diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2013-10-13 12:09:55 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2013-10-13 12:09:55 +0000 |
commit | 399c5007d024afdc86064ad9ed624913ce0d52e3 (patch) | |
tree | fab6587476de9abe6ced694bf4ede1a6f62d15f5 | |
parent | d5c5a8879d36e1fb79670efda231a1f2d13a2a7e (diff) |
Just use sockaddr_union instead of a handcrafted version and rename
bridge_tunnelupdate to a more generic name bridge_copyaddr.
No functional change.
-rw-r--r-- | sys/net/if_bridge.c | 28 | ||||
-rw-r--r-- | sys/net/if_bridge.h | 12 |
2 files changed, 14 insertions, 26 deletions
diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index c1798b0371b..c043d797356 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bridge.c,v 1.216 2013/10/13 10:10:02 reyk Exp $ */ +/* $OpenBSD: if_bridge.c,v 1.217 2013/10/13 12:09:53 reyk Exp $ */ /* * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net) @@ -161,7 +161,7 @@ int bridge_ipsec(struct bridge_softc *, struct ifnet *, int bridge_clone_create(struct if_clone *, int); int bridge_clone_destroy(struct ifnet *ifp); int bridge_delete(struct bridge_softc *, struct bridge_iflist *); -void bridge_tunnelupdate(struct sockaddr *, struct sockaddr *); +void bridge_copyaddr(struct sockaddr *, struct sockaddr *); #define ETHERADDR_IS_IP_MCAST(a) \ /* struct etheraddr *a; */ \ @@ -1720,7 +1720,7 @@ bridge_rtupdate(struct bridge_softc *sc, struct ether_addr *ea, bcopy(ea, &p->brt_addr, sizeof(p->brt_addr)); p->brt_if = ifp; p->brt_age = 1; - bridge_tunnelupdate(sa, (struct sockaddr *)&p->brt_tunnel); + bridge_copyaddr(sa, (struct sockaddr *)&p->brt_tunnel); if (setflags) p->brt_flags = flags; @@ -1747,7 +1747,7 @@ bridge_rtupdate(struct bridge_softc *sc, struct ether_addr *ea, if (q->brt_if == ifp) q->brt_age = 1; ifp = q->brt_if; - bridge_tunnelupdate(sa, + bridge_copyaddr(sa, (struct sockaddr *)&q->brt_tunnel); goto want; @@ -1763,7 +1763,7 @@ bridge_rtupdate(struct bridge_softc *sc, struct ether_addr *ea, bcopy(ea, &p->brt_addr, sizeof(p->brt_addr)); p->brt_if = ifp; p->brt_age = 1; - bridge_tunnelupdate(sa, + bridge_copyaddr(sa, (struct sockaddr *)&p->brt_tunnel); if (setflags) @@ -1786,7 +1786,7 @@ bridge_rtupdate(struct bridge_softc *sc, struct ether_addr *ea, bcopy(ea, &p->brt_addr, sizeof(p->brt_addr)); p->brt_if = ifp; p->brt_age = 1; - bridge_tunnelupdate(sa, + bridge_copyaddr(sa, (struct sockaddr *)&p->brt_tunnel); if (setflags) @@ -2043,12 +2043,8 @@ bridge_rtfind(struct bridge_softc *sc, struct ifbaconf *baconf) sizeof(bareq.ifba_ifsname)); bcopy(&n->brt_addr, &bareq.ifba_dst, sizeof(bareq.ifba_dst)); - if (n->brt_tunnel.sa.sa_family != AF_UNSPEC) - bcopy(&n->brt_tunnel.sa, - &bareq.ifba_dstsa, - n->brt_tunnel.sa.sa_len); - else - bareq.ifba_dstsa.ss_family = AF_UNSPEC; + bridge_copyaddr(&n->brt_tunnel.sa, + (struct sockaddr *)&bareq.ifba_dstsa); bareq.ifba_age = n->brt_age; bareq.ifba_flags = n->brt_flags; error = copyout((caddr_t)&bareq, @@ -2909,10 +2905,10 @@ bridge_tunneluntag(struct mbuf *m) } void -bridge_tunnelupdate(struct sockaddr *sa, struct sockaddr *tunnel) +bridge_copyaddr(struct sockaddr *src, struct sockaddr *dst) { - if (sa != NULL && sa->sa_family != AF_UNSPEC) - memcpy(tunnel, sa, sa->sa_len); + if (src != NULL && src->sa_family != AF_UNSPEC) + memcpy(dst, src, src->sa_len); else - tunnel->sa_family = AF_UNSPEC; + dst->sa_family = AF_UNSPEC; } diff --git a/sys/net/if_bridge.h b/sys/net/if_bridge.h index db956d960cd..6583dabf945 100644 --- a/sys/net/if_bridge.h +++ b/sys/net/if_bridge.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bridge.h,v 1.38 2013/10/13 10:10:03 reyk Exp $ */ +/* $OpenBSD: if_bridge.h,v 1.39 2013/10/13 12:09:54 reyk Exp $ */ /* * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net) @@ -407,15 +407,7 @@ struct bridge_rtnode { u_int8_t brt_flags; /* address flags */ u_int8_t brt_age; /* age counter */ struct ether_addr brt_addr; /* dst addr */ - union { - struct sockaddr sa; -#ifdef INET - struct sockaddr_in sin; -#endif -#ifdef INET6 - struct sockaddr_in6 sin6; -#endif - } brt_tunnel; /* tunnel endpoint */ + union sockaddr_union brt_tunnel; /* tunnel endpoint */ }; #ifndef BRIDGE_RTABLE_SIZE |