Last but of rt_ifp cleanup. Since we want to print the interface names in
those log messages we need to do the if_get/if_put dance there. Since this
is only in 2 places which should not be super common that should be fine
and with this arp should be MP save :)

-- 
:wq Claudio

Index: if_ether.c
===================================================================
RCS file: /cvs/src/sys/netinet/if_ether.c,v
retrieving revision 1.196
diff -u -p -r1.196 if_ether.c
--- if_ether.c  2 Dec 2015 21:09:06 -0000       1.196
+++ if_ether.c  2 Dec 2015 21:16:14 -0000
@@ -565,14 +565,19 @@ in_arpinput(struct mbuf *m)
                                        if (ifp->if_type != IFT_CARP)
 #endif
                                        {
+                                               struct ifnet *rifp = if_get(
+                                                   rt->rt_ifidx);
+                                               if (rifp == NULL)
+                                                       goto out;
                                                inet_ntop(AF_INET, &isaddr,
                                                    addr, sizeof(addr));
                                                log(LOG_WARNING, "arp: attempt"
                                                   " to overwrite entry for"
                                                   " %s on %s by %s on %s\n",
-                                                  addr, rt->rt_ifp->if_xname,
+                                                  addr, rifp->if_xname,
                                                   ether_sprintf(ea->arp_sha),
                                                   ifp->if_xname);
+                                               if_put(rifp);
                                        }
                                        goto out;
                                } else {
@@ -587,13 +592,17 @@ in_arpinput(struct mbuf *m)
                        changed = 1;
                        }
                } else if (!if_isconnected(ifp, rt->rt_ifidx)) {
+                       struct ifnet *rifp = if_get(rt->rt_ifidx);
+                       if (rifp == NULL)
+                               goto out;
                        inet_ntop(AF_INET, &isaddr, addr, sizeof(addr));
                        log(LOG_WARNING,
                            "arp: attempt to add entry for %s "
                            "on %s by %s on %s\n", addr,
-                           rt->rt_ifp->if_xname,
+                           rifp->if_xname,
                            ether_sprintf(ea->arp_sha),
                            ifp->if_xname);
+                       if_put(rifp);
                        goto out;
                }
                sdl->sdl_alen = sizeof(ea->arp_sha);


Reply via email to