* Authors: Ben Greear <greearb@candelatech.com>
* Please send support related email to: vlan@scry.wanfear.com
* VLAN Home Page: http://www.candelatech.com/~greear/vlan.html
- *
+ *
* Fixes:
* Fix for packet capture - Nick Eggleston <nick@dccinc.com>;
* Add HW acceleration hooks - David S. Miller <davem@redhat.com>;
/*
* Function vlan_proto_init (pro)
*
- * Initialize VLAN protocol layer,
+ * Initialize VLAN protocol layer,
*
*/
static int __init vlan_proto_init(void)
/* proc file system initialization */
err = vlan_proc_init();
if (err < 0) {
- printk(KERN_ERR
+ printk(KERN_ERR
"%s %s: can't create entry in proc filesystem!\n",
__FUNCTION__, VLAN_NAME);
return err;
return 0;
}
-/* Cleanup all vlan devices
+/* Cleanup all vlan devices
* Note: devices that have been registered that but not
* brought up will exist but have no module ref count.
*/
/*
* Module 'remove' entry point.
* o delete /proc/net/router directory and static entries.
- */
+ */
static void __exit vlan_cleanup_module(void)
{
int i;
struct vlan_group *grp = __vlan_find_group(real_dev->ifindex);
if (grp)
- return grp->vlan_devices[VID];
+ return grp->vlan_devices[VID];
return NULL;
}
}
}
- return ret;
+ return ret;
}
static int unregister_vlan_device(const char *vlan_IF_name)
if (ret == 1)
ret = 0;
} else {
- printk(VLAN_ERR
+ printk(VLAN_ERR
"%s: ERROR: Tried to remove a non-vlan device "
"with VLAN code, name: %s priv_flags: %hX\n",
__FUNCTION__, dev->name, dev->priv_flags);
static void vlan_setup(struct net_device *new_dev)
{
SET_MODULE_OWNER(new_dev);
-
+
/* new_dev->ifindex = 0; it will be set when added to
* the global list.
* iflink is set as well.
/* Make this thing known as a VLAN device */
new_dev->priv_flags |= IFF_802_1Q_VLAN;
-
+
/* Set us up to have no queue, as the underlying Hardware device
* can do all the queueing we could want.
*/
default:
snprintf(name, IFNAMSIZ, "vlan%.4i", VLAN_ID);
};
-
+
new_dev = alloc_netdev(sizeof(struct vlan_dev_info), name,
vlan_setup);
new_dev->state = (real_dev->state & ((1<<__LINK_STATE_NOCARRIER) |
(1<<__LINK_STATE_DORMANT))) |
- (1<<__LINK_STATE_PRESENT);
+ (1<<__LINK_STATE_PRESENT);
/* need 4 bytes for extra VLAN header info,
* hope the underlying device can handle it.
VLAN_MEM_DBG("new_dev->priv malloc, addr: %p size: %i\n",
new_dev->priv,
sizeof(struct vlan_dev_info));
-
+
memcpy(new_dev->broadcast, real_dev->broadcast, real_dev->addr_len);
memcpy(new_dev->dev_addr, real_dev->dev_addr, real_dev->addr_len);
new_dev->addr_len = real_dev->addr_len;
printk(VLAN_DBG "About to go find the group for idx: %i\n",
real_dev->ifindex);
#endif
-
+
if (register_netdevice(new_dev))
goto out_free_newdev;
grp = kzalloc(sizeof(struct vlan_group), GFP_KERNEL);
if (!grp)
goto out_free_unregister;
-
+
/* printk(KERN_ALERT "VLAN REGISTER: Allocated new group.\n"); */
grp->real_dev_ifindex = real_dev->ifindex;
- hlist_add_head_rcu(&grp->hlist,
+ hlist_add_head_rcu(&grp->hlist,
&vlan_group_hash[vlan_grp_hashfn(real_dev->ifindex)]);
if (real_dev->features & NETIF_F_HW_VLAN_RX)
real_dev->vlan_rx_register(real_dev, grp);
}
-
+
grp->vlan_devices[VLAN_ID] = new_dev;
if (vlan_proc_add_dev(new_dev)<0)/* create it's proc entry */
- printk(KERN_WARNING "VLAN: failed to add proc entry for %s\n",
- new_dev->name);
+ printk(KERN_WARNING "VLAN: failed to add proc entry for %s\n",
+ new_dev->name);
if (real_dev->features & NETIF_F_HW_VLAN_FILTER)
real_dev->vlan_rx_add_vid(real_dev, VLAN_ID);
vlandev = grp->vlan_devices[i];
if (!vlandev)
continue;
-
+
flgs = vlandev->flags;
if (flgs & IFF_UP)
continue;
dev_change_flags(vlandev, flgs | IFF_UP);
}
break;
-
+
case NETDEV_UNREGISTER:
/* Delete all VLANs for this dev. */
for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
/* TODO: Implement
err = vlan_dev_get_ingress_priority(args);
if (copy_to_user((void*)arg, &args,
- sizeof(struct vlan_ioctl_args))) {
- err = -EFAULT;
+ sizeof(struct vlan_ioctl_args))) {
+ err = -EFAULT;
}
*/
err = -EINVAL;
/* TODO: Implement
err = vlan_dev_get_egress_priority(args.device1, &(args.args);
if (copy_to_user((void*)arg, &args,
- sizeof(struct vlan_ioctl_args))) {
- err = -EFAULT;
+ sizeof(struct vlan_ioctl_args))) {
+ err = -EFAULT;
}
*/
err = -EINVAL;
args.u.VID = vid;
if (copy_to_user(arg, &args,
sizeof(struct vlan_ioctl_args))) {
- err = -EFAULT;
+ err = -EFAULT;
}
break;
#define VLAN_ERR KERN_ERR
#define VLAN_INF KERN_INFO
#define VLAN_DBG KERN_ALERT /* change these... to debug, having a hard time
- * changing the log level at run-time..for some reason.
- */
+ * changing the log level at run-time..for some reason.
+ */
/*
*/
/* This way they don't do anything! */
-#define VLAN_MEM_DBG(x, y, z)
+#define VLAN_MEM_DBG(x, y, z)
#define VLAN_FMEM_DBG(x, y)
/* found in vlan_dev.c */
int vlan_dev_rebuild_header(struct sk_buff *skb);
int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
- struct packet_type *ptype, struct net_device *orig_dev);
+ struct packet_type *ptype, struct net_device *orig_dev);
int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
- unsigned short type, void *daddr, void *saddr,
- unsigned len);
+ unsigned short type, void *daddr, void *saddr,
+ unsigned len);
int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev);
int vlan_dev_hwaccel_hard_start_xmit(struct sk_buff *skb, struct net_device *dev);
int vlan_dev_change_mtu(struct net_device *dev, int new_mtu);
* Authors: Ben Greear <greearb@candelatech.com>
* Please send support related email to: vlan@scry.wanfear.com
* VLAN Home Page: http://www.candelatech.com/~greear/vlan.html
- *
+ *
* Fixes: Mar 22 2001: Martin Bokaemper <mbokaemper@unispherenetworks.com>
* - reset skb->pkt_type on incoming packets when MAC was changed
* - see that changed MAC is saddr for outgoing packets
* Oct 20, 2001: Ard van Breeman:
* - Fix MC-list, finally.
* - Flush MC-list on VLAN destroy.
- *
+ *
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
/* TODO: Confirm this will work with VLAN headers... */
return arp_find(veth->h_dest, skb);
-#endif
+#endif
default:
printk(VLAN_DBG
- "%s: unable to resolve type %X addresses.\n",
+ "%s: unable to resolve type %X addresses.\n",
dev->name, ntohs(veth->h_vlan_encapsulated_proto));
-
+
memcpy(veth->h_source, dev->dev_addr, ETH_ALEN);
break;
};
}
/*
- * Determine the packet's protocol ID. The rule here is that we
+ * Determine the packet's protocol ID. The rule here is that we
* assume 802.3 if the type field is short enough to be a length.
* This is normal practice and works for any 'now in use' protocol.
*
*
*/
int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
- struct packet_type* ptype, struct net_device *orig_dev)
+ struct packet_type* ptype, struct net_device *orig_dev)
{
unsigned char *rawp = NULL;
struct vlan_hdr *vhdr = (struct vlan_hdr *)(skb->data);
#ifdef VLAN_DEBUG
printk(VLAN_DBG "%s: dropping skb: %p because came in on wrong device, dev: %s real_dev: %s, skb_dev: %s\n",
- __FUNCTION__, skb, dev->name,
- VLAN_DEV_INFO(skb->dev)->real_dev->name,
+ __FUNCTION__, skb, dev->name,
+ VLAN_DEV_INFO(skb->dev)->real_dev->name,
skb->dev->name);
#endif
kfree_skb(skb);
#ifdef VLAN_DEBUG
printk(VLAN_DBG "%s: priority: %lu for TCI: %hu (hbo)\n",
- __FUNCTION__, (unsigned long)(skb->priority),
+ __FUNCTION__, (unsigned long)(skb->priority),
ntohs(vhdr->h_vlan_TCI));
#endif
stats->multicast++;
break;
- case PACKET_OTHERHOST:
+ case PACKET_OTHERHOST:
/* Our lower layer thinks this is not local, let's make sure.
* This allows the VLAN to have a different MAC than the underlying
* device, and still route correctly.
}
/*
- * Create the VLAN header for an arbitrary protocol layer
+ * Create the VLAN header for an arbitrary protocol layer
*
* saddr=NULL means use device source address
* daddr=NULL means leave destination address (eg unresolved arp)
* physical devices.
*/
int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
- unsigned short type, void *daddr, void *saddr,
- unsigned len)
+ unsigned short type, void *daddr, void *saddr,
+ unsigned len)
{
struct vlan_hdr *vhdr;
unsigned short veth_TCI = 0;
* fixes some programs that get confused when they see a VLAN device
* sending a frame that is VLAN encoded (the consensus is that the VLAN
* device should look completely like an Ethernet device when the
- * REORDER_HEADER flag is set) The drawback to this is some extra
+ * REORDER_HEADER flag is set) The drawback to this is some extra
* header shuffling in the hard_start_xmit. Users can turn off this
* REORDER behaviour with the vconfig tool.
*/
struct net_device *dev = dev_get_by_name(dev_name);
struct vlan_priority_tci_mapping *mp = NULL;
struct vlan_priority_tci_mapping *np;
-
+
if (dev) {
if (dev->priv_flags & IFF_802_1Q_VLAN) {
/* See if a priority mapping exists.. */
return -EINVAL;
}
} else {
- printk(KERN_ERR
+ printk(KERN_ERR
"%s: %s is not a vlan device, priv_flags: %hX.\n",
__FUNCTION__, dev->name, dev->priv_flags);
dev_put(dev);
}
} else {
- printk(KERN_ERR "%s: Could not find device: %s\n",
+ printk(KERN_ERR "%s: Could not find device: %s\n",
__FUNCTION__, dev_name);
}
}
static inline int vlan_dmi_equals(struct dev_mc_list *dmi1,
- struct dev_mc_list *dmi2)
+ struct dev_mc_list *dmi2)
{
return ((dmi1->dmi_addrlen == dmi2->dmi_addrlen) &&
(memcmp(dmi1->dmi_addr, dmi2->dmi_addr, dmi1->dmi_addrlen) == 0));
case SIOCGMIIPHY:
case SIOCGMIIREG:
case SIOCSMIIREG:
- if (real_dev->do_ioctl && netif_device_present(real_dev))
+ if (real_dev->do_ioctl && netif_device_present(real_dev))
err = real_dev->do_ioctl(real_dev, &ifrr, cmd);
break;
err = dev_ethtool(&ifrr);
}
- if (!err)
+ if (!err)
ifr->ifr_ifru = ifrr.ifr_ifru;
return err;
/*
- * Names of the proc directory entries
+ * Names of the proc directory entries
*/
static const char name_root[] = "vlan";
*/
/*
- * Generic /proc/net/vlan/<file> file and inode operations
+ * Generic /proc/net/vlan/<file> file and inode operations
*/
static struct seq_operations vlan_seq_ops = {
*/
/*
- * /proc/net/vlan
+ * /proc/net/vlan
*/
static struct proc_dir_entry *proc_vlan_dir;
/*
- * /proc/net/vlan/config
+ * /proc/net/vlan/config
*/
static struct proc_dir_entry *proc_vlan_conf;
*/
/* starting at dev, find a VLAN device */
-static struct net_device *vlan_skip(struct net_device *dev)
+static struct net_device *vlan_skip(struct net_device *dev)
{
- while (dev && !(dev->priv_flags & IFF_802_1Q_VLAN))
+ while (dev && !(dev->priv_flags & IFF_802_1Q_VLAN))
dev = dev->next;
return dev;
}
-/* start read of /proc/net/vlan/config */
+/* start read of /proc/net/vlan/config */
static void *vlan_seq_start(struct seq_file *seq, loff_t *pos)
{
struct net_device *dev;
if (*pos == 0)
return SEQ_START_TOKEN;
-
- for (dev = vlan_skip(dev_base); dev && i < *pos;
+
+ for (dev = vlan_skip(dev_base); dev && i < *pos;
dev = vlan_skip(dev->next), ++i);
-
+
return (i == *pos) ? dev : NULL;
-}
+}
static void *vlan_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{
++*pos;
- return vlan_skip((v == SEQ_START_TOKEN)
- ? dev_base
+ return vlan_skip((v == SEQ_START_TOKEN)
+ ? dev_base
: ((struct net_device *)v)->next);
}
if (vlan_name_type < ARRAY_SIZE(vlan_name_type_str))
nmtype = vlan_name_type_str[vlan_name_type];
- seq_printf(seq, "Name-Type: %s\n",
+ seq_printf(seq, "Name-Type: %s\n",
nmtype ? nmtype : "UNKNOWN" );
} else {
const struct net_device *vlandev = v;
const struct vlan_dev_info *dev_info = VLAN_DEV_INFO(vlandev);
- seq_printf(seq, "%-15s| %d | %s\n", vlandev->name,
+ seq_printf(seq, "%-15s| %d | %s\n", vlandev->name,
dev_info->vlan_id, dev_info->real_dev->name);
}
return 0;
seq_puts(seq, "\n");
seq_printf(seq, fmt, "total frames transmitted", stats->tx_packets);
seq_printf(seq, fmt, "total bytes transmitted", stats->tx_bytes);
- seq_printf(seq, fmt, "total headroom inc",
+ seq_printf(seq, fmt, "total headroom inc",
dev_info->cnt_inc_headroom_on_tx);
- seq_printf(seq, fmt, "total encap on xmit",
+ seq_printf(seq, fmt, "total encap on xmit",
dev_info->cnt_encap_on_xmit);
seq_printf(seq, "Device: %s", dev_info->real_dev->name);
/* now show all PRIORITY mappings relating to this VLAN */
- seq_printf(seq,
+ seq_printf(seq,
"\nINGRESS priority mappings: 0:%lu 1:%lu 2:%lu 3:%lu 4:%lu 5:%lu 6:%lu 7:%lu\n",
dev_info->ingress_priority_map[0],
dev_info->ingress_priority_map[1],