Enable/Disable VLAN HW filters
Subsystems (2)
RFC 1/1 Enable/Disable VLAN HW filters
We've had a few internal requests for a way to enable and disable the hardware VLAN filter at runtime. I'm posting it here for discussion and to see if anybody else is interested in this feature.
Originally I had planned to do this as an Ethtool ioctl, but decided instead to handle it through the VLAN module. Ethtool doesn't know anything about VLANs at all.
There are no userspace changes required to support this functionality.
To disable HW VLAN filtering:
# vconfig set_flag <VLAN interface> 2 1
To enable HW VLAN filtering:
# vconfig set_flag <VLAN interface> 2 0
At this point (somewhat obviously), it's only implemented on e1000, but this ioctl could be easily implemented by other drivers.
Originally based on 2.6.17 but applies OK to 2.6.18-rc4 with a little fuzz.
include/linux/if_vlan.h +15 -9
@@ -87,7 +87,20 @@ struct vlan_priority_tci_mapping {*/ struct vlan_priority_tci_mapping *next; }; - +#define VLAN_FLAG_REORDER 1/* (1 << 0) re_order_header This option will cause the +* VLAN code to move around the ethernet header on +* ingress to make the skb look **exactly** like it +* came in from an ethernet port. This destroys some of +* the VLAN information in the skb, but it fixes programs +* like DHCP that use packet-filtering and don't understand +* 802.1Q +*/ + +#define VLAN_FLAG_DISABLE_FILTER 2/* (1 << 1) disable HW filtering. This flag allows +* devices that perform hardware filtering to +* turn off filtering. This may be useful for +* debugging or for sniffer applications. +*/ /* Holds information that makes sense if this device is a VLAN device. */ struct vlan_dev_info {/** This will be the mapping that correlates skb->priority to
@@ -97,14 +110,7 @@ struct vlan_dev_info {struct vlan_priority_tci_mapping *egress_priority_map[16 ];/* hash table */ unsigned short vlan_id;/* The VLAN Identifier for this interface. */ -unsigned short flags;/* (1 << 0) re_order_header This option will cause the -* VLAN code to move around the ethernet header on -* ingress to make the skb look **exactly** like it -* came in from an ethernet port. This destroys some of -* the VLAN information in the skb, but it fixes programs -* like DHCP that use packet-filtering and don't understand -* 802.1Q -*/ +unsigned short flags;struct dev_mc_list *old_mc_list;/* old multi-cast list for the VLAN interface.. * we save this so we can tell what changes were * made, in order to feed the right changes down
include/linux/netdevice.h +3 -1
@@ -484,7 +484,9 @@ struct net_device unsigned short vid);void (*vlan_rx_kill_vid)(struct net_device *dev,unsigned short vid); - +#define HAVE_VLAN_FLAGS +int (*vlan_set_flag)(struct net_device *dev, +unsigned int flag,int value);int (*hard_header_parse)(struct sk_buff *skb,unsigned char *haddr);int (*neigh_setup)(struct net_device *dev,struct neigh_parms *);
net/8021q/vlan_dev.c +46 -25
81 lines not on this page · raw message
drivers/net/e1000/e1000_main.c +43 -0
62 lines not on this page · raw message
Quoted 10 lines · Mitch Williams
We've had a few internal requests for a way to enable and disable the hardware VLAN filter at runtime. I'm posting it here for discussion and to see if anybody else is interested in this feature.
Originally I had planned to do this as an Ethtool ioctl, but decided instead to handle it through the VLAN module. Ethtool doesn't know anything about VLANs at all.
There are no userspace changes required to support this functionality.
Quoted 8 lines
To disable HW VLAN filtering:
# vconfig set_flag <VLAN interface> 2 1To enable HW VLAN filtering:
# vconfig set_flag <VLAN interface> 2 0At this point (somewhat obviously), it's only implemented on e1000, but this ioctl could be easily implemented by other drivers.
Sounds like a good idea to me.
net/8021q/vlan_dev.c int vlan_dev_set_egress_priority(char *d · line 620
Quoted 7 lines
net/8021q/vlan_dev.c +7
-0+switch (flag) { +case VLAN_FLAG_REORDER : +if (flag_val) +VLAN_DEV_INFO (dev)->flags |=1 ; +else +VLAN_DEV_INFO (dev)->flags &= ~1 ; +break ;
If we're defining constants for the flags, might as well use them here instead of using the bare '1'.
Ben
Signature · 2 lines
Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com