In the IPv4 forwarding case your kernel checks if its is doing ARP proxy
for the destination to decide if it needs to send an ICMP redirect msg.
Currently arpproxy() does an iteration on the global list of interfaces.
This will be not allowed as soon as we go SMP. This list MUST not be
used in interrupt context.
But this is actually not needed because if you add an ARP entry that
matches one of your lladdr, with:
# arp -s 204.1.2.3 00:90:27:bb:cc:dd pub
The entry will be attached on the corresponding interface, so we can
simplify the check as below.
Ok?
Index: netinet/if_ether.c
===================================================================
RCS file: /cvs/src/sys/netinet/if_ether.c,v
retrieving revision 1.162
diff -u -p -r1.162 if_ether.c
--- netinet/if_ether.c 19 Aug 2015 11:05:33 -0000 1.162
+++ netinet/if_ether.c 3 Sep 2015 08:59:30 -0000
@@ -826,29 +826,24 @@ arplookup(u_int32_t addr, int create, in
* Check whether we do proxy ARP for this address and we point to ourselves.
*/
int
-arpproxy(struct in_addr in, u_int rdomain)
+arpproxy(struct in_addr in, unsigned int rtableid)
{
+ struct sockaddr_dl *sdl;
struct rtentry *rt;
- struct llinfo_arp *la;
struct ifnet *ifp;
int found = 0;
- rt = arplookup(in.s_addr, 0, SIN_PROXY, rdomain);
+ rt = arplookup(in.s_addr, 0, SIN_PROXY, rtableid);
if (rt == NULL)
return (0);
- la = ((struct llinfo_arp *)rt->rt_llinfo);
- TAILQ_FOREACH(ifp, &ifnet, if_list) {
- if (ifp->if_rdomain != rdomain)
- continue;
+ sdl = (struct sockaddr_dl *)rt->rt_gateway;
+ if (sdl->sdl_alen != ETHER_ADDR_LEN)
+ return (0);
- if (!memcmp(LLADDR((struct sockaddr_dl *)la->la_rt->rt_gateway),
- LLADDR(ifp->if_sadl),
- ETHER_ADDR_LEN)) {
- found = 1;
- break;
- }
- }
+ ifp = rt->rt_ifp;
+ if (!memcmp(LLADDR(sdl), LLADDR(ifp->if_sadl), sdl->sdl_alen))
+ found = 1;
return (found);
}
Index: netinet/if_ether.h
===================================================================
RCS file: /cvs/src/sys/netinet/if_ether.h,v
retrieving revision 1.57
diff -u -p -r1.57 if_ether.h
--- netinet/if_ether.h 23 Jun 2015 13:20:17 -0000 1.57
+++ netinet/if_ether.h 3 Sep 2015 08:59:30 -0000
@@ -272,7 +280,7 @@ extern struct ifnet *revarp_ifp;
#endif /* NFSCLIENT */
void arprequest(struct ifnet *, u_int32_t *, u_int32_t *, u_int8_t *);
-int arpproxy(struct in_addr, u_int);
+int arpproxy(struct in_addr, unsigned int);
void revarpinput(struct mbuf *);
void in_revarpinput(struct mbuf *);
void revarprequest(struct ifnet *);