This is a discussion on Works for me; was: [PATCH] VLAN users within the mailing.openbsd.tech forums, part of the OpenBSD category; --> works for me on box running -current from 20050417 with carp-interfaces built against vlan-interfaces built against trunk on em-interface. ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| works for me on box running -current from 20050417 with carp-interfaces built against vlan-interfaces built against trunk on em-interface. > If you use VLANs under OpenBSD then please try out this diff > and let me know how goes. > > - 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 of bandwidth, [ifSpeed] > should be zero." > - Do not call if_down() on a parent interface if it's already down. > > From FreeBSD > > Index: if_vlan.c > ================================================== ================= > RCS file: /cvs/src/sys/net/if_vlan.c,v > retrieving revision 1.48 > diff -u -p -r1.48 if_vlan.c > --- if_vlan.c 25 Mar 2005 03:23:51 -0000 1.48 > +++ if_vlan.c 12 Apr 2005 01:12:43 -0000 > @@ -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, > 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 i > 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 i > 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. > @@ -465,7 +459,6 @@ vlan_config(struct ifvlan *ifv, struct i > bcopy(LLADDR(sdl2), LLADDR(sdl1), ETHER_ADDR_LEN); > bcopy(LLADDR(sdl2), ifv->ifv_ac.ac_enaddr, ETHER_ADDR_LEN); > > - ifv->ifv_tag = tag; > s = splnet(); > LIST_INSERT_HEAD(&vlan_tagh[TAG_HASH(tag)], ifv, ifv_list); > splx(s); > @@ -609,23 +602,29 @@ vlan_ioctl(struct ifnet *ifp, u_long cmd > 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; > + ifv->ifv_tag = vlr.vlr_tag; > ifp->if_flags |= IFF_RUNNING; > > /* Update promiscuous mode, if necessary. */ > Index: if_vlan_var.h > ================================================== ================= > RCS file: /cvs/src/sys/net/if_vlan_var.h,v > retrieving revision 1.11 > diff -u -p -r1.11 if_vlan_var.h > --- if_vlan_var.h 12 Feb 2004 18:07:29 -0000 1.11 > +++ if_vlan_var.h 12 Apr 2005 01:12:43 -0000 > @@ -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 */ |