On 25/03/14(Tue) 16:52, Claudio Jeker wrote:
> On Tue, Mar 25, 2014 at 11:39:30AM +0100, Martin Pieuchot wrote:
> > Why do we do a lookup on all the addresses of the systems to know if the
> > destination address given to ether_output() is on the carp interface?
> >
> > If this address is on any of our interfaces we should not even end up
> > here. Since both arp_rtrequest() and nd6_rtrequest() change the ifp
> > of the route entries for our addresses to loopback, if `dst' is one
> > of our addresses it won't be passed to ether_output() but looutput().
> >
> > ok?
>
> I think this is OK and the check should die in a fire but...
> What about bpf senders or more exotic things like MPLS?
> I think ifa_ifwithaddr() will fail on them but I learned that some of
> those checks are non obivous but needed.
Thanks for the advice :)
In this case, for bpf senders the `dst' should not be of any sa_family
present in the address list. For exotic things like MPLS^^ a route
lookup is done before calling mpls_output() and if it matches an address
on our system, then the associated ifp will be loopback and
ether_output() won't be called.
Apart from that, mikeb@ pointed out that my diff removes a supplementary
check in case the carp interface is down. So I'll commit the simpler diff
below unless I hear objections.
Index: net/if_ethersubr.c
===================================================================
RCS file: /home/ncvs/src/sys/net/if_ethersubr.c,v
retrieving revision 1.162
diff -u -p -r1.162 if_ethersubr.c
--- net/if_ethersubr.c 17 Feb 2014 14:48:48 -0000 1.162
+++ net/if_ethersubr.c 25 Mar 2014 17:09:00 -0000
@@ -228,14 +228,6 @@ ether_output(struct ifnet *ifp0, struct
#if NCARP > 0
if (ifp->if_type == IFT_CARP) {
- struct ifaddr *ifa;
-
- /* loop back if this is going to the carp interface */
- if (dst != NULL && LINK_STATE_IS_UP(ifp0->if_link_state) &&
- (ifa = ifa_ifwithaddr(dst, ifp->if_rdomain)) != NULL &&
- ifa->ifa_ifp == ifp0)
- return (looutput(ifp0, m, dst, rt0));
-
ifp = ifp->if_carpdev;
ac = (struct arpcom *)ifp;