Keep BGP control endpoint off OLSR mesh address
This commit is contained in:
1 parent
90a5e4a189
commit
fde4be1a8e
3 files changed
+57
-21
No files matched your search
+22
-19
@@ -5,16 +5,11 @@ available. Containers need the official container package and container-enabled
|
||||
device mode, supported ARM hardware, and sufficient storage. No replacement
|
||||
RouterOS image, custom signing key, or configuration reset is required.
|
||||
|
||||
Status: development snapshot, **not ready for mesh deployment**. Both ARM
|
||||
architectures build and pass BIRD configuration checks, but full native forwarding
|
||||
has not passed hardware acceptance. WohnzimmerAP's old container forwarding path
|
||||
has been disabled. The replacement test is stopped too.
|
||||
|
||||
Outstanding blocker: other mesh nodes currently resolve the container's OLSR
|
||||
address to its MAC. RouterOS must own that forwarding identity before the
|
||||
container can act only as a routing controller. Preserving outgoing next hops
|
||||
alone does not fix incoming transit. The instructions below document the current
|
||||
lab topology, not a completed production installation.
|
||||
Status: experimental. The WohnzimmerAP live test now confirms OLSR neighbor
|
||||
discovery, an established RouterOS BGP session, hundreds of accepted dynamic
|
||||
routes, and correct neighbor-based gateways on `olsr-mesh`. Disabling the BGP
|
||||
connection withdraws those routes while OLSR keeps running. Full end-to-end
|
||||
forwarding and return traffic still need hardware acceptance.
|
||||
|
||||
This is an experimental control-plane-only container. It discovers OLSRv1 routes
|
||||
and exports the actual neighbor next hops to RouterOS over BGP. RouterOS forwards
|
||||
@@ -26,9 +21,12 @@ There is no custom native OLSR configuration dialog in this container edition.
|
||||
## Networking
|
||||
|
||||
RouterOS and the container have separate network namespaces. **Do not connect
|
||||
BGP to localhost.** RouterOS connects to the container's transit IP on TCP 1179.
|
||||
In this example RouterOS is 172.31.255.1 and the container is 172.31.255.2.
|
||||
Choose a different unused transit subnet if this overlaps existing addressing.
|
||||
BGP to localhost.** The container's OLSR identity is its mesh address, while BGP
|
||||
uses 172.31.255.2 on container loopback and 172.31.255.1 on RouterOS. The
|
||||
container adds an on-link route to the RouterOS peer through its VETH. The
|
||||
private 172.31.255.0/30 addresses are only the BGP control path; they are not
|
||||
OLSR interface addresses or route next hops. RouterOS installs learned routes
|
||||
through the actual OLSR neighbor on the mesh bridge.
|
||||
|
||||
Create a VLAN 4 interface on the existing trunk bridge, then bridge that VLAN
|
||||
interface with the container VETH using a separate bridge. This hands the
|
||||
@@ -37,11 +35,14 @@ not hand over the physical port or change the existing bridge's PVID. The trunk
|
||||
bridge must already permit tagged VLAN 4 on the CPU and appropriate uplink.
|
||||
Do not also bridge the physical parent into the new bridge.
|
||||
|
||||
The VETH receives both a unique community-assigned mesh IPv4 /32 and the
|
||||
transit address. These addresses belong to the container. RouterOS needs its own
|
||||
separate community-assigned address for router-originated mesh traffic; do not
|
||||
assign the container's address to RouterOS too. LAN traffic also needs a valid
|
||||
return path. Learning a destination route does not advertise your source network.
|
||||
The VETH receives the unique community-assigned mesh IPv4 /32 as its address;
|
||||
that identity belongs to the container, not RouterOS. RouterOS keeps
|
||||
172.31.255.1/30 on the mesh bridge for BGP. The container binds its BGP endpoint,
|
||||
172.31.255.2/32, on loopback and adds an on-link route to the RouterOS peer
|
||||
through the VETH. This keeps the private control addresses off the OLSR
|
||||
interface. Add a RouterOS /32 route to the container mesh identity through the
|
||||
mesh bridge. LAN traffic also needs a valid return path. Learning a destination
|
||||
route does not advertise your source network.
|
||||
|
||||
BIRD preserves each OLSR next-hop IP and tags its outgoing link using community
|
||||
`64514:LINK_ID`. RouterOS maps that ID to a local interface. Direct neighbor /32
|
||||
@@ -96,11 +97,13 @@ Upload the image archive to usb1/olsr-container.tar first.
|
||||
/interface/vlan/add name=olsr-vlan4 interface=bridgeLocal vlan-id=4 comment=mikrotik-olsr-container
|
||||
/interface/bridge/add name=olsr-mesh comment=mikrotik-olsr-container
|
||||
/interface/bridge/port/add bridge=olsr-mesh interface=olsr-vlan4
|
||||
/interface/veth/add name=veth-olsr address=NODE_IP/32,172.31.255.2/30 gateway=172.31.255.1
|
||||
/interface/veth/add name=veth-olsr address=NODE_IP/32
|
||||
/interface/bridge/port/add bridge=olsr-mesh interface=veth-olsr
|
||||
/ip/address/add address=172.31.255.1/30 interface=olsr-mesh comment=mikrotik-olsr-container
|
||||
/ip/route/add dst-address=NODE_IP/32 gateway=olsr-mesh comment=mikrotik-olsr-container
|
||||
/container/envs/add list=olsr key=OLSR_INTERFACE value=veth-olsr
|
||||
/container/envs/add list=olsr key=OLSR_NODE_IP value=NODE_IP
|
||||
/container/envs/add list=olsr key=BGP_INTERFACE value=veth-olsr
|
||||
/container/envs/add list=olsr key=BGP_LOCAL_IP value=172.31.255.2
|
||||
/container/envs/add list=olsr key=BGP_PEER_IP value=172.31.255.1
|
||||
/container/add name=olsr file=usb1/olsr-container.tar interface=veth-olsr envlist=olsr root-dir=usb1/olsr-root logging=yes start-on-boot=no
|
||||
|
||||
+23
-2
@@ -40,8 +40,12 @@ def configuration(env):
|
||||
node = str(ipaddress.IPv4Address(env['OLSR_NODE_IP']))
|
||||
local = str(ipaddress.IPv4Address(env['BGP_LOCAL_IP']))
|
||||
peer = str(ipaddress.IPv4Address(env['BGP_PEER_IP']))
|
||||
if len({local, peer, node}) != 3 or any(link['address'] in (local, peer) for link in mesh_links):
|
||||
raise ValueError('Container and RouterOS addresses must be distinct')
|
||||
if len({local, peer, node}) != 3 or any(
|
||||
link['address'] in (local, peer) for link in mesh_links):
|
||||
raise ValueError('Mesh and BGP control addresses must be distinct')
|
||||
control_interface = env.get('BGP_INTERFACE', mesh_links[0]['interface'])
|
||||
if not re.fullmatch(r'[A-Za-z0-9_.:-]{1,15}', control_interface):
|
||||
raise ValueError('Invalid BGP control interface name')
|
||||
debug = int(env.get('OLSR_DEBUG', '0'))
|
||||
if debug not in (0, 1):
|
||||
raise ValueError('OLSR_DEBUG must be 0 or 1')
|
||||
@@ -75,6 +79,18 @@ LinkQualityFishEye 0
|
||||
return config, bird
|
||||
|
||||
|
||||
def network_setup(env):
|
||||
"""Keep the BGP control endpoint local while OLSR uses only mesh IPs."""
|
||||
mesh_links = links(env)
|
||||
control_interface = env.get('BGP_INTERFACE', mesh_links[0]['interface'])
|
||||
local = ipaddress.IPv4Address(env['BGP_LOCAL_IP'])
|
||||
peer = ipaddress.IPv4Address(env['BGP_PEER_IP'])
|
||||
return [
|
||||
['ip', 'address', 'add', f'{local}/32', 'dev', 'lo'],
|
||||
['ip', 'route', 'add', f'{peer}/32', 'dev', control_interface],
|
||||
]
|
||||
|
||||
|
||||
def main():
|
||||
config, bird = configuration(os.environ)
|
||||
Path('/run/olsrd.conf').write_text(config)
|
||||
@@ -82,6 +98,11 @@ def main():
|
||||
subprocess.run(['bird', '-p', '-c', '/run/bird.conf'], check=True)
|
||||
if '--check' in sys.argv:
|
||||
return
|
||||
# Keep the private BGP endpoint off the mesh interface. RouterOS reaches
|
||||
# it over the shared bridge; the container replies through an explicit
|
||||
# on-link route. OLSR therefore sees only the community-assigned mesh IP.
|
||||
for command in network_setup(os.environ):
|
||||
subprocess.run(command, check=True)
|
||||
# olsrd enables the kernel forwarding sysctl itself. A fail-closed FORWARD
|
||||
# policy prevents transit regardless of that sysctl. No NAT or policy route
|
||||
# into OLSR's private table: RouterOS owns packet forwarding.
|
||||
|
||||
@@ -36,6 +36,18 @@ class ContainerRouting(unittest.TestCase):
|
||||
self.assertIn('set gw-interface ether2', rule)
|
||||
self.assertTrue(rule.endswith('reject;'))
|
||||
|
||||
def test_mesh_identity_and_private_bgp_endpoint_are_distinct(self):
|
||||
env = self.env()
|
||||
olsr, bird = start.configuration(env)
|
||||
self.assertIn('MainIp 10.12.4.173', olsr)
|
||||
self.assertIn('IPv4Src 10.12.4.173', olsr)
|
||||
self.assertIn('local 172.31.255.2 port 1179', bird)
|
||||
self.assertIn('neighbor 172.31.255.1 as 64512', bird)
|
||||
self.assertEqual(start.network_setup(env), [
|
||||
['ip', 'address', 'add', '172.31.255.2/32', 'dev', 'lo'],
|
||||
['ip', 'route', 'add', '172.31.255.1/32', 'dev', 'veth-olsr'],
|
||||
])
|
||||
|
||||
def test_ambiguous_links_rejected(self):
|
||||
env = self.env()
|
||||
env['OLSR_LINKS'] = '[{"interface":"a","address":"10.1.1.1","id":1},{"interface":"b","address":"10.1.1.2","id":1}]'
|
||||
|
||||
Reference in new issue
Block a user