diff options
author | Brad Smith <brad@cvs.openbsd.org> | 2005-04-17 23:02:03 +0000 |
---|---|---|
committer | Brad Smith <brad@cvs.openbsd.org> | 2005-04-17 23:02:03 +0000 |
commit | 7543a315d882308d72be69e1a207f521fad9bc02 (patch) | |
tree | 4d3997264ef147291be7c7cd7c005f926d5c0d4f /sys/net | |
parent | a19a369720df8c731a1ef9926bd45c36c7db8a84 (diff) |
- In vlan_input()/vlan_input_tag(), always mask off all but the VLID
bits from tags extracted from received frames. (Some drivers may
already do this masking internally, but doing it here doesn't hurt
and insures consistency.)
- In vlan_ioctl(), don't let the user set a VLAN ID value with anything
besides the VLID bits set, otherwise we will have trouble matching
an interface in vlan_input() later.
- Set the interface speed back to zero after ether_ifattach(). RFC 2863
says: "For a sub-layer which has no concept of bandwidth, [ifSpeed]
should be zero."
- Do not call if_down() on a parent interface if it's already down.
From FreeBSD
Tested by camield@ and Alexey E. Suslikov <cruel at texnika dot com dot ua>
ok camield@
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/if_vlan.c | 29 | ||||
-rw-r--r-- | sys/net/if_vlan_var.h | 5 |
2 files changed, 17 insertions, 17 deletions
diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index c0ba967e844..105f254c215 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vlan.c,v 1.48 2005/03/25 03:23:51 brad Exp $ */ +/* $OpenBSD: if_vlan.c,v 1.49 2005/04/17 23:02:02 brad Exp $ */ /* * Copyright 1998 Massachusetts Institute of Technology * @@ -88,7 +88,6 @@ LIST_HEAD(, ifvlan) *vlan_tagh; void vlan_start (struct ifnet *ifp); int vlan_ioctl (struct ifnet *ifp, u_long cmd, caddr_t addr); -int vlan_setmulti (struct ifnet *ifp); int vlan_unconfig (struct ifnet *ifp); int vlan_config (struct ifvlan *, struct ifnet *, u_int16_t); void vlanattach (int count); @@ -139,8 +138,8 @@ vlan_clone_create(struct if_clone *ifc, int unit) IFQ_SET_READY(&ifp->if_snd); if_attach(ifp); ether_ifattach(ifp); - /* Now undo some of the damage... */ + ifp->if_baudrate = 0; ifp->if_type = IFT_8021_VLAN; ifp->if_hdrlen = EVL_ENCAPLEN; @@ -403,6 +402,7 @@ vlan_config(struct ifvlan *ifv, struct ifnet *p, u_int16_t tag) return EPROTONOSUPPORT; if (ifv->ifv_p) return EBUSY; + ifv->ifv_p = p; if (p->if_capabilities & IFCAP_VLAN_MTU) @@ -430,12 +430,6 @@ vlan_config(struct ifvlan *ifv, struct ifnet *p, u_int16_t tag) ifv->ifv_if.if_type = p->if_type; /* - * Inherit baudrate from the parent. An SNMP agent would use this - * information. - */ - ifv->ifv_if.if_baudrate = p->if_baudrate; - - /* * If the parent interface can do hardware-assisted * VLAN encapsulation, then propagate its hardware- * assisted checksumming flags. @@ -609,20 +603,25 @@ vlan_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) if (vlr.vlr_parent[0] == '\0') { s = splimp(); vlan_unconfig(ifp); - if_down(ifp); - ifp->if_flags &= ~(IFF_UP|IFF_RUNNING); + if (ifp->if_flags & IFF_UP) + if_down(ifp); + ifp->if_flags &= ~IFF_RUNNING; splx(s); break; } - if (vlr.vlr_tag != EVL_VLANOFTAG(vlr.vlr_tag)) { - error = EINVAL; /* check for valid tag */ - break; - } pr = ifunit(vlr.vlr_parent); if (pr == NULL) { error = ENOENT; break; } + /* + * Don't let the caller set up a VLAN tag with + * anything except VLID bits. + */ + if (vlr.vlr_tag & ~EVL_VLID_MASK) { + error = EINVAL; + break; + } error = vlan_config(ifv, pr, vlr.vlr_tag); if (error) break; diff --git a/sys/net/if_vlan_var.h b/sys/net/if_vlan_var.h index 63ba2ff39bc..cefe543a032 100644 --- a/sys/net/if_vlan_var.h +++ b/sys/net/if_vlan_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vlan_var.h,v 1.11 2004/02/12 18:07:29 henning Exp $ */ +/* $OpenBSD: if_vlan_var.h,v 1.12 2005/04/17 23:02:02 brad Exp $ */ /* * Copyright 1998 Massachusetts Institute of Technology @@ -71,7 +71,8 @@ struct ether_vlan_header { u_int16_t evl_proto; }; -#define EVL_VLANOFTAG(tag) ((tag) & 4095) +#define EVL_VLID_MASK 0x0FFF +#define EVL_VLANOFTAG(tag) ((tag) & EVL_VLID_MASK) #define EVL_PRIOFTAG(tag) (((tag) >> 13) & 7) #define EVL_ENCAPLEN 4 /* length in octets of encapsulation */ |