Do not grab the KERNEL_LOCK if the source address is already specified.
Note that the sending path will still be done while holding the
KERNEL_LOCK but it doesn't hurt to get this right. Plus this makes it
similar to another chunk in this file.
ok?
Index: netinet/ip_output.c
===================================================================
RCS file: /cvs/src/sys/netinet/ip_output.c,v
retrieving revision 1.322
diff -u -p -r1.322 ip_output.c
--- netinet/ip_output.c 4 May 2016 13:22:51 -0000 1.322
+++ netinet/ip_output.c 30 May 2016 04:53:09 -0000
@@ -185,14 +185,17 @@ reroute:
if ((IN_MULTICAST(ip->ip_dst.s_addr) ||
(ip->ip_dst.s_addr == INADDR_BROADCAST)) &&
imo != NULL && (ifp = if_get(imo->imo_ifidx)) != NULL) {
- struct in_ifaddr *ia;
mtu = ifp->if_mtu;
- KERNEL_LOCK();
- IFP_TO_IA(ifp, ia);
- if (ip->ip_src.s_addr == INADDR_ANY && ia)
- ip->ip_src = ia->ia_addr.sin_addr;
- KERNEL_UNLOCK();
+ if (ip->ip_src.s_addr == INADDR_ANY) {
+ struct in_ifaddr *ia;
+
+ KERNEL_LOCK();
+ IFP_TO_IA(ifp, ia);
+ if (ia != NULL)
+ ip->ip_src = ia->ia_addr.sin_addr;
+ KERNEL_UNLOCK();
+ }
} else {
struct in_ifaddr *ia;