2

I have a PC ("main PC") with two interfaces mgbe0 and mgbe1. Both of these interfaces connect to another PCs A and B (mgbe0->"A", mbge1->"B"). Both PCs A and B are on subnet 2: 192.168.2.xxx, and I cannot change this. So to connect to the other PCs, I need both interfaces on the main PC to be on subnet 2. After googling I found that I need a bridge to set both interfaces to the same IP address. This is my netplan config:

network:
  version: 2
  renderer: NetworkManager
  ethernets:
    mgbe0:
      dhcp4: no
    mgbe1:
      dhcp4: no
  bridges:
    br0:
      dhcp4: no
      addresses:
        - 192.168.2.86/24
      interfaces:
        - mgbe0
        - mgbe1

With this configuration, the main PC can ping and ssh into both other PCs, and both PC A and PC B can ping/ssh into the main PC.

But a problem occurs: PC A (connected to mbge0) is synchronized with PTP (precision time protocol) to the mgbe0 clock. But when I have the bridge set, the PTP doesn't work. This is probably because the complete path delay measurement, that is a delay request and a delay response, doesn't finish.

How can I configure the bridge to allow these requests to work? Or is it possible to have mgbe0 and mgbe1 on different IP addresses on the same subnet? If so, how can i do this?

Thank you for your help!

1 Answers1

1

PTP (IEEE 1588-2019) supports two different transports: Layer 2 and Layer 3 (UDP).

UDP is by far the more common of the two, so I will assume you are using it. In that case, you are in a bit of "rock and a hard place" situation:

  • LinuxPTP does not support bridges, so you can't configure it to use br0.
  • mgbe0 does not have an IP address, so it cannot send UDP datagrams (which are layered on top of IP).

In particular, if you use PTPv2.1 hybrid PTP (which I personally prefer since it is the most efficient use of the network), then you need to be able to both receive multicast UDP datagrams as well as send and receive unicast UDP datagrams.

So, you need to "somehow" trick Linux into sending PTP datagrams from mgbe0 using the source IP of br0, and also make sure that received PTP datagrams get forwarded to LinuxPTP.

Your situation seems to be similar to the one in this mailing list thread on the linux-netdev mailing list: RFC: PTP Boundary Clock over UDPv4/UDPv6 on Linux bridge. Unfortunately, this thread does not come to a general solution, only a workaround using ebtables to move the datagrams around the kernel:

ebtables --table broute --append BROUTING --protocol 0x88F7 --jump DROP

ebtables --table broute --append BROUTING --protocol 0x0800 --ip-protocol udp --ip-destination-port 320 --jump DROP ebtables --table broute --append BROUTING --protocol 0x0800 --ip-protocol udp --ip-destination-port 319 --jump DROP

ebtables --table broute --append BROUTING --protocol 0x86DD --ip6-protocol udp --ip6-destination-port 320 --jump DROP ebtables --table broute --append BROUTING --protocol 0x86DD --ip6-protocol udp --ip6-destination-port 319 --jump DROP

Note: at first glance, it seems like this would completely break PTP. After all, it filters PTP traffic and DROPs it. However, the BROUTING chain in the broute table has a special meaning for the ACCEPT and DROP targets: ACCEPT means "should be bridged" and DROP means "should be routed".

So, what these rules are saying is that UDP packets addressed to ports 319 and 320 (i.e., PTP) should be routed, not bridged. This means that they are processed by the constituent member interfaces of the bridge, not the bridge itself.

If I understood all of that correctly (which I will not guarantee, as I have literally only started learning about it when I started writing this answer 10 minutes ago), mgbe0 will need to have a valid IP configuration for this to work. So, you would need to modify your Netplan configuration something like this:

network:
  version: 2
  renderer: NetworkManager
  ethernets:
    mgbe0:
      dhcp4: no
      addresses:
        - 192.168.2.85/24 # or whatever
    mgbe1:
      dhcp4: no
  bridges:
    br0:
      dhcp4: no
      addresses:
        - 192.168.2.86/24
      interfaces:
        - mgbe0
        - mgbe1