diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2017-05-12 22:43:22 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2017-05-12 22:43:22 +0000 |
commit | 48f28640af9ee122465351110d8a5c85c20a3d2a (patch) | |
tree | 00b0ecd5c26105e148b04a2862f3844edecc776b /sys | |
parent | 918a32864b4796d54c4b0c734ee7b8ae1f8f722b (diff) |
Unify duplicate code from address family switch in bridge_ipsec().
Remove an if condition that cannot happen.
OK mikeb@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/if_bridge.c | 40 |
1 files changed, 15 insertions, 25 deletions
diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index 4e27e3f249f..377f6f5d074 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bridge.c,v 1.294 2017/02/05 16:04:14 jca Exp $ */ +/* $OpenBSD: if_bridge.c,v 1.295 2017/05/12 22:43:21 bluhm Exp $ */ /* * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net) @@ -1425,17 +1425,6 @@ bridge_ipsec(struct bridge_softc *sc, struct ifnet *ifp, sizeof(struct in_addr), (caddr_t)&dst.sin.sin_addr); - if (ip->ip_p == IPPROTO_ESP) - m_copydata(m, hlen, sizeof(u_int32_t), - (caddr_t)&spi); - else if (ip->ip_p == IPPROTO_AH) - m_copydata(m, hlen + sizeof(u_int32_t), - sizeof(u_int32_t), (caddr_t)&spi); - else if (ip->ip_p == IPPROTO_IPCOMP) { - m_copydata(m, hlen + sizeof(u_int16_t), - sizeof(u_int16_t), (caddr_t)&cpi); - spi = ntohl(htons(cpi)); - } break; #ifdef INET6 case AF_INET6: @@ -1459,25 +1448,26 @@ bridge_ipsec(struct bridge_softc *sc, struct ifnet *ifp, sizeof(struct in6_addr), (caddr_t)&dst.sin6.sin6_addr); - if (proto == IPPROTO_ESP) - m_copydata(m, hlen, sizeof(u_int32_t), - (caddr_t)&spi); - else if (proto == IPPROTO_AH) - m_copydata(m, hlen + sizeof(u_int32_t), - sizeof(u_int32_t), (caddr_t)&spi); - else if (proto == IPPROTO_IPCOMP) { - m_copydata(m, hlen + sizeof(u_int16_t), - sizeof(u_int16_t), (caddr_t)&cpi); - spi = ntohl(htons(cpi)); - } break; #endif /* INET6 */ default: return (0); } - if (proto == 0) - goto skiplookup; + switch (proto) { + case IPPROTO_ESP: + m_copydata(m, hlen, sizeof(u_int32_t), (caddr_t)&spi); + break; + case IPPROTO_AH: + m_copydata(m, hlen + sizeof(u_int32_t), + sizeof(u_int32_t), (caddr_t)&spi); + break; + case IPPROTO_IPCOMP: + m_copydata(m, hlen + sizeof(u_int16_t), + sizeof(u_int16_t), (caddr_t)&cpi); + spi = ntohl(htons(cpi)); + break; + } splsoftassert(IPL_SOFTNET); |