openwrt / odhcpd

This repository is a mirror of https://git.openwrt.org/?p=project/odhcpd.git. Pull requests will be accepted which will be merged in odhcpd.git
GNU General Public License v2.0
162 stars 98 forks source link

Unsolicited router advertisements are sent to all interfaces #81

Closed lowjoel closed 6 years ago

lowjoel commented 8 years ago

Related: https://forum.openwrt.org/viewtopic.php?pid=326050

odhcpd sends unsolicited (sent at intervals) router advertisements regularly as per the Neighbour Discovery Protocol. However, it sends all registered router addresses as advertisements on all links. This means :1::/64 will get unsolicited advertisements for ::2::/64, and vice versa.

Solicited router advertisements (triggered by clients) are OK.

I've traced this down (via eyeballing) to router.c:send_router_advert. I am guessing that send_router_advert is called once for every defined interface. In that case, the destination struct sockaddr_in6 dest = {AF_INET6, 0, 0, ALL_IPV6_NODES, 0}; would cause the router advertisement to be sent to all nodes on all interfaces, thus every possible interface x router combination is sent out to all connected nodes.

I'm not familiar with the network stack enough to know if this is a problem, and if it is, figure out what the fix is. If it isn't a problem, what would be the recommended way to not end up with this address confusion?

Thanks!

ghost commented 6 years ago

Same issue for me as well. I'd like odhcpd to respect the ip6assign prefix on the given network interface. Broadcasting every LAN's routes on every other LAN causes clients to configure themselves with address from all prefixes.

I'm not sure if this behavior is standard IPv6 behavior, or something that needs additional config options or fixes.

Anyone have any tips?

EDIT:

Actually in my case, odhcpd was fine. The issue was attaching a VLAN trunk(an untagged VLAN and two tagged VLANs) to a Windows PC. The driver or windows would strip the VLAN tag from the tagged traffic and its router advertisements would reach the PC and the PC would configure itself using router advertisements from all three VLANs.

lowjoel commented 6 years ago

@dedeckeh why is this closed? My machines are on separate VLANs and they get both IPv6 prefixes.

dedeckeh commented 6 years ago

odhcpd only sends the prefixes which are assigned to the interface on which it is sending a router advertisement messages; this can be seen in the send_router_advert code (see https://github.com/openwrt/odhcpd/blob/master/src/router.c#L408). Also sending a message to ALL_IPV6_NODES does not mean the message is sent to all nodes on all interfaces; odhcpd_send takes as last argument the interface on which the RA message needs to be sent (https://github.com/openwrt/odhcpd/blob/master/src/router.c#L653). So the logic inside odhcpd is perfectly fine

lowjoel commented 6 years ago

Thanks @dedeckeh. It seems like the original code I referenced 2 years ago (https://github.com/openwrt/odhcpd/blob/32b977a5336612a5c01f7426c4d165685fa8aca0/src/router.c#L458) has changed substantially. Unfortunately I can't correlate the version of odhcpd I'm using since I'm using the version bundled with LEDE 17.01.

I'll hope that the fixes are released with the next version of OpenWRT. Thanks a lot.

dedeckeh commented 6 years ago

It would be nice to see the used network and dhcp config together with a tcpdump of the RA messages showing the issue; otherwise it gets hard to trouble shoot issues based on observations

lowjoel commented 6 years ago

@dedeckeh After upgrading to OpenWRT 18.06, I've done a tcpdump (on the router), as well as a capture on my desktop (on ethernet) which has been assigned two router addresses. It seems from the tcpdump that odhcpd is indeed sending the correct prefixes to each of the interfaces, but my desktop gets both ICMPv6 messages. My laptop (on wifi) only gets the correct ICMPv6 sent to the correct subnet. This is in contrast to the past where both my ethernet and wifi clients both get two different routers.

So after the upgrade, it seems like it's the same problem as @exdeus7 above.

Thanks for your explanation and your time.

ghost commented 6 years ago

lowjoel: Are you using Windows? If so, there is no issue. Change the switch configuration so that you're not having untagged and tagged VLANs on the same port.

lowjoel commented 6 years ago

Yeah. I'm planning to rewire so I can do that. Thanks for the advice.