jech / babeld

The Babel routing daemon
http://www.irif.fr/~jch/software/babel/
MIT License
385 stars 92 forks source link

routing loop due to ignoring linkdown #111

Closed DanielG closed 11 months ago

DanielG commented 1 year ago

Hi Juliusz,

here's a routing loop I just ran into. I have sysctl net.ipv6.conf.all.ignore_routes_with_linkdown=1 on my router this is to ignore routes via interfaces that are down at the link level (but administratively up).

babeld doesn't seem to know about this kernel feature so it will export routes which are ignored by the kernel. In my case this caused a routing loop. babeld exports a specific route, say /64, another router will use this route to send us traffic, but since the kernel ignores the linkdown /64 it falls back to the default route instead, which in my case forms a loop.

We might wan to add an option to honor the linkdown route attribute or one to ignore routes on any interfaces that are linkdown.

--Daniel

jech commented 1 year ago

So what you are saying is that there's a sysctl that tells the kernel to disobey the routing table? I don't see how we could possibly avoid routing loops if the kernel is not obeying the routing table.

We might wan to add an option to honor the linkdown route attribute or one to ignore routes any interfaces that are linkdown.

Does the link-detect option do what you want? If you find it useful, we might make it into a per-interface option.

DanielG commented 1 year ago

Hi Juliusz,

On Fri, Oct 27, 2023 at 10:39:24AM -0700, Juliusz Chroboczek wrote:

So what you are saying is that there's a sysctl that tells the kernel to disobey the routing table?

I'd say babeld's model of how the Linux routing table works is incomplete :)

I don't see how we could possibly avoid routing loops if the kernel is not obeying the routing table.

I belive (but haven't checked) the kernel will send route change netlink events when routes become ignored, the linkdown (RTNH_F_LINKDOWN) should be set in those. So it ought to be easy for babeld to react to routes becoming ignored in this way.

Only problem I see is that (AFAIK) linkdown will be set whether or not the ignore_routes_with_linkdown sysctl is enabled. So ignoring these routes would have to be made conditional on the sysctl being enabled or a babeld config parameter (eg. respect-kernel-linkdown true|false).

I'd prefer we respect the sysctl by default but allow overriding that behaviour with a (per-interface) respect-kernel-linkdown false.

We might wan to add an option to honor the linkdown route attribute or one to ignore routes any interfaces that are linkdown.

Does the link-detect option do what you want? If you find it useful, we might make it into a per-interface option.

I'll test that.

Thanks, --Daniel

jech commented 11 months ago

I'd say babeld's model of how the Linux routing table works is incomplete :)

The role of the routing daemon is not to model the Linux routing table. It's role is to construct a routing table and instruct the kernel to forward packets according to that routing table. If the kernel is configured to ignore the routing daemon's instructions, then routing is going to break.

I belive (but haven't checked) the kernel will send route change netlink events when routes become ignored, the linkdown (RTNH_F_LINKDOWN) should be set in those. So it ought to be easy for babeld to react to routes becoming ignored in this way.

I'm not opposed to accepting a (tested!) patch that does that. However, I think we should simply document that babeld is not compatible with ignore_routes_with_linkdown, and that people should be using link-detect instead.

(As a side note, the reason why link-detect is not the default is that it's unreliable on WiFi hardware. I think it might be an improvement to make it into a per-interface option, and to enable it automatically when the interface is known to support it reliably. But that's a different matter.)

Closing this issue, please feel free to reopen it if you think there's anything actionable about it.