diff options
author | 2014-09-30 08:21:21 +0000 | |
---|---|---|
committer | 2014-09-30 08:21:21 +0000 | |
commit | b866b63ef50ec82aafccfabc71151f14d78537ff (patch) | |
tree | b3b94d7974befba897e0104e1099b8f5d9804b88 | |
parent | implement atomic operations using ll/sc, and convert rw_cas and callers of the (diff) | |
download | wireguard-openbsd-b866b63ef50ec82aafccfabc71151f14d78537ff.tar.xz wireguard-openbsd-b866b63ef50ec82aafccfabc71151f14d78537ff.zip |
Use the routing table instead of the RB-tree for address lookups in
in_ouraddr().
The lookup done in the forwarding case will hopefully be merged with
this one in the future.
ok kspillner@, bluhm@, claudio@
-rw-r--r-- | sys/netinet/ip_input.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 46213926aa6..030cca4de7a 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_input.c,v 1.236 2014/09/27 12:26:16 mpi Exp $ */ +/* $OpenBSD: ip_input.c,v 1.237 2014/09/30 08:21:21 mpi Exp $ */ /* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */ /* @@ -643,7 +643,8 @@ bad: int in_ouraddr(struct mbuf *m, struct ifnet *ifp, struct in_addr ina) { - struct in_ifaddr *ia; + struct in_ifaddr *ia = NULL; + struct rtentry *rt; struct sockaddr_in sin; #if NPF > 0 struct pf_state_key *key; @@ -666,7 +667,12 @@ in_ouraddr(struct mbuf *m, struct ifnet *ifp, struct in_addr ina) sin.sin_len = sizeof(sin); sin.sin_family = AF_INET; sin.sin_addr = ina; - ia = ifatoia(ifa_ifwithaddr(sintosa(&sin), m->m_pkthdr.ph_rtableid)); + rt = rtalloc1(sintosa(&sin), 0, m->m_pkthdr.ph_rtableid); + if (rt != NULL) { + if (rt->rt_flags & (RTF_LOCAL|RTF_BROADCAST)) + ia = ifatoia(rt->rt_ifa); + rtfree(rt); + } if (ia == NULL) { struct ifaddr *ifa; |