vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| When assigning an address to a carp interface, it searches through the existing interface addresses and picks the first matching subnet available. This causes problems when you have overlapping subnets, e.g.: # ifconfig vlan0 10.0.0.1 netmask 255.0.0.0 vlan 1 vlandev em0 up # ifconfig vlan1 10.5.0.1 netmask 255.255.0.0 vlan 2 vlandev em0 up # ifconfig carp0 10.5.0.50 netmask 255.255.255.255 vhid 1 carpdev vlan1 up ifconfig: SIOCAIFADDR: Can't assign requested address The patch below gives preference to addresses with a more specific subnet mask, or with an equal subnet mask but on the same interface we're already using as the carpdev. With this patch applied, the above test case results in carp0 being assigned 10.5.0.50 as expected. Index: ip_carp.c ================================================== ================= RCS file: /cvs/src/sys/netinet/ip_carp.c,v retrieving revision 1.162 diff -p -u -r1.162 ip_carp.c --- ip_carp.c 20 Feb 2008 22:11:53 -0000 1.162 +++ ip_carp.c 21 Mar 2008 01:59:14 -0000 @@ -1970,7 +1970,10 @@ carp_set_addr(struct carp_softc *sc, str (ia->ia_ifp->if_flags & IFF_MULTICAST) && (sin->sin_addr.s_addr & ia->ia_subnetmask) == ia->ia_subnet) { - if (!ia_if) + if (!ia_if || + ia->ia_subnetmask > ia_if->ia_subnetmask || + (ia->ia_subnetmask == ia_if->ia_subnetmask && + ia->ia_ifp == ifp)) ia_if = ia; } } |