* [VLAN 09/18]: Remove non-implemented ioctls
From: Patrick McHardy @ 2008-01-20 17:11 UTC (permalink / raw)
To: davem; +Cc: netdev, Patrick McHardy
In-Reply-To: <20080120171117.7980.67072.sendpatchset@localhost.localdomain>
[VLAN]: Remove non-implemented ioctls
The GET_VLAN_INGRESS_PRIORITY_CMD/GET_VLAN_EGRESS_PRIORITY_CMD ioctls are
not implemented and won't be, new functionality will be added to the netlink
interface. Remove the code and make the ioctl handler return -EOPNOTSUPP
for unknown commands instead of -EINVAL.
Also remove a comment about passing unknown commands to the underlying
device, that doesn't make any sense since its a VLAN specific ioctl and
if its not implemented here, its implemented nowhere.
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit 8798cc926478d29231ad48d5e0ff31e434660ddb
tree bd5a582834f284db01ad92e19153ad307a425510
parent 7d925b47858e2f18fd474c673a0a75a0cfd00ebf
author Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 17:37:31 +0100
committer Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 17:37:31 +0100
net/8021q/vlan.c | 23 +----------------------
1 files changed, 1 insertions(+), 22 deletions(-)
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 6edd191..69a9e02 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -688,26 +688,6 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
err = unregister_vlan_device(dev);
break;
- case GET_VLAN_INGRESS_PRIORITY_CMD:
- /* TODO: Implement
- err = vlan_dev_get_ingress_priority(args);
- if (copy_to_user((void*)arg, &args,
- sizeof(struct vlan_ioctl_args))) {
- err = -EFAULT;
- }
- */
- err = -EINVAL;
- break;
- case GET_VLAN_EGRESS_PRIORITY_CMD:
- /* 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;
- }
- */
- err = -EINVAL;
- break;
case GET_VLAN_REALDEV_NAME_CMD:
err = 0;
vlan_dev_get_realdev_name(dev, args.u.device2);
@@ -728,8 +708,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
break;
default:
- /* pass on to underlying device instead?? */
- err = -EINVAL;
+ err = -EOPNOTSUPP;
break;
}
out:
^ permalink raw reply related
* [VLAN 10/18]: Clean up initialization code
From: Patrick McHardy @ 2008-01-20 17:11 UTC (permalink / raw)
To: davem; +Cc: netdev, Patrick McHardy
In-Reply-To: <20080120171117.7980.67072.sendpatchset@localhost.localdomain>
[VLAN]: Clean up initialization code
- move module init/exit functions to end of file, remove some now unnecessary
forward declarations
- remove some obvious comments
- clean up proc init function and move a proc-related printk there
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit 9829059db87d43bb24e82683e6bb4ed4a655fc39
tree d4a062fb2a45e299eae6ac7aa1de6e3e05e9ad31
parent 8798cc926478d29231ad48d5e0ff31e434660ddb
author Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 17:37:31 +0100
committer Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 17:37:31 +0100
net/8021q/vlan.c | 141 +++++++++++++++++++++-----------------------------
net/8021q/vlanproc.c | 21 ++++---
2 files changed, 70 insertions(+), 92 deletions(-)
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 69a9e02..006d9a9 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -50,16 +50,6 @@ static char vlan_version[] = DRV_VERSION;
static char vlan_copyright[] = "Ben Greear <greearb@candelatech.com>";
static char vlan_buggyright[] = "David S. Miller <davem@redhat.com>";
-static int vlan_device_event(struct notifier_block *, unsigned long, void *);
-static int vlan_ioctl_handler(struct net *net, void __user *);
-static int unregister_vlan_dev(struct net_device *, unsigned short );
-
-static struct notifier_block vlan_notifier_block = {
- .notifier_call = vlan_device_event,
-};
-
-/* These may be changed at run-time through IOCTLs */
-
/* Determines interface naming scheme. */
unsigned short vlan_name_type = VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD;
@@ -70,79 +60,6 @@ static struct packet_type vlan_packet_type = {
/* End of global variables definitions. */
-/*
- * Function vlan_proto_init (pro)
- *
- * Initialize VLAN protocol layer,
- *
- */
-static int __init vlan_proto_init(void)
-{
- int err;
-
- pr_info("%s v%s %s\n", vlan_fullname, vlan_version, vlan_copyright);
- pr_info("All bugs added by %s\n", vlan_buggyright);
-
- /* proc file system initialization */
- err = vlan_proc_init();
- if (err < 0) {
- pr_err("%s: can't create entry in proc filesystem!\n",
- __FUNCTION__);
- return err;
- }
-
- dev_add_pack(&vlan_packet_type);
-
- /* Register us to receive netdevice events */
- err = register_netdevice_notifier(&vlan_notifier_block);
- if (err < 0)
- goto err1;
-
- err = vlan_netlink_init();
- if (err < 0)
- goto err2;
-
- vlan_ioctl_set(vlan_ioctl_handler);
- return 0;
-
-err2:
- unregister_netdevice_notifier(&vlan_notifier_block);
-err1:
- vlan_proc_cleanup();
- dev_remove_pack(&vlan_packet_type);
- return err;
-}
-
-/*
- * Module 'remove' entry point.
- * o delete /proc/net/router directory and static entries.
- */
-static void __exit vlan_cleanup_module(void)
-{
- int i;
-
- vlan_ioctl_set(NULL);
- vlan_netlink_fini();
-
- /* Un-register us from receiving netdevice events */
- unregister_netdevice_notifier(&vlan_notifier_block);
-
- dev_remove_pack(&vlan_packet_type);
-
- /* This table must be empty if there are no module
- * references left.
- */
- for (i = 0; i < VLAN_GRP_HASH_SIZE; i++) {
- BUG_ON(!hlist_empty(&vlan_group_hash[i]));
- }
- vlan_proc_cleanup();
-
- synchronize_net();
-}
-
-module_init(vlan_proto_init);
-module_exit(vlan_cleanup_module);
-
/* Must be invoked with RCU read lock (no preempt) */
static struct vlan_group *__vlan_find_group(int real_dev_ifindex)
{
@@ -592,6 +509,10 @@ out:
return NOTIFY_DONE;
}
+static struct notifier_block vlan_notifier_block __read_mostly = {
+ .notifier_call = vlan_device_event,
+};
+
/*
* VLAN IOCTL handler.
* o execute requested action or pass command to the device driver
@@ -716,5 +637,59 @@ out:
return err;
}
+static int __init vlan_proto_init(void)
+{
+ int err;
+
+ pr_info("%s v%s %s\n", vlan_fullname, vlan_version, vlan_copyright);
+ pr_info("All bugs added by %s\n", vlan_buggyright);
+
+ err = vlan_proc_init();
+ if (err < 0)
+ goto err1;
+
+ err = register_netdevice_notifier(&vlan_notifier_block);
+ if (err < 0)
+ goto err2;
+
+ err = vlan_netlink_init();
+ if (err < 0)
+ goto err3;
+
+ dev_add_pack(&vlan_packet_type);
+ vlan_ioctl_set(vlan_ioctl_handler);
+ return 0;
+
+err3:
+ unregister_netdevice_notifier(&vlan_notifier_block);
+err2:
+ vlan_proc_cleanup();
+err1:
+ return err;
+}
+
+static void __exit vlan_cleanup_module(void)
+{
+ unsigned int i;
+
+ vlan_ioctl_set(NULL);
+ vlan_netlink_fini();
+
+ unregister_netdevice_notifier(&vlan_notifier_block);
+
+ dev_remove_pack(&vlan_packet_type);
+
+ /* This table must be empty if there are no module references left. */
+ for (i = 0; i < VLAN_GRP_HASH_SIZE; i++)
+ BUG_ON(!hlist_empty(&vlan_group_hash[i]));
+
+ vlan_proc_cleanup();
+
+ synchronize_net();
+}
+
+module_init(vlan_proto_init);
+module_exit(vlan_cleanup_module);
+
MODULE_LICENSE("GPL");
MODULE_VERSION(DRV_VERSION);
diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c
index 5da02e2..971e623 100644
--- a/net/8021q/vlanproc.c
+++ b/net/8021q/vlanproc.c
@@ -158,15 +158,18 @@ void vlan_proc_cleanup(void)
int __init vlan_proc_init(void)
{
proc_vlan_dir = proc_mkdir(name_root, init_net.proc_net);
- if (proc_vlan_dir) {
- proc_vlan_conf = create_proc_entry(name_conf,
- S_IFREG|S_IRUSR|S_IWUSR,
- proc_vlan_dir);
- if (proc_vlan_conf) {
- proc_vlan_conf->proc_fops = &vlan_fops;
- return 0;
- }
- }
+ if (!proc_vlan_dir)
+ goto err;
+
+ proc_vlan_conf = create_proc_entry(name_conf, S_IFREG|S_IRUSR|S_IWUSR,
+ proc_vlan_dir);
+ if (!proc_vlan_conf)
+ goto err;
+ proc_vlan_conf->proc_fops = &vlan_fops;
+ return 0;
+
+err:
+ pr_err("%s: can't create entry in proc filesystem!\n", __FUNCTION__);
vlan_proc_cleanup();
return -ENOBUFS;
}
^ permalink raw reply related
* [VLAN 11/18]: Clean up unregister_vlan_dev
From: Patrick McHardy @ 2008-01-20 17:11 UTC (permalink / raw)
To: davem; +Cc: netdev, Patrick McHardy
In-Reply-To: <20080120171117.7980.67072.sendpatchset@localhost.localdomain>
[VLAN]: Clean up unregister_vlan_dev
Save two levels of indentation by aborting on error conditions,
remove unnecessary initialization to NULL and remove two obvious
comments.
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit 9f39c0253f370dae13a81cda9cf119052bb11750
tree d27c1417f8f19e0aff3833b6a631453c509c787e
parent 9829059db87d43bb24e82683e6bb4ed4a655fc39
author Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 17:37:31 +0100
committer Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 17:37:31 +0100
net/8021q/vlan.c | 72 ++++++++++++++++++++++++------------------------------
1 files changed, 32 insertions(+), 40 deletions(-)
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 006d9a9..ad34e4a 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -142,63 +142,55 @@ static void vlan_rcu_free(struct rcu_head *rcu)
static int unregister_vlan_dev(struct net_device *real_dev,
unsigned short vlan_id)
{
- struct net_device *dev = NULL;
+ struct net_device *dev;
int real_dev_ifindex = real_dev->ifindex;
struct vlan_group *grp;
- int i, ret;
+ unsigned int i;
+ int ret;
- /* sanity check */
if (vlan_id >= VLAN_VID_MASK)
return -EINVAL;
ASSERT_RTNL();
grp = __vlan_find_group(real_dev_ifindex);
+ if (!grp)
+ return -ENOENT;
- ret = 0;
-
- if (grp) {
- dev = vlan_group_get_device(grp, vlan_id);
- if (dev) {
- /* Remove proc entry */
- vlan_proc_rem_dev(dev);
-
- /* Take it out of our own structures, but be sure to
- * interlock with HW accelerating devices or SW vlan
- * input packet processing.
- */
- if (real_dev->features & NETIF_F_HW_VLAN_FILTER)
- real_dev->vlan_rx_kill_vid(real_dev, vlan_id);
+ dev = vlan_group_get_device(grp, vlan_id);
+ if (!dev)
+ return -ENOENT;
- vlan_group_set_device(grp, vlan_id, NULL);
- synchronize_net();
+ vlan_proc_rem_dev(dev);
+ /* Take it out of our own structures, but be sure to interlock with
+ * HW accelerating devices or SW vlan input packet processing.
+ */
+ if (real_dev->features & NETIF_F_HW_VLAN_FILTER)
+ real_dev->vlan_rx_kill_vid(real_dev, vlan_id);
- /* Caller unregisters (and if necessary, puts)
- * VLAN device, but we get rid of the reference to
- * real_dev here.
- */
- dev_put(real_dev);
+ vlan_group_set_device(grp, vlan_id, NULL);
+ synchronize_net();
- /* If the group is now empty, kill off the
- * group.
- */
- for (i = 0; i < VLAN_VID_MASK; i++)
- if (vlan_group_get_device(grp, i))
- break;
+ /* Caller unregisters (and if necessary, puts) VLAN device, but we
+ * get rid of the reference to real_dev here.
+ */
+ dev_put(real_dev);
- if (i == VLAN_VID_MASK) {
- if (real_dev->features & NETIF_F_HW_VLAN_RX)
- real_dev->vlan_rx_register(real_dev, NULL);
+ /* If the group is now empty, kill off the group. */
+ ret = 0;
+ for (i = 0; i < VLAN_VID_MASK; i++)
+ if (vlan_group_get_device(grp, i))
+ break;
- hlist_del_rcu(&grp->hlist);
+ if (i == VLAN_VID_MASK) {
+ if (real_dev->features & NETIF_F_HW_VLAN_RX)
+ real_dev->vlan_rx_register(real_dev, NULL);
- /* Free the group, after all cpu's are done. */
- call_rcu(&grp->rcu, vlan_rcu_free);
+ hlist_del_rcu(&grp->hlist);
- grp = NULL;
- ret = 1;
- }
- }
+ /* Free the group, after all cpu's are done. */
+ call_rcu(&grp->rcu, vlan_rcu_free);
+ ret = 1;
}
return ret;
^ permalink raw reply related
* [VLAN 12/18]: Simplify vlan unregistration
From: Patrick McHardy @ 2008-01-20 17:11 UTC (permalink / raw)
To: davem; +Cc: netdev, Patrick McHardy
In-Reply-To: <20080120171117.7980.67072.sendpatchset@localhost.localdomain>
[VLAN]: Simplify vlan unregistration
Keep track of the number of VLAN devices in a vlan group. This allows
to have the caller sense when the group is going to be destroyed and
stop using it, which in turn allows to remove the wrapper around
unregister_vlan_dev for the NETDEV_UNREGISTER notifier and avoid
iterating over all possible VLAN ids whenever a device in unregistered.
Also fix what looks like a use-after-free (but is actually safe since
we're holding the RTNL), the real_dev reference should not be dropped
while we still use it.
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit cd41c792d7df5107c05f2529426ae68f817e38f6
tree 469a2f8242654a34329d4b51e66e27f200ec314f
parent 9f39c0253f370dae13a81cda9cf119052bb11750
author Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 17:37:31 +0100
committer Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 17:37:31 +0100
include/linux/if_vlan.h | 1 +
net/8021q/vlan.c | 76 ++++++++++++----------------------------------
net/8021q/vlan.h | 2 +
net/8021q/vlan_netlink.c | 7 +---
4 files changed, 23 insertions(+), 63 deletions(-)
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 07db416..129fa87 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -82,6 +82,7 @@ extern void vlan_ioctl_set(int (*hook)(struct net *, void __user *));
struct vlan_group {
int real_dev_ifindex; /* The ifindex of the ethernet(like) device the vlan is attached to. */
+ unsigned int nr_vlans;
struct hlist_node hlist; /* linked list */
struct net_device **vlan_devices_arrays[VLAN_GROUP_ARRAY_SPLIT_PARTS];
struct rcu_head rcu;
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index ad34e4a..ac79638 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -132,33 +132,17 @@ static void vlan_rcu_free(struct rcu_head *rcu)
vlan_group_free(container_of(rcu, struct vlan_group, rcu));
}
-
-/* This returns 0 if everything went fine.
- * It will return 1 if the group was killed as a result.
- * A negative return indicates failure.
- *
- * The RTNL lock must be held.
- */
-static int unregister_vlan_dev(struct net_device *real_dev,
- unsigned short vlan_id)
+void unregister_vlan_dev(struct net_device *dev)
{
- struct net_device *dev;
- int real_dev_ifindex = real_dev->ifindex;
+ struct vlan_dev_info *vlan = VLAN_DEV_INFO(dev);
+ struct net_device *real_dev = vlan->real_dev;
struct vlan_group *grp;
- unsigned int i;
- int ret;
-
- if (vlan_id >= VLAN_VID_MASK)
- return -EINVAL;
+ unsigned short vlan_id = vlan->vlan_id;
ASSERT_RTNL();
- grp = __vlan_find_group(real_dev_ifindex);
- if (!grp)
- return -ENOENT;
- dev = vlan_group_get_device(grp, vlan_id);
- if (!dev)
- return -ENOENT;
+ grp = __vlan_find_group(real_dev->ifindex);
+ BUG_ON(!grp);
vlan_proc_rem_dev(dev);
@@ -169,20 +153,12 @@ static int unregister_vlan_dev(struct net_device *real_dev,
real_dev->vlan_rx_kill_vid(real_dev, vlan_id);
vlan_group_set_device(grp, vlan_id, NULL);
- synchronize_net();
+ grp->nr_vlans--;
- /* Caller unregisters (and if necessary, puts) VLAN device, but we
- * get rid of the reference to real_dev here.
- */
- dev_put(real_dev);
+ synchronize_net();
/* If the group is now empty, kill off the group. */
- ret = 0;
- for (i = 0; i < VLAN_VID_MASK; i++)
- if (vlan_group_get_device(grp, i))
- break;
-
- if (i == VLAN_VID_MASK) {
+ if (grp->nr_vlans == 0) {
if (real_dev->features & NETIF_F_HW_VLAN_RX)
real_dev->vlan_rx_register(real_dev, NULL);
@@ -190,23 +166,12 @@ static int unregister_vlan_dev(struct net_device *real_dev,
/* Free the group, after all cpu's are done. */
call_rcu(&grp->rcu, vlan_rcu_free);
- ret = 1;
}
- return ret;
-}
-
-int unregister_vlan_device(struct net_device *dev)
-{
- int ret;
+ /* Get rid of the vlan's reference to real_dev */
+ dev_put(real_dev);
- ret = unregister_vlan_dev(VLAN_DEV_INFO(dev)->real_dev,
- VLAN_DEV_INFO(dev)->vlan_id);
unregister_netdevice(dev);
-
- if (ret == 1)
- ret = 0;
- return ret;
}
static void vlan_transfer_operstate(const struct net_device *dev, struct net_device *vlandev)
@@ -291,6 +256,8 @@ int register_vlan_dev(struct net_device *dev)
* it into our local structure.
*/
vlan_group_set_device(grp, vlan_id, dev);
+ grp->nr_vlans++;
+
if (ngrp && real_dev->features & NETIF_F_HW_VLAN_RX)
real_dev->vlan_rx_register(real_dev, ngrp);
if (real_dev->features & NETIF_F_HW_VLAN_FILTER)
@@ -479,20 +446,16 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
case NETDEV_UNREGISTER:
/* Delete all VLANs for this dev. */
for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
- int ret;
-
vlandev = vlan_group_get_device(grp, i);
if (!vlandev)
continue;
- ret = unregister_vlan_dev(dev,
- VLAN_DEV_INFO(vlandev)->vlan_id);
-
- unregister_netdevice(vlandev);
+ /* unregistration of last vlan destroys group, abort
+ * afterwards */
+ if (grp->nr_vlans == 1)
+ i = VLAN_GROUP_ARRAY_LEN;
- /* Group was destroyed? */
- if (ret == 1)
- break;
+ unregister_vlan_dev(vlandev);
}
break;
}
@@ -598,7 +561,8 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
err = -EPERM;
if (!capable(CAP_NET_ADMIN))
break;
- err = unregister_vlan_device(dev);
+ unregister_vlan_dev(dev);
+ err = 0;
break;
case GET_VLAN_REALDEV_NAME_CMD:
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
index 5637865..0cfdf77 100644
--- a/net/8021q/vlan.h
+++ b/net/8021q/vlan.h
@@ -38,7 +38,7 @@ void vlan_dev_get_vid(const struct net_device *dev, unsigned short *result);
int vlan_check_real_dev(struct net_device *real_dev, unsigned short vlan_id);
void vlan_setup(struct net_device *dev);
int register_vlan_dev(struct net_device *dev);
-int unregister_vlan_device(struct net_device *dev);
+void unregister_vlan_dev(struct net_device *dev);
int vlan_netlink_init(void);
void vlan_netlink_fini(void);
diff --git a/net/8021q/vlan_netlink.c b/net/8021q/vlan_netlink.c
index 0996185..9ee6358 100644
--- a/net/8021q/vlan_netlink.c
+++ b/net/8021q/vlan_netlink.c
@@ -137,11 +137,6 @@ static int vlan_newlink(struct net_device *dev,
return register_vlan_dev(dev);
}
-static void vlan_dellink(struct net_device *dev)
-{
- unregister_vlan_device(dev);
-}
-
static inline size_t vlan_qos_map_size(unsigned int n)
{
if (n == 0)
@@ -226,7 +221,7 @@ struct rtnl_link_ops vlan_link_ops __read_mostly = {
.validate = vlan_validate,
.newlink = vlan_newlink,
.changelink = vlan_changelink,
- .dellink = vlan_dellink,
+ .dellink = unregister_vlan_dev,
.get_size = vlan_get_size,
.fill_info = vlan_fill_info,
};
^ permalink raw reply related
* [VLAN 13/18]: Turn VLAN_DEV_INFO into inline function
From: Patrick McHardy @ 2008-01-20 17:11 UTC (permalink / raw)
To: davem; +Cc: netdev, Patrick McHardy
In-Reply-To: <20080120171117.7980.67072.sendpatchset@localhost.localdomain>
[VLAN]: Turn VLAN_DEV_INFO into inline function
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit 84ea6a8ff0745f63e25d2d17664fd8c56448f985
tree de3ead8eda857231834d77e151be7ebc60ed3b5f
parent cd41c792d7df5107c05f2529426ae68f817e38f6
author Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 17:37:31 +0100
committer Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 17:37:31 +0100
drivers/net/cxgb3/l2t.c | 2 +-
drivers/s390/net/qeth_main.c | 4 ++-
include/linux/if_vlan.h | 7 ++++-
net/8021q/vlan.c | 14 +++++------
net/8021q/vlan_dev.c | 56 +++++++++++++++++++++---------------------
net/8021q/vlan_netlink.c | 10 ++++----
net/8021q/vlanproc.c | 12 +++++----
7 files changed, 54 insertions(+), 51 deletions(-)
diff --git a/drivers/net/cxgb3/l2t.c b/drivers/net/cxgb3/l2t.c
index d660af7..17ed4c3 100644
--- a/drivers/net/cxgb3/l2t.c
+++ b/drivers/net/cxgb3/l2t.c
@@ -337,7 +337,7 @@ struct l2t_entry *t3_l2t_get(struct t3cdev *cdev, struct neighbour *neigh,
atomic_set(&e->refcnt, 1);
neigh_replace(e, neigh);
if (neigh->dev->priv_flags & IFF_802_1Q_VLAN)
- e->vlan = VLAN_DEV_INFO(neigh->dev)->vlan_id;
+ e->vlan = vlan_dev_info(neigh->dev)->vlan_id;
else
e->vlan = VLAN_NONE;
spin_unlock(&e->lock);
diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c
index f1866a2..62606ce 100644
--- a/drivers/s390/net/qeth_main.c
+++ b/drivers/s390/net/qeth_main.c
@@ -3890,7 +3890,7 @@ qeth_verify_vlan_dev(struct net_device *dev, struct qeth_card *card)
break;
}
}
- if (rc && !(VLAN_DEV_INFO(dev)->real_dev->priv == (void *)card))
+ if (rc && !(vlan_dev_info(dev)->real_dev->priv == (void *)card))
return 0;
#endif
@@ -3930,7 +3930,7 @@ qeth_get_card_from_dev(struct net_device *dev)
card = (struct qeth_card *)dev->priv;
else if (rc == QETH_VLAN_CARD)
card = (struct qeth_card *)
- VLAN_DEV_INFO(dev)->real_dev->priv;
+ vlan_dev_info(dev)->real_dev->priv;
QETH_DBF_TEXT_(trace, 4, "%d", rc);
return card ;
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 129fa87..82c2352 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -143,13 +143,16 @@ struct vlan_dev_info {
unsigned long cnt_encap_on_xmit; /* How many times did we have to encapsulate the skb on TX. */
};
-#define VLAN_DEV_INFO(x) ((struct vlan_dev_info *)(x->priv))
+static inline struct vlan_dev_info *vlan_dev_info(const struct net_device *dev)
+{
+ return netdev_priv(dev);
+}
/* inline functions */
static inline __u32 vlan_get_ingress_priority(struct net_device *dev,
unsigned short vlan_tag)
{
- struct vlan_dev_info *vip = VLAN_DEV_INFO(dev);
+ struct vlan_dev_info *vip = vlan_dev_info(dev);
return vip->ingress_priority_map[(vlan_tag >> 13) & 0x7];
}
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index ac79638..d058c0e 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -134,7 +134,7 @@ static void vlan_rcu_free(struct rcu_head *rcu)
void unregister_vlan_dev(struct net_device *dev)
{
- struct vlan_dev_info *vlan = VLAN_DEV_INFO(dev);
+ struct vlan_dev_info *vlan = vlan_dev_info(dev);
struct net_device *real_dev = vlan->real_dev;
struct vlan_group *grp;
unsigned short vlan_id = vlan->vlan_id;
@@ -229,7 +229,7 @@ int vlan_check_real_dev(struct net_device *real_dev, unsigned short vlan_id)
int register_vlan_dev(struct net_device *dev)
{
- struct vlan_dev_info *vlan = VLAN_DEV_INFO(dev);
+ struct vlan_dev_info *vlan = vlan_dev_info(dev);
struct net_device *real_dev = vlan->real_dev;
unsigned short vlan_id = vlan->vlan_id;
struct vlan_group *grp, *ngrp = NULL;
@@ -328,10 +328,10 @@ static int register_vlan_device(struct net_device *real_dev,
*/
new_dev->mtu = real_dev->mtu;
- VLAN_DEV_INFO(new_dev)->vlan_id = VLAN_ID; /* 1 through VLAN_VID_MASK */
- VLAN_DEV_INFO(new_dev)->real_dev = real_dev;
- VLAN_DEV_INFO(new_dev)->dent = NULL;
- VLAN_DEV_INFO(new_dev)->flags = VLAN_FLAG_REORDER_HDR;
+ vlan_dev_info(new_dev)->vlan_id = VLAN_ID; /* 1 through VLAN_VID_MASK */
+ vlan_dev_info(new_dev)->real_dev = real_dev;
+ vlan_dev_info(new_dev)->dent = NULL;
+ vlan_dev_info(new_dev)->flags = VLAN_FLAG_REORDER_HDR;
new_dev->rtnl_link_ops = &vlan_link_ops;
err = register_vlan_dev(new_dev);
@@ -348,7 +348,7 @@ out_free_newdev:
static void vlan_sync_address(struct net_device *dev,
struct net_device *vlandev)
{
- struct vlan_dev_info *vlan = VLAN_DEV_INFO(vlandev);
+ struct vlan_dev_info *vlan = vlan_dev_info(vlandev);
/* May be called without an actual change */
if (!compare_ether_addr(vlan->real_dev_addr, dev->dev_addr))
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 756a71c..a846559 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -72,7 +72,7 @@ static int vlan_dev_rebuild_header(struct sk_buff *skb)
static inline struct sk_buff *vlan_check_reorder_header(struct sk_buff *skb)
{
- if (VLAN_DEV_INFO(skb->dev)->flags & VLAN_FLAG_REORDER_HDR) {
+ if (vlan_dev_info(skb->dev)->flags & VLAN_FLAG_REORDER_HDR) {
if (skb_shared(skb) || skb_cloned(skb)) {
struct sk_buff *nskb = skb_copy(skb, GFP_ATOMIC);
kfree_skb(skb);
@@ -290,7 +290,7 @@ static inline unsigned short vlan_dev_get_egress_qos_mask(struct net_device* dev
struct sk_buff* skb)
{
struct vlan_priority_tci_mapping *mp =
- VLAN_DEV_INFO(dev)->egress_priority_map[(skb->priority & 0xF)];
+ vlan_dev_info(dev)->egress_priority_map[(skb->priority & 0xF)];
while (mp) {
if (mp->priority == skb->priority) {
@@ -324,7 +324,7 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
struct net_device *vdev = dev; /* save this for the bottom of the method */
pr_debug("%s: skb: %p type: %hx len: %u vlan_id: %hx, daddr: %p\n",
- __FUNCTION__, skb, type, len, VLAN_DEV_INFO(dev)->vlan_id, daddr);
+ __FUNCTION__, skb, type, len, vlan_dev_info(dev)->vlan_id, daddr);
/* build vlan header only if re_order_header flag is NOT set. This
* fixes some programs that get confused when they see a VLAN device
@@ -334,7 +334,7 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
* header shuffling in the hard_start_xmit. Users can turn off this
* REORDER behaviour with the vconfig tool.
*/
- if (!(VLAN_DEV_INFO(dev)->flags & VLAN_FLAG_REORDER_HDR))
+ if (!(vlan_dev_info(dev)->flags & VLAN_FLAG_REORDER_HDR))
build_vlan_header = 1;
if (build_vlan_header) {
@@ -349,7 +349,7 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
* VLAN ID 12 bits (low bits)
*
*/
- veth_TCI = VLAN_DEV_INFO(dev)->vlan_id;
+ veth_TCI = vlan_dev_info(dev)->vlan_id;
veth_TCI |= vlan_dev_get_egress_qos_mask(dev, skb);
vhdr->h_vlan_TCI = htons(veth_TCI);
@@ -374,7 +374,7 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
if (saddr == NULL)
saddr = dev->dev_addr;
- dev = VLAN_DEV_INFO(dev)->real_dev;
+ dev = vlan_dev_info(dev)->real_dev;
/* MPLS can send us skbuffs w/out enough space. This check will grow the
* skb if it doesn't have enough headroom. Not a beautiful solution, so
@@ -395,7 +395,7 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
stats->tx_dropped++;
return -ENOMEM;
}
- VLAN_DEV_INFO(vdev)->cnt_inc_headroom_on_tx++;
+ vlan_dev_info(vdev)->cnt_inc_headroom_on_tx++;
pr_debug("%s: %s: had to grow skb.\n", __FUNCTION__, vdev->name);
}
@@ -430,12 +430,12 @@ static int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
*/
if (veth->h_vlan_proto != htons(ETH_P_8021Q) ||
- VLAN_DEV_INFO(dev)->flags & VLAN_FLAG_REORDER_HDR) {
+ vlan_dev_info(dev)->flags & VLAN_FLAG_REORDER_HDR) {
int orig_headroom = skb_headroom(skb);
unsigned short veth_TCI;
/* This is not a VLAN frame...but we can fix that! */
- VLAN_DEV_INFO(dev)->cnt_encap_on_xmit++;
+ vlan_dev_info(dev)->cnt_encap_on_xmit++;
pr_debug("%s: proto to encap: 0x%hx\n",
__FUNCTION__, htons(veth->h_vlan_proto));
@@ -445,7 +445,7 @@ static int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
* CFI 1 bit
* VLAN ID 12 bits (low bits)
*/
- veth_TCI = VLAN_DEV_INFO(dev)->vlan_id;
+ veth_TCI = vlan_dev_info(dev)->vlan_id;
veth_TCI |= vlan_dev_get_egress_qos_mask(dev, skb);
skb = __vlan_put_tag(skb, veth_TCI);
@@ -455,7 +455,7 @@ static int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
}
if (orig_headroom < VLAN_HLEN) {
- VLAN_DEV_INFO(dev)->cnt_inc_headroom_on_tx++;
+ vlan_dev_info(dev)->cnt_inc_headroom_on_tx++;
}
}
@@ -472,7 +472,7 @@ static int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
stats->tx_packets++; /* for statics only */
stats->tx_bytes += skb->len;
- skb->dev = VLAN_DEV_INFO(dev)->real_dev;
+ skb->dev = vlan_dev_info(dev)->real_dev;
dev_queue_xmit(skb);
return 0;
@@ -490,14 +490,14 @@ static int vlan_dev_hwaccel_hard_start_xmit(struct sk_buff *skb,
* CFI 1 bit
* VLAN ID 12 bits (low bits)
*/
- veth_TCI = VLAN_DEV_INFO(dev)->vlan_id;
+ veth_TCI = vlan_dev_info(dev)->vlan_id;
veth_TCI |= vlan_dev_get_egress_qos_mask(dev, skb);
skb = __vlan_hwaccel_put_tag(skb, veth_TCI);
stats->tx_packets++;
stats->tx_bytes += skb->len;
- skb->dev = VLAN_DEV_INFO(dev)->real_dev;
+ skb->dev = vlan_dev_info(dev)->real_dev;
dev_queue_xmit(skb);
return 0;
@@ -508,7 +508,7 @@ static int vlan_dev_change_mtu(struct net_device *dev, int new_mtu)
/* TODO: gotta make sure the underlying layer can handle it,
* maybe an IFF_VLAN_CAPABLE flag for devices?
*/
- if (VLAN_DEV_INFO(dev)->real_dev->mtu < new_mtu)
+ if (vlan_dev_info(dev)->real_dev->mtu < new_mtu)
return -ERANGE;
dev->mtu = new_mtu;
@@ -519,7 +519,7 @@ static int vlan_dev_change_mtu(struct net_device *dev, int new_mtu)
void vlan_dev_set_ingress_priority(const struct net_device *dev,
u32 skb_prio, short vlan_prio)
{
- struct vlan_dev_info *vlan = VLAN_DEV_INFO(dev);
+ struct vlan_dev_info *vlan = vlan_dev_info(dev);
if (vlan->ingress_priority_map[vlan_prio & 0x7] && !skb_prio)
vlan->nr_ingress_mappings--;
@@ -532,7 +532,7 @@ void vlan_dev_set_ingress_priority(const struct net_device *dev,
int vlan_dev_set_egress_priority(const struct net_device *dev,
u32 skb_prio, short vlan_prio)
{
- struct vlan_dev_info *vlan = VLAN_DEV_INFO(dev);
+ struct vlan_dev_info *vlan = vlan_dev_info(dev);
struct vlan_priority_tci_mapping *mp = NULL;
struct vlan_priority_tci_mapping *np;
u32 vlan_qos = (vlan_prio << 13) & 0xE000;
@@ -573,9 +573,9 @@ int vlan_dev_set_vlan_flag(const struct net_device *dev,
/* verify flag is supported */
if (flag == VLAN_FLAG_REORDER_HDR) {
if (flag_val) {
- VLAN_DEV_INFO(dev)->flags |= VLAN_FLAG_REORDER_HDR;
+ vlan_dev_info(dev)->flags |= VLAN_FLAG_REORDER_HDR;
} else {
- VLAN_DEV_INFO(dev)->flags &= ~VLAN_FLAG_REORDER_HDR;
+ vlan_dev_info(dev)->flags &= ~VLAN_FLAG_REORDER_HDR;
}
return 0;
}
@@ -584,17 +584,17 @@ int vlan_dev_set_vlan_flag(const struct net_device *dev,
void vlan_dev_get_realdev_name(const struct net_device *dev, char *result)
{
- strncpy(result, VLAN_DEV_INFO(dev)->real_dev->name, 23);
+ strncpy(result, vlan_dev_info(dev)->real_dev->name, 23);
}
void vlan_dev_get_vid(const struct net_device *dev, unsigned short *result)
{
- *result = VLAN_DEV_INFO(dev)->vlan_id;
+ *result = vlan_dev_info(dev)->vlan_id;
}
static int vlan_dev_open(struct net_device *dev)
{
- struct vlan_dev_info *vlan = VLAN_DEV_INFO(dev);
+ struct vlan_dev_info *vlan = vlan_dev_info(dev);
struct net_device *real_dev = vlan->real_dev;
int err;
@@ -618,7 +618,7 @@ static int vlan_dev_open(struct net_device *dev)
static int vlan_dev_stop(struct net_device *dev)
{
- struct net_device *real_dev = VLAN_DEV_INFO(dev)->real_dev;
+ struct net_device *real_dev = vlan_dev_info(dev)->real_dev;
dev_mc_unsync(real_dev, dev);
if (dev->flags & IFF_ALLMULTI)
@@ -634,7 +634,7 @@ static int vlan_dev_stop(struct net_device *dev)
static int vlan_dev_set_mac_address(struct net_device *dev, void *p)
{
- struct net_device *real_dev = VLAN_DEV_INFO(dev)->real_dev;
+ struct net_device *real_dev = vlan_dev_info(dev)->real_dev;
struct sockaddr *addr = p;
int err;
@@ -660,7 +660,7 @@ out:
static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{
- struct net_device *real_dev = VLAN_DEV_INFO(dev)->real_dev;
+ struct net_device *real_dev = vlan_dev_info(dev)->real_dev;
struct ifreq ifrr;
int err = -EOPNOTSUPP;
@@ -684,7 +684,7 @@ static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
static void vlan_dev_change_rx_flags(struct net_device *dev, int change)
{
- struct net_device *real_dev = VLAN_DEV_INFO(dev)->real_dev;
+ struct net_device *real_dev = vlan_dev_info(dev)->real_dev;
if (change & IFF_ALLMULTI)
dev_set_allmulti(real_dev, dev->flags & IFF_ALLMULTI ? 1 : -1);
@@ -694,7 +694,7 @@ static void vlan_dev_change_rx_flags(struct net_device *dev, int change)
static void vlan_dev_set_multicast_list(struct net_device *vlan_dev)
{
- dev_mc_sync(VLAN_DEV_INFO(vlan_dev)->real_dev, vlan_dev);
+ dev_mc_sync(vlan_dev_info(vlan_dev)->real_dev, vlan_dev);
}
/*
@@ -712,7 +712,7 @@ static const struct header_ops vlan_header_ops = {
static int vlan_dev_init(struct net_device *dev)
{
- struct net_device *real_dev = VLAN_DEV_INFO(dev)->real_dev;
+ struct net_device *real_dev = vlan_dev_info(dev)->real_dev;
int subclass = 0;
/* IFF_BROADCAST|IFF_MULTICAST; ??? */
diff --git a/net/8021q/vlan_netlink.c b/net/8021q/vlan_netlink.c
index 9ee6358..e32eeb3 100644
--- a/net/8021q/vlan_netlink.c
+++ b/net/8021q/vlan_netlink.c
@@ -75,7 +75,7 @@ static int vlan_validate(struct nlattr *tb[], struct nlattr *data[])
static int vlan_changelink(struct net_device *dev,
struct nlattr *tb[], struct nlattr *data[])
{
- struct vlan_dev_info *vlan = VLAN_DEV_INFO(dev);
+ struct vlan_dev_info *vlan = vlan_dev_info(dev);
struct ifla_vlan_flags *flags;
struct ifla_vlan_qos_mapping *m;
struct nlattr *attr;
@@ -104,7 +104,7 @@ static int vlan_changelink(struct net_device *dev,
static int vlan_newlink(struct net_device *dev,
struct nlattr *tb[], struct nlattr *data[])
{
- struct vlan_dev_info *vlan = VLAN_DEV_INFO(dev);
+ struct vlan_dev_info *vlan = vlan_dev_info(dev);
struct net_device *real_dev;
int err;
@@ -148,7 +148,7 @@ static inline size_t vlan_qos_map_size(unsigned int n)
static size_t vlan_get_size(const struct net_device *dev)
{
- struct vlan_dev_info *vlan = VLAN_DEV_INFO(dev);
+ struct vlan_dev_info *vlan = vlan_dev_info(dev);
return nla_total_size(2) + /* IFLA_VLAN_ID */
vlan_qos_map_size(vlan->nr_ingress_mappings) +
@@ -157,14 +157,14 @@ static size_t vlan_get_size(const struct net_device *dev)
static int vlan_fill_info(struct sk_buff *skb, const struct net_device *dev)
{
- struct vlan_dev_info *vlan = VLAN_DEV_INFO(dev);
+ struct vlan_dev_info *vlan = vlan_dev_info(dev);
struct vlan_priority_tci_mapping *pm;
struct ifla_vlan_flags f;
struct ifla_vlan_qos_mapping m;
struct nlattr *nest;
unsigned int i;
- NLA_PUT_U16(skb, IFLA_VLAN_ID, VLAN_DEV_INFO(dev)->vlan_id);
+ NLA_PUT_U16(skb, IFLA_VLAN_ID, vlan_dev_info(dev)->vlan_id);
if (vlan->flags) {
f.flags = vlan->flags;
f.mask = ~0;
diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c
index 971e623..b520244 100644
--- a/net/8021q/vlanproc.c
+++ b/net/8021q/vlanproc.c
@@ -180,7 +180,7 @@ err:
int vlan_proc_add_dev (struct net_device *vlandev)
{
- struct vlan_dev_info *dev_info = VLAN_DEV_INFO(vlandev);
+ struct vlan_dev_info *dev_info = vlan_dev_info(vlandev);
dev_info->dent = create_proc_entry(vlandev->name,
S_IFREG|S_IRUSR|S_IWUSR,
@@ -199,9 +199,9 @@ int vlan_proc_add_dev (struct net_device *vlandev)
int vlan_proc_rem_dev(struct net_device *vlandev)
{
/** NOTE: This will consume the memory pointed to by dent, it seems. */
- if (VLAN_DEV_INFO(vlandev)->dent) {
- remove_proc_entry(VLAN_DEV_INFO(vlandev)->dent->name, proc_vlan_dir);
- VLAN_DEV_INFO(vlandev)->dent = NULL;
+ if (vlan_dev_info(vlandev)->dent) {
+ remove_proc_entry(vlan_dev_info(vlandev)->dent->name, proc_vlan_dir);
+ vlan_dev_info(vlandev)->dent = NULL;
}
return 0;
}
@@ -278,7 +278,7 @@ static int vlan_seq_show(struct seq_file *seq, void *v)
nmtype ? nmtype : "UNKNOWN" );
} else {
const struct net_device *vlandev = v;
- const struct vlan_dev_info *dev_info = VLAN_DEV_INFO(vlandev);
+ const struct vlan_dev_info *dev_info = vlan_dev_info(vlandev);
seq_printf(seq, "%-15s| %d | %s\n", vlandev->name,
dev_info->vlan_id, dev_info->real_dev->name);
@@ -289,7 +289,7 @@ static int vlan_seq_show(struct seq_file *seq, void *v)
static int vlandev_seq_show(struct seq_file *seq, void *offset)
{
struct net_device *vlandev = (struct net_device *) seq->private;
- const struct vlan_dev_info *dev_info = VLAN_DEV_INFO(vlandev);
+ const struct vlan_dev_info *dev_info = vlan_dev_info(vlandev);
struct net_device_stats *stats = &vlandev->stats;
static const char fmt[] = "%30s %12lu\n";
int i;
^ permalink raw reply related
* [VLAN 14/18]: Turn __constant_htons into htons where possible
From: Patrick McHardy @ 2008-01-20 17:11 UTC (permalink / raw)
To: davem; +Cc: netdev, Patrick McHardy
In-Reply-To: <20080120171117.7980.67072.sendpatchset@localhost.localdomain>
[VLAN]: Turn __constant_htons into htons where possible
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit 40048c4ab8a08ea7f0e2df52f0ec02a8010d2a0e
tree bf0486c7fd56dae810144d1695281fb39ce402e7
parent 84ea6a8ff0745f63e25d2d17664fd8c56448f985
author Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 17:37:31 +0100
committer Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 17:37:31 +0100
include/linux/if_vlan.h | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 82c2352..34f40ef 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -271,12 +271,12 @@ static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, unsigned short
memmove(skb->data, skb->data + VLAN_HLEN, 2 * VLAN_ETH_ALEN);
/* first, the ethernet type */
- veth->h_vlan_proto = __constant_htons(ETH_P_8021Q);
+ veth->h_vlan_proto = htons(ETH_P_8021Q);
/* now, the tag */
veth->h_vlan_TCI = htons(tag);
- skb->protocol = __constant_htons(ETH_P_8021Q);
+ skb->protocol = htons(ETH_P_8021Q);
skb->mac_header -= VLAN_HLEN;
skb->network_header -= VLAN_HLEN;
@@ -331,7 +331,7 @@ static inline int __vlan_get_tag(struct sk_buff *skb, unsigned short *tag)
{
struct vlan_ethhdr *veth = (struct vlan_ethhdr *)skb->data;
- if (veth->h_vlan_proto != __constant_htons(ETH_P_8021Q)) {
+ if (veth->h_vlan_proto != htons(ETH_P_8021Q)) {
return -EINVAL;
}
^ permalink raw reply related
* [VLAN 15/18]: checkpatch cleanups
From: Patrick McHardy @ 2008-01-20 17:11 UTC (permalink / raw)
To: davem; +Cc: netdev, Patrick McHardy
In-Reply-To: <20080120171117.7980.67072.sendpatchset@localhost.localdomain>
[VLAN]: checkpatch cleanups
Checkpatch cleanups, consisting mainly of overly long lines and missing
spaces.
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit bea0af04454189d656afd69168e0e3ec3209b6b2
tree 6b7d57540dbaf1e40c295d4ba0d40d021a0fec50
parent 40048c4ab8a08ea7f0e2df52f0ec02a8010d2a0e
author Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 17:37:31 +0100
committer Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 17:37:31 +0100
net/8021q/vlan.c | 20 ++++++----
net/8021q/vlan.h | 2 +
net/8021q/vlan_dev.c | 98 +++++++++++++++++++++++++-------------------------
net/8021q/vlanproc.c | 42 +++++++++++----------
net/8021q/vlanproc.h | 11 +++---
5 files changed, 89 insertions(+), 84 deletions(-)
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index d058c0e..8b93799 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -43,7 +43,6 @@
/* Our listing of VLAN group(s) */
static struct hlist_head vlan_group_hash[VLAN_GRP_HASH_SIZE];
-#define vlan_grp_hashfn(IDX) ((((IDX) >> VLAN_GRP_HASH_SHIFT) ^ (IDX)) & VLAN_GRP_HASH_MASK)
static char vlan_fullname[] = "802.1Q VLAN Support";
static char vlan_version[] = DRV_VERSION;
@@ -60,6 +59,11 @@ static struct packet_type vlan_packet_type = {
/* End of global variables definitions. */
+static inline unsigned int vlan_grp_hashfn(unsigned int idx)
+{
+ return ((idx >> VLAN_GRP_HASH_SHIFT) ^ idx) & VLAN_GRP_HASH_MASK;
+}
+
/* Must be invoked with RCU read lock (no preempt) */
static struct vlan_group *__vlan_find_group(int real_dev_ifindex)
{
@@ -94,7 +98,7 @@ static void vlan_group_free(struct vlan_group *grp)
{
int i;
- for (i=0; i < VLAN_GROUP_ARRAY_SPLIT_PARTS; i++)
+ for (i = 0; i < VLAN_GROUP_ARRAY_SPLIT_PARTS; i++)
kfree(grp->vlan_devices_arrays[i]);
kfree(grp);
}
@@ -174,7 +178,8 @@ void unregister_vlan_dev(struct net_device *dev)
unregister_netdevice(dev);
}
-static void vlan_transfer_operstate(const struct net_device *dev, struct net_device *vlandev)
+static void vlan_transfer_operstate(const struct net_device *dev,
+ struct net_device *vlandev)
{
/* Have to respect userspace enforced dormant state
* of real device, also must allow supplicant running
@@ -369,7 +374,8 @@ static void vlan_sync_address(struct net_device *dev,
memcpy(vlan->real_dev_addr, dev->dev_addr, ETH_ALEN);
}
-static int vlan_device_event(struct notifier_block *unused, unsigned long event, void *ptr)
+static int vlan_device_event(struct notifier_block *unused, unsigned long event,
+ void *ptr)
{
struct net_device *dev = ptr;
struct vlan_group *grp = __vlan_find_group(dev->ifindex);
@@ -569,9 +575,8 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
err = 0;
vlan_dev_get_realdev_name(dev, args.u.device2);
if (copy_to_user(arg, &args,
- sizeof(struct vlan_ioctl_args))) {
+ sizeof(struct vlan_ioctl_args)))
err = -EFAULT;
- }
break;
case GET_VLAN_VID_CMD:
@@ -579,9 +584,8 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
vlan_dev_get_vid(dev, &vid);
args.u.VID = vid;
if (copy_to_user(arg, &args,
- sizeof(struct vlan_ioctl_args))) {
+ sizeof(struct vlan_ioctl_args)))
err = -EFAULT;
- }
break;
default:
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
index 0cfdf77..73efcc7 100644
--- a/net/8021q/vlan.h
+++ b/net/8021q/vlan.h
@@ -20,7 +20,7 @@ extern unsigned short vlan_name_type;
* Must be invoked with rcu_read_lock (ie preempt disabled)
* or with RTNL.
*/
-struct net_device *__find_vlan_dev(struct net_device* real_dev,
+struct net_device *__find_vlan_dev(struct net_device *real_dev,
unsigned short VID); /* vlan.c */
/* found in vlan_dev.c */
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index a846559..2ff7659 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -106,13 +106,13 @@ static inline struct sk_buff *vlan_check_reorder_header(struct sk_buff *skb)
* SANITY NOTE 2: We are referencing to the VLAN_HDR frields, which MAY be
* stored UNALIGNED in the memory. RISC systems don't like
* such cases very much...
- * SANITY NOTE 2a: According to Dave Miller & Alexey, it will always be aligned,
- * so there doesn't need to be any of the unaligned stuff. It has
- * been commented out now... --Ben
+ * SANITY NOTE 2a: According to Dave Miller & Alexey, it will always be
+ * aligned, so there doesn't need to be any of the unaligned
+ * stuff. It has been commented out now... --Ben
*
*/
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;
@@ -126,7 +126,8 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
return -1;
}
- if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL)
+ skb = skb_share_check(skb, GFP_ATOMIC);
+ if (skb == NULL)
return -1;
if (unlikely(!pskb_may_pull(skb, VLAN_HLEN))) {
@@ -156,8 +157,8 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
skb->dev = __find_vlan_dev(dev, vid);
if (!skb->dev) {
rcu_read_unlock();
- pr_debug("%s: ERROR: No net_device for VID: %u on dev: %s [%i]\n",
- __FUNCTION__, (unsigned int)vid, dev->name, dev->ifindex);
+ pr_debug("%s: ERROR: No net_device for VID: %u on dev: %s\n",
+ __FUNCTION__, (unsigned int)vid, dev->name);
kfree_skb(skb);
return -1;
}
@@ -175,7 +176,8 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
/*
* Deal with ingress priority mapping.
*/
- skb->priority = vlan_get_ingress_priority(skb->dev, ntohs(vhdr->h_vlan_TCI));
+ skb->priority = vlan_get_ingress_priority(skb->dev,
+ ntohs(vhdr->h_vlan_TCI));
pr_debug("%s: priority: %u for TCI: %hu\n",
__FUNCTION__, skb->priority, ntohs(vhdr->h_vlan_TCI));
@@ -185,7 +187,7 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
*/
switch (skb->pkt_type) {
case PACKET_BROADCAST: /* Yeah, stats collect these together.. */
- // stats->broadcast ++; // no such counter :-(
+ /* stats->broadcast ++; // no such counter :-( */
break;
case PACKET_MULTICAST:
@@ -194,13 +196,13 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
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.
+ * This allows the VLAN to have a different MAC than the
+ * underlying device, and still route correctly.
*/
- if (!compare_ether_addr(eth_hdr(skb)->h_dest, skb->dev->dev_addr)) {
+ if (!compare_ether_addr(eth_hdr(skb)->h_dest,
+ skb->dev->dev_addr))
/* It is for our (changed) MAC-address! */
skb->pkt_type = PACKET_HOST;
- }
break;
default:
break;
@@ -244,8 +246,8 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
*/
if (*(unsigned short *)rawp == 0xFFFF) {
skb->protocol = htons(ETH_P_802_3);
- /* place it back on the queue to be handled by true layer 3 protocols.
- */
+ /* place it back on the queue to be handled by true layer 3
+ * protocols. */
/* See if we are configured to re-write the VLAN header
* to make it look like ethernet...
@@ -286,17 +288,17 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
return 0;
}
-static inline unsigned short vlan_dev_get_egress_qos_mask(struct net_device* dev,
- struct sk_buff* skb)
+static inline unsigned short
+vlan_dev_get_egress_qos_mask(struct net_device *dev, struct sk_buff *skb)
{
- struct vlan_priority_tci_mapping *mp =
- vlan_dev_info(dev)->egress_priority_map[(skb->priority & 0xF)];
+ struct vlan_priority_tci_mapping *mp;
+ mp = vlan_dev_info(dev)->egress_priority_map[(skb->priority & 0xF)];
while (mp) {
if (mp->priority == skb->priority) {
- return mp->vlan_qos; /* This should already be shifted to mask
- * correctly with the VLAN's TCI
- */
+ return mp->vlan_qos; /* This should already be shifted
+ * to mask correctly with the
+ * VLAN's TCI */
}
mp = mp->next;
}
@@ -321,10 +323,11 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
unsigned short veth_TCI = 0;
int rc = 0;
int build_vlan_header = 0;
- struct net_device *vdev = dev; /* save this for the bottom of the method */
+ struct net_device *vdev = dev;
pr_debug("%s: skb: %p type: %hx len: %u vlan_id: %hx, daddr: %p\n",
- __FUNCTION__, skb, type, len, vlan_dev_info(dev)->vlan_id, daddr);
+ __FUNCTION__, skb, type, len, vlan_dev_info(dev)->vlan_id,
+ daddr);
/* build vlan header only if re_order_header flag is NOT set. This
* fixes some programs that get confused when they see a VLAN device
@@ -342,8 +345,8 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
/* build the four bytes that make this a VLAN header. */
- /* Now, construct the second two bytes. This field looks something
- * like:
+ /* Now, construct the second two bytes. This field looks
+ * something like:
* usr_priority: 3 bits (high bits)
* CFI 1 bit
* VLAN ID 12 bits (low bits)
@@ -355,16 +358,15 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
vhdr->h_vlan_TCI = htons(veth_TCI);
/*
- * Set the protocol type.
- * For a packet of type ETH_P_802_3 we put the length in here instead.
- * It is up to the 802.2 layer to carry protocol information.
+ * Set the protocol type. For a packet of type ETH_P_802_3 we
+ * put the length in here instead. It is up to the 802.2
+ * layer to carry protocol information.
*/
- if (type != ETH_P_802_3) {
+ if (type != ETH_P_802_3)
vhdr->h_vlan_encapsulated_proto = htons(type);
- } else {
+ else
vhdr->h_vlan_encapsulated_proto = htons(len);
- }
skb->protocol = htons(ETH_P_8021Q);
skb_reset_network_header(skb);
@@ -376,14 +378,14 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
dev = vlan_dev_info(dev)->real_dev;
- /* MPLS can send us skbuffs w/out enough space. This check will grow the
- * skb if it doesn't have enough headroom. Not a beautiful solution, so
- * I'll tick a counter so that users can know it's happening... If they
- * care...
+ /* MPLS can send us skbuffs w/out enough space. This check will grow
+ * the skb if it doesn't have enough headroom. Not a beautiful solution,
+ * so I'll tick a counter so that users can know it's happening...
+ * If they care...
*/
- /* NOTE: This may still break if the underlying device is not the final
- * device (and thus there are more headers to add...) It should work for
+ /* NOTE: This may still break if the underlying device is not the final
+ * device (and thus there are more headers to add...) It should work for
* good-ole-ethernet though.
*/
if (skb_headroom(skb) < dev->hard_header_len) {
@@ -396,7 +398,7 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
return -ENOMEM;
}
vlan_dev_info(vdev)->cnt_inc_headroom_on_tx++;
- pr_debug("%s: %s: had to grow skb.\n", __FUNCTION__, vdev->name);
+ pr_debug("%s: %s: had to grow skb\n", __FUNCTION__, vdev->name);
}
if (build_vlan_header) {
@@ -408,10 +410,10 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
else if (rc < 0)
rc -= VLAN_HLEN;
} else
- /* If here, then we'll just make a normal looking ethernet frame,
- * but, the hard_start_xmit method will insert the tag (it has to
- * be able to do this for bridged and other skbs that don't come
- * down the protocol stack in an orderly manner.
+ /* If here, then we'll just make a normal looking ethernet
+ * frame, but, the hard_start_xmit method will insert the tag
+ * (it has to be able to do this for bridged and other skbs
+ * that don't come down the protocol stack in an orderly manner.
*/
rc = dev_hard_header(skb, dev, type, daddr, saddr, len);
@@ -454,9 +456,8 @@ static int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
return 0;
}
- if (orig_headroom < VLAN_HLEN) {
+ if (orig_headroom < VLAN_HLEN)
vlan_dev_info(dev)->cnt_inc_headroom_on_tx++;
- }
}
pr_debug("%s: about to send skb: %p to dev: %s\n",
@@ -572,11 +573,10 @@ int vlan_dev_set_vlan_flag(const struct net_device *dev,
{
/* verify flag is supported */
if (flag == VLAN_FLAG_REORDER_HDR) {
- if (flag_val) {
+ if (flag_val)
vlan_dev_info(dev)->flags |= VLAN_FLAG_REORDER_HDR;
- } else {
+ else
vlan_dev_info(dev)->flags &= ~VLAN_FLAG_REORDER_HDR;
- }
return 0;
}
return -EINVAL;
@@ -667,7 +667,7 @@ static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
strncpy(ifrr.ifr_name, real_dev->name, IFNAMSIZ);
ifrr.ifr_ifru = ifr->ifr_ifru;
- switch(cmd) {
+ switch (cmd) {
case SIOCGMIIPHY:
case SIOCGMIIREG:
case SIOCSMIIREG:
diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c
index b520244..2a4e1aa 100644
--- a/net/8021q/vlanproc.c
+++ b/net/8021q/vlanproc.c
@@ -125,10 +125,10 @@ static struct proc_dir_entry *proc_vlan_conf;
/* Strings */
static const char *vlan_name_type_str[VLAN_NAME_TYPE_HIGHEST] = {
- [VLAN_NAME_TYPE_RAW_PLUS_VID] = "VLAN_NAME_TYPE_RAW_PLUS_VID",
- [VLAN_NAME_TYPE_PLUS_VID_NO_PAD] = "VLAN_NAME_TYPE_PLUS_VID_NO_PAD",
- [VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD]= "VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD",
- [VLAN_NAME_TYPE_PLUS_VID] = "VLAN_NAME_TYPE_PLUS_VID",
+ [VLAN_NAME_TYPE_RAW_PLUS_VID] = "VLAN_NAME_TYPE_RAW_PLUS_VID",
+ [VLAN_NAME_TYPE_PLUS_VID_NO_PAD] = "VLAN_NAME_TYPE_PLUS_VID_NO_PAD",
+ [VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD] = "VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD",
+ [VLAN_NAME_TYPE_PLUS_VID] = "VLAN_NAME_TYPE_PLUS_VID",
};
/*
* Interface functions
@@ -178,7 +178,7 @@ err:
* Add directory entry for VLAN device.
*/
-int vlan_proc_add_dev (struct net_device *vlandev)
+int vlan_proc_add_dev(struct net_device *vlandev)
{
struct vlan_dev_info *dev_info = vlan_dev_info(vlandev);
@@ -200,7 +200,8 @@ int vlan_proc_rem_dev(struct net_device *vlandev)
{
/** NOTE: This will consume the memory pointed to by dent, it seems. */
if (vlan_dev_info(vlandev)->dent) {
- remove_proc_entry(vlan_dev_info(vlandev)->dent->name, proc_vlan_dir);
+ remove_proc_entry(vlan_dev_info(vlandev)->dent->name,
+ proc_vlan_dir);
vlan_dev_info(vlandev)->dent = NULL;
}
return 0;
@@ -275,7 +276,7 @@ static int vlan_seq_show(struct seq_file *seq, void *v)
nmtype = vlan_name_type_str[vlan_name_type];
seq_printf(seq, "Name-Type: %s\n",
- nmtype ? nmtype : "UNKNOWN" );
+ nmtype ? nmtype : "UNKNOWN");
} else {
const struct net_device *vlandev = v;
const struct vlan_dev_info *dev_info = vlan_dev_info(vlandev);
@@ -297,9 +298,10 @@ static int vlandev_seq_show(struct seq_file *seq, void *offset)
if (!(vlandev->priv_flags & IFF_802_1Q_VLAN))
return 0;
- seq_printf(seq, "%s VID: %d REORDER_HDR: %i dev->priv_flags: %hx\n",
- vlandev->name, dev_info->vlan_id,
- (int)(dev_info->flags & 1), vlandev->priv_flags);
+ seq_printf(seq,
+ "%s VID: %d REORDER_HDR: %i dev->priv_flags: %hx\n",
+ vlandev->name, dev_info->vlan_id,
+ (int)(dev_info->flags & 1), vlandev->priv_flags);
seq_printf(seq, fmt, "total frames received", stats->rx_packets);
seq_printf(seq, fmt, "total bytes received", stats->rx_bytes);
@@ -313,16 +315,16 @@ static int vlandev_seq_show(struct seq_file *seq, void *offset)
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,
- "\nINGRESS priority mappings: 0:%u 1:%u 2:%u 3:%u 4:%u 5:%u 6:%u 7:%u\n",
- dev_info->ingress_priority_map[0],
- dev_info->ingress_priority_map[1],
- dev_info->ingress_priority_map[2],
- dev_info->ingress_priority_map[3],
- dev_info->ingress_priority_map[4],
- dev_info->ingress_priority_map[5],
- dev_info->ingress_priority_map[6],
- dev_info->ingress_priority_map[7]);
+ seq_printf(seq, "\nINGRESS priority mappings: "
+ "0:%u 1:%u 2:%u 3:%u 4:%u 5:%u 6:%u 7:%u\n",
+ dev_info->ingress_priority_map[0],
+ dev_info->ingress_priority_map[1],
+ dev_info->ingress_priority_map[2],
+ dev_info->ingress_priority_map[3],
+ dev_info->ingress_priority_map[4],
+ dev_info->ingress_priority_map[5],
+ dev_info->ingress_priority_map[6],
+ dev_info->ingress_priority_map[7]);
seq_printf(seq, "EGRESSS priority Mappings: ");
for (i = 0; i < 16; i++) {
diff --git a/net/8021q/vlanproc.h b/net/8021q/vlanproc.h
index f908ee3..da542ca 100644
--- a/net/8021q/vlanproc.h
+++ b/net/8021q/vlanproc.h
@@ -4,16 +4,15 @@
#ifdef CONFIG_PROC_FS
int vlan_proc_init(void);
int vlan_proc_rem_dev(struct net_device *vlandev);
-int vlan_proc_add_dev (struct net_device *vlandev);
-void vlan_proc_cleanup (void);
+int vlan_proc_add_dev(struct net_device *vlandev);
+void vlan_proc_cleanup(void);
#else /* No CONFIG_PROC_FS */
#define vlan_proc_init() (0)
-#define vlan_proc_cleanup() do {} while(0)
-#define vlan_proc_add_dev(dev) ({(void)(dev), 0;})
-#define vlan_proc_rem_dev(dev) ({(void)(dev), 0;})
-
+#define vlan_proc_cleanup() do {} while (0)
+#define vlan_proc_add_dev(dev) ({(void)(dev), 0; })
+#define vlan_proc_rem_dev(dev) ({(void)(dev), 0; })
#endif
#endif /* !(__BEN_VLAN_PROC_INC__) */
^ permalink raw reply related
* [VLAN 16/18]: Update list address
From: Patrick McHardy @ 2008-01-20 17:11 UTC (permalink / raw)
To: davem; +Cc: netdev, Patrick McHardy
In-Reply-To: <20080120171117.7980.67072.sendpatchset@localhost.localdomain>
[VLAN]: Update list address
VLAN related mail should go to netdev.
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit e7e221b07c3a3f77df617232ea0f76094edc1071
tree 347c69877e8e1b5fc5e730b099683739ba83a6d0
parent bea0af04454189d656afd69168e0e3ec3209b6b2
author Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 17:37:32 +0100
committer Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 17:37:32 +0100
net/8021q/vlan.c | 2 +-
net/8021q/vlan_dev.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 8b93799..dbc81b9 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -3,7 +3,7 @@
* Ethernet-type device handling.
*
* Authors: Ben Greear <greearb@candelatech.com>
- * Please send support related email to: vlan@scry.wanfear.com
+ * Please send support related email to: netdev@vger.kernel.org
* VLAN Home Page: http://www.candelatech.com/~greear/vlan.html
*
* Fixes:
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 2ff7659..e19e491 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -3,7 +3,7 @@
* Ethernet-type device handling.
*
* Authors: Ben Greear <greearb@candelatech.com>
- * Please send support related email to: vlan@scry.wanfear.com
+ * Please send support related email to: netdev@vger.kernel.org
* VLAN Home Page: http://www.candelatech.com/~greear/vlan.html
*
* Fixes: Mar 22 2001: Martin Bokaemper <mbokaemper@unispherenetworks.com>
^ permalink raw reply related
* [VLAN 17/18]: Clean up vlan_skb_recv()
From: Patrick McHardy @ 2008-01-20 17:11 UTC (permalink / raw)
To: davem; +Cc: netdev, Patrick McHardy
In-Reply-To: <20080120171117.7980.67072.sendpatchset@localhost.localdomain>
[VLAN]: Clean up vlan_skb_recv()
- remove three instances of identical code
- remove unnecessary NULL initialization
- remove obvious and unnecessary comments
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit c314238cb2135e4bb812487ed47652a5e2e4b748
tree 42969440a4ea33d5addcbbce4758ed5f377b4a7e
parent e7e221b07c3a3f77df617232ea0f76094edc1071
author Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 17:37:32 +0100
committer Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 17:37:32 +0100
net/8021q/vlan_dev.c | 113 +++++++++++---------------------------------------
1 files changed, 24 insertions(+), 89 deletions(-)
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index e19e491..57799af 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -114,77 +114,49 @@ static inline struct sk_buff *vlan_check_reorder_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)
{
- unsigned char *rawp = NULL;
+ unsigned char *rawp;
struct vlan_hdr *vhdr;
unsigned short vid;
struct net_device_stats *stats;
unsigned short vlan_TCI;
__be16 proto;
- if (dev->nd_net != &init_net) {
- kfree_skb(skb);
- return -1;
- }
+ if (dev->nd_net != &init_net)
+ goto err_free;
skb = skb_share_check(skb, GFP_ATOMIC);
if (skb == NULL)
- return -1;
-
- if (unlikely(!pskb_may_pull(skb, VLAN_HLEN))) {
- kfree_skb(skb);
- return -1;
- }
+ goto err_free;
- vhdr = (struct vlan_hdr *)(skb->data);
+ if (unlikely(!pskb_may_pull(skb, VLAN_HLEN)))
+ goto err_free;
- /* vlan_TCI = ntohs(get_unaligned(&vhdr->h_vlan_TCI)); */
+ vhdr = (struct vlan_hdr *)skb->data;
vlan_TCI = ntohs(vhdr->h_vlan_TCI);
-
vid = (vlan_TCI & VLAN_VID_MASK);
- /* Ok, we will find the correct VLAN device, strip the header,
- * and then go on as usual.
- */
-
- /* We have 12 bits of vlan ID.
- *
- * We must not drop allow preempt until we hold a
- * reference to the device (netif_rx does that) or we
- * fail.
- */
-
rcu_read_lock();
skb->dev = __find_vlan_dev(dev, vid);
if (!skb->dev) {
- rcu_read_unlock();
pr_debug("%s: ERROR: No net_device for VID: %u on dev: %s\n",
__FUNCTION__, (unsigned int)vid, dev->name);
- kfree_skb(skb);
- return -1;
+ goto err_unlock;
}
skb->dev->last_rx = jiffies;
- /* Bump the rx counters for the VLAN device. */
stats = &skb->dev->stats;
stats->rx_packets++;
stats->rx_bytes += skb->len;
- /* Take off the VLAN header (4 bytes currently) */
skb_pull_rcsum(skb, VLAN_HLEN);
- /*
- * Deal with ingress priority mapping.
- */
skb->priority = vlan_get_ingress_priority(skb->dev,
ntohs(vhdr->h_vlan_TCI));
pr_debug("%s: priority: %u for TCI: %hu\n",
__FUNCTION__, skb->priority, ntohs(vhdr->h_vlan_TCI));
- /* The ethernet driver already did the pkt_type calculations
- * for us...
- */
switch (skb->pkt_type) {
case PACKET_BROADCAST: /* Yeah, stats collect these together.. */
/* stats->broadcast ++; // no such counter :-( */
@@ -201,7 +173,6 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
*/
if (!compare_ether_addr(eth_hdr(skb)->h_dest,
skb->dev->dev_addr))
- /* It is for our (changed) MAC-address! */
skb->pkt_type = PACKET_HOST;
break;
default:
@@ -211,81 +182,45 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
/* Was a VLAN packet, grab the encapsulated protocol, which the layer
* three protocols care about.
*/
- /* proto = get_unaligned(&vhdr->h_vlan_encapsulated_proto); */
proto = vhdr->h_vlan_encapsulated_proto;
-
- skb->protocol = proto;
if (ntohs(proto) >= 1536) {
- /* place it back on the queue to be handled by
- * true layer 3 protocols.
- */
-
- /* See if we are configured to re-write the VLAN header
- * to make it look like ethernet...
- */
- skb = vlan_check_reorder_header(skb);
-
- /* Can be null if skb-clone fails when re-ordering */
- if (skb) {
- netif_rx(skb);
- } else {
- /* TODO: Add a more specific counter here. */
- stats->rx_errors++;
- }
- rcu_read_unlock();
- return 0;
+ skb->protocol = proto;
+ goto recv;
}
- rawp = skb->data;
-
/*
* This is a magic hack to spot IPX packets. Older Novell breaks
* the protocol design and runs IPX over 802.3 without an 802.2 LLC
* layer. We look for FFFF which isn't a used 802.2 SSAP/DSAP. This
* won't work for fault tolerant netware but does for the rest.
*/
+ rawp = skb->data;
if (*(unsigned short *)rawp == 0xFFFF) {
skb->protocol = htons(ETH_P_802_3);
- /* place it back on the queue to be handled by true layer 3
- * protocols. */
-
- /* See if we are configured to re-write the VLAN header
- * to make it look like ethernet...
- */
- skb = vlan_check_reorder_header(skb);
-
- /* Can be null if skb-clone fails when re-ordering */
- if (skb) {
- netif_rx(skb);
- } else {
- /* TODO: Add a more specific counter here. */
- stats->rx_errors++;
- }
- rcu_read_unlock();
- return 0;
+ goto recv;
}
/*
* Real 802.2 LLC
*/
skb->protocol = htons(ETH_P_802_2);
- /* place it back on the queue to be handled by upper layer protocols.
- */
- /* See if we are configured to re-write the VLAN header
- * to make it look like ethernet...
- */
+recv:
skb = vlan_check_reorder_header(skb);
-
- /* Can be null if skb-clone fails when re-ordering */
- if (skb) {
- netif_rx(skb);
- } else {
- /* TODO: Add a more specific counter here. */
+ if (!skb) {
stats->rx_errors++;
+ goto err_unlock;
}
+
+ netif_rx(skb);
rcu_read_unlock();
- return 0;
+ return NET_RX_SUCCESS;
+
+err_unlock:
+ rcu_read_unlock();
+err_free:
+ kfree_skb(skb);
+ return NET_RX_DROP;
}
static inline unsigned short
^ permalink raw reply related
* [VLAN 18/18]: Move protocol determination to seperate function
From: Patrick McHardy @ 2008-01-20 17:11 UTC (permalink / raw)
To: davem; +Cc: netdev, Patrick McHardy
In-Reply-To: <20080120171117.7980.67072.sendpatchset@localhost.localdomain>
[VLAN]: Move protocol determination to seperate function
I think, that we can make this code flow easier to understand
by introducing the vlan_set_encap_proto() function (I hope the
name is good) to setup the skb proto and merge the paths calling
netif_rx() together.
[Patrick: Modified to apply on top of my previous patches]
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit 0e185e8a940c2780362ff815cfe638e7d1269972
tree 62b8568718057b7a12375c34af01d95bae463240
parent c314238cb2135e4bb812487ed47652a5e2e4b748
author Pavel Emelyanov <xemul@openvz.org> Sun, 20 Jan 2008 17:37:32 +0100
committer Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 17:37:32 +0100
net/8021q/vlan_dev.c | 63 ++++++++++++++++++++++++++++----------------------
1 files changed, 35 insertions(+), 28 deletions(-)
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 57799af..8059fa4 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -89,6 +89,40 @@ static inline struct sk_buff *vlan_check_reorder_header(struct sk_buff *skb)
return skb;
}
+static inline void vlan_set_encap_proto(struct sk_buff *skb,
+ struct vlan_hdr *vhdr)
+{
+ __be16 proto;
+ unsigned char *rawp;
+
+ /*
+ * Was a VLAN packet, grab the encapsulated protocol, which the layer
+ * three protocols care about.
+ */
+
+ proto = vhdr->h_vlan_encapsulated_proto;
+ if (ntohs(proto) >= 1536) {
+ skb->protocol = proto;
+ return;
+ }
+
+ rawp = skb->data;
+ if (*(unsigned short *)rawp == 0xFFFF)
+ /*
+ * This is a magic hack to spot IPX packets. Older Novell
+ * breaks the protocol design and runs IPX over 802.3 without
+ * an 802.2 LLC layer. We look for FFFF which isn't a used
+ * 802.2 SSAP/DSAP. This won't work for fault tolerant netware
+ * but does for the rest.
+ */
+ skb->protocol = htons(ETH_P_802_3);
+ else
+ /*
+ * Real 802.2 LLC
+ */
+ skb->protocol = htons(ETH_P_802_2);
+}
+
/*
* 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.
@@ -114,12 +148,10 @@ static inline struct sk_buff *vlan_check_reorder_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)
{
- unsigned char *rawp;
struct vlan_hdr *vhdr;
unsigned short vid;
struct net_device_stats *stats;
unsigned short vlan_TCI;
- __be16 proto;
if (dev->nd_net != &init_net)
goto err_free;
@@ -179,33 +211,8 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
break;
}
- /* Was a VLAN packet, grab the encapsulated protocol, which the layer
- * three protocols care about.
- */
- proto = vhdr->h_vlan_encapsulated_proto;
- if (ntohs(proto) >= 1536) {
- skb->protocol = proto;
- goto recv;
- }
-
- /*
- * This is a magic hack to spot IPX packets. Older Novell breaks
- * the protocol design and runs IPX over 802.3 without an 802.2 LLC
- * layer. We look for FFFF which isn't a used 802.2 SSAP/DSAP. This
- * won't work for fault tolerant netware but does for the rest.
- */
- rawp = skb->data;
- if (*(unsigned short *)rawp == 0xFFFF) {
- skb->protocol = htons(ETH_P_802_3);
- goto recv;
- }
-
- /*
- * Real 802.2 LLC
- */
- skb->protocol = htons(ETH_P_802_2);
+ vlan_set_encap_proto(skb, vhdr);
-recv:
skb = vlan_check_reorder_header(skb);
if (!skb) {
stats->rx_errors++;
^ permalink raw reply related
* [NET]: rtnl_link: fix use-after-free
From: Patrick McHardy @ 2008-01-20 17:21 UTC (permalink / raw)
To: David S. Miller; +Cc: Pavel Emelianov, Linux Netdev List
[-- Attachment #1: Type: text/plain, Size: 0 bytes --]
[-- Attachment #2: x --]
[-- Type: text/plain, Size: 2248 bytes --]
commit 6e470bd53fb50632fe1878bb74bb8531a21b6731
Author: Patrick McHardy <kaber@trash.net>
Date: Sun Jan 20 18:19:15 2008 +0100
[NET]: rtnl_link: fix use-after-free
When unregistering the rtnl_link_ops, all existing devices using
the ops are destroyed. With nested devices this may lead to a
use-after-free despite the use of for_each_netdev_safe() in case
the upper device is next in the device list and is destroyed
by the NETDEV_UNREGISTER notifier.
The easy fix is to restart scanning the device list after removing
a device. Alternatively we could add new devices to the front of
the list to avoid having dependant devices follow the device they
depend on. A third option would be to only restart scanning if
dev->iflink of the next device matches dev->ifindex of the current
one. For now this seems like the safest solution.
With this patch, the veth rtnl_link_ops unregistration can use
rtnl_link_unregister() directly since it now also handles destruction
of multiple devices at once.
Signed-off-by: Patrick McHardy <kaber@trash.net>
diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 43af9e9..3f67a29 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -459,19 +459,7 @@ static __init int veth_init(void)
static __exit void veth_exit(void)
{
- struct veth_priv *priv, *next;
-
- rtnl_lock();
- /*
- * cannot trust __rtnl_link_unregister() to unregister all
- * devices, as each ->dellink call will remove two devices
- * from the list at once.
- */
- list_for_each_entry_safe(priv, next, &veth_list, list)
- veth_dellink(priv->dev);
-
- __rtnl_link_unregister(&veth_link_ops);
- rtnl_unlock();
+ rtnl_link_unregister(&veth_link_ops);
}
module_init(veth_init);
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index e1ba26f..fed95a3 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -308,9 +308,12 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
struct net *net;
for_each_net(net) {
+restart:
for_each_netdev_safe(net, dev, n) {
- if (dev->rtnl_link_ops == ops)
+ if (dev->rtnl_link_ops == ops) {
ops->dellink(dev);
+ goto restart;
+ }
}
}
list_del(&ops->list);
^ permalink raw reply related
* [PATCH] ipv6: addrconf sparse warnings
From: Stephen Hemminger @ 2008-01-20 18:01 UTC (permalink / raw)
To: David Miller,
YOSHIFUJI Hideaki / 吉藤英明; +Cc: netdev
Get rid of a couple of sparse warnings in IPV6 addrconf code.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/net/ipv6/addrconf.c 2008-01-20 09:38:06.000000000 -0800
+++ b/net/ipv6/addrconf.c 2008-01-20 09:57:40.000000000 -0800
@@ -1900,7 +1900,7 @@ int addrconf_set_dstaddr(void __user *ar
p.iph.ihl = 5;
p.iph.protocol = IPPROTO_IPV6;
p.iph.ttl = 64;
- ifr.ifr_ifru.ifru_data = (void __user *)&p;
+ ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
oldfs = get_fs(); set_fs(KERNEL_DS);
err = dev->do_ioctl(dev, &ifr, SIOCADDTUNNEL);
@@ -2799,6 +2799,7 @@ static struct inet6_ifaddr *if6_get_idx(
}
static void *if6_seq_start(struct seq_file *seq, loff_t *pos)
+ __acquires(addrconf_hash_lock)
{
read_lock_bh(&addrconf_hash_lock);
return if6_get_idx(seq, *pos);
@@ -2814,6 +2815,7 @@ static void *if6_seq_next(struct seq_fil
}
static void if6_seq_stop(struct seq_file *seq, void *v)
+ __releases(addrconf_hash_lock)
{
read_unlock_bh(&addrconf_hash_lock);
}
^ permalink raw reply
* [RFC NET_SCHED 00/05]: Pseudo-classful qdisc consolidation
From: Patrick McHardy @ 2008-01-20 18:28 UTC (permalink / raw)
To: netdev; +Cc: Patrick McHardy
These patches contain some preparatory cleanups and consolidate the
Qdisc_class_ops for pseudo-classful qdiscs. The main reason for
RFC is that the naming is not particular appealing (both qdisc_q_...
and sch_pseudo_classful), suggestions for better names are welcome.
include/net/pkt_sched.h | 4 +
include/net/sch_generic.h | 78 +++++++++++++-------
net/core/dev.c | 4 +-
net/sched/Kconfig | 6 ++
net/sched/Makefile | 1 +
net/sched/sch_atm.c | 17 +++--
net/sched/sch_blackhole.c | 2 +-
net/sched/sch_cbq.c | 18 +++--
net/sched/sch_dsmark.c | 11 +--
net/sched/sch_fifo.c | 62 +++++++++++++---
net/sched/sch_generic.c | 12 ++--
net/sched/sch_gred.c | 18 ++--
net/sched/sch_hfsc.c | 12 ++--
net/sched/sch_htb.c | 11 ++-
net/sched/sch_netem.c | 157 +++++++--------------------------------
net/sched/sch_prio.c | 13 ++-
net/sched/sch_pseudo_classful.c | 101 +++++++++++++++++++++++++
net/sched/sch_red.c | 152 ++++++--------------------------------
net/sched/sch_sfq.c | 2 +-
net/sched/sch_tbf.c | 150 +++++--------------------------------
20 files changed, 347 insertions(+), 484 deletions(-)
create mode 100644 net/sched/sch_pseudo_classful.c
Patrick McHardy (5):
[NET_SCHED]: Consolidate default fifo setup
[NET_SCHED]: Rename qdisc helpers for built-in queue
[NET_SCHED]: Introduce child qdisc helpers
[NET_SCHED]: Use qdisc helpers
[NET_SCHED]: Consolidate class ops for pseudo classful qdisc
^ permalink raw reply
* [RFC NET_SCHED 01/05]: Consolidate default fifo setup
From: Patrick McHardy @ 2008-01-20 18:28 UTC (permalink / raw)
To: netdev; +Cc: Patrick McHardy
In-Reply-To: <20080120182848.10972.46380.sendpatchset@localhost.localdomain>
commit e56c933715900be7c6ad30bd07d342d31c457112
Author: Patrick McHardy <kaber@trash.net>
Date: Wed Jan 2 21:35:19 2008 +0100
[NET_SCHED]: Consolidate default fifo setup
Signed-off-by: Patrick McHardy <kaber@trash.net>
diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h
index ab61809..9d06d2d 100644
--- a/include/net/pkt_sched.h
+++ b/include/net/pkt_sched.h
@@ -72,6 +72,10 @@ extern void qdisc_watchdog_cancel(struct qdisc_watchdog *wd);
extern struct Qdisc_ops pfifo_qdisc_ops;
extern struct Qdisc_ops bfifo_qdisc_ops;
+extern int fifo_set_limit(struct Qdisc *q, unsigned int limit);
+extern struct Qdisc *fifo_create_dflt(struct Qdisc *sch, struct Qdisc_ops *ops,
+ unsigned int limit);
+
extern int register_qdisc(struct Qdisc_ops *qops);
extern int unregister_qdisc(struct Qdisc_ops *qops);
extern struct Qdisc *qdisc_lookup(struct net_device *dev, u32 handle);
diff --git a/net/sched/sch_fifo.c b/net/sched/sch_fifo.c
index d71dbfc..f9bf58b 100644
--- a/net/sched/sch_fifo.c
+++ b/net/sched/sch_fifo.c
@@ -108,3 +108,45 @@ struct Qdisc_ops bfifo_qdisc_ops __read_mostly = {
EXPORT_SYMBOL(bfifo_qdisc_ops);
EXPORT_SYMBOL(pfifo_qdisc_ops);
+
+/* Pass size change message down to embedded FIFO */
+int fifo_set_limit(struct Qdisc *q, unsigned int limit)
+{
+ struct rtattr *rta;
+ int ret = -ENOMEM;
+
+ /* Hack to avoid sending change message to non-FIFO */
+ if (strncmp(q->ops->id + 1, "fifo", 4) != 0)
+ return 0;
+
+ rta = kmalloc(RTA_LENGTH(sizeof(struct tc_fifo_qopt)), GFP_KERNEL);
+ if (rta) {
+ rta->rta_type = RTM_NEWQDISC;
+ rta->rta_len = RTA_LENGTH(sizeof(struct tc_fifo_qopt));
+ ((struct tc_fifo_qopt *)RTA_DATA(rta))->limit = limit;
+
+ ret = q->ops->change(q, rta);
+ kfree(rta);
+ }
+ return ret;
+}
+EXPORT_SYMBOL(fifo_set_limit);
+
+struct Qdisc *fifo_create_dflt(struct Qdisc *sch, struct Qdisc_ops *ops,
+ unsigned int limit)
+{
+ struct Qdisc *q;
+ int err = -ENOMEM;
+
+ q = qdisc_create_dflt(sch->dev, ops, TC_H_MAKE(sch->handle, 1));
+ if (q) {
+ err = fifo_set_limit(q, limit);
+ if (err < 0) {
+ qdisc_destroy(q);
+ q = NULL;
+ }
+ }
+
+ return q ? : ERR_PTR(err);
+}
+EXPORT_SYMBOL(fifo_create_dflt);
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index 6c344ad..5342a2f 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -310,28 +310,6 @@ static void netem_reset(struct Qdisc *sch)
qdisc_watchdog_cancel(&q->watchdog);
}
-/* Pass size change message down to embedded FIFO */
-static int set_fifo_limit(struct Qdisc *q, int limit)
-{
- struct rtattr *rta;
- int ret = -ENOMEM;
-
- /* Hack to avoid sending change message to non-FIFO */
- if (strncmp(q->ops->id + 1, "fifo", 4) != 0)
- return 0;
-
- rta = kmalloc(RTA_LENGTH(sizeof(struct tc_fifo_qopt)), GFP_KERNEL);
- if (rta) {
- rta->rta_type = RTM_NEWQDISC;
- rta->rta_len = RTA_LENGTH(sizeof(struct tc_fifo_qopt));
- ((struct tc_fifo_qopt *)RTA_DATA(rta))->limit = limit;
-
- ret = q->ops->change(q, rta);
- kfree(rta);
- }
- return ret;
-}
-
/*
* Distribution data is a variable size payload containing
* signed 16 bit values.
@@ -414,7 +392,7 @@ static int netem_change(struct Qdisc *sch, struct rtattr *opt)
return -EINVAL;
qopt = RTA_DATA(opt);
- ret = set_fifo_limit(q->qdisc, qopt->limit);
+ ret = fifo_set_limit(q->qdisc, qopt->limit);
if (ret) {
pr_debug("netem: can't set fifo limit\n");
return ret;
diff --git a/net/sched/sch_red.c b/net/sched/sch_red.c
index f1e9647..699f83d 100644
--- a/net/sched/sch_red.c
+++ b/net/sched/sch_red.c
@@ -174,33 +174,6 @@ static void red_destroy(struct Qdisc *sch)
qdisc_destroy(q->qdisc);
}
-static struct Qdisc *red_create_dflt(struct Qdisc *sch, u32 limit)
-{
- struct Qdisc *q;
- struct rtattr *rta;
- int ret;
-
- q = qdisc_create_dflt(sch->dev, &bfifo_qdisc_ops,
- TC_H_MAKE(sch->handle, 1));
- if (q) {
- rta = kmalloc(RTA_LENGTH(sizeof(struct tc_fifo_qopt)),
- GFP_KERNEL);
- if (rta) {
- rta->rta_type = RTM_NEWQDISC;
- rta->rta_len = RTA_LENGTH(sizeof(struct tc_fifo_qopt));
- ((struct tc_fifo_qopt *)RTA_DATA(rta))->limit = limit;
-
- ret = q->ops->change(q, rta);
- kfree(rta);
-
- if (ret == 0)
- return q;
- }
- qdisc_destroy(q);
- }
- return NULL;
-}
-
static int red_change(struct Qdisc *sch, struct rtattr *opt)
{
struct red_sched_data *q = qdisc_priv(sch);
@@ -220,9 +193,9 @@ static int red_change(struct Qdisc *sch, struct rtattr *opt)
ctl = RTA_DATA(tb[TCA_RED_PARMS-1]);
if (ctl->limit > 0) {
- child = red_create_dflt(sch, ctl->limit);
- if (child == NULL)
- return -ENOMEM;
+ child = fifo_create_dflt(sch, &bfifo_qdisc_ops, ctl->limit);
+ if (IS_ERR(child))
+ return PTR_ERR(child);
}
sch_tree_lock(sch);
diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
index d88fea9..bd34355 100644
--- a/net/sched/sch_tbf.c
+++ b/net/sched/sch_tbf.c
@@ -242,33 +242,6 @@ static void tbf_reset(struct Qdisc* sch)
qdisc_watchdog_cancel(&q->watchdog);
}
-static struct Qdisc *tbf_create_dflt_qdisc(struct Qdisc *sch, u32 limit)
-{
- struct Qdisc *q;
- struct rtattr *rta;
- int ret;
-
- q = qdisc_create_dflt(sch->dev, &bfifo_qdisc_ops,
- TC_H_MAKE(sch->handle, 1));
- if (q) {
- rta = kmalloc(RTA_LENGTH(sizeof(struct tc_fifo_qopt)), GFP_KERNEL);
- if (rta) {
- rta->rta_type = RTM_NEWQDISC;
- rta->rta_len = RTA_LENGTH(sizeof(struct tc_fifo_qopt));
- ((struct tc_fifo_qopt *)RTA_DATA(rta))->limit = limit;
-
- ret = q->ops->change(q, rta);
- kfree(rta);
-
- if (ret == 0)
- return q;
- }
- qdisc_destroy(q);
- }
-
- return NULL;
-}
-
static int tbf_change(struct Qdisc* sch, struct rtattr *opt)
{
int err = -EINVAL;
@@ -312,8 +285,9 @@ static int tbf_change(struct Qdisc* sch, struct rtattr *opt)
goto done;
if (qopt->limit > 0) {
- if ((child = tbf_create_dflt_qdisc(sch, qopt->limit)) == NULL)
- goto done;
+ child = fifo_create_dflt(sch, &bfifo_qdisc_ops, qopt->limit);
+ if (IS_ERR(child))
+ return PTR_ERR(child);
}
sch_tree_lock(sch);
^ permalink raw reply related
* [RFC NET_SCHED 02/05]: Rename qdisc helpers for built-in queue
From: Patrick McHardy @ 2008-01-20 18:28 UTC (permalink / raw)
To: netdev; +Cc: Patrick McHardy
In-Reply-To: <20080120182848.10972.46380.sendpatchset@localhost.localdomain>
commit c1f4198dd24ce854b7d55d0ed23a61d36d7defc9
Author: Patrick McHardy <kaber@trash.net>
Date: Wed Jan 2 21:35:21 2008 +0100
[NET_SCHED]: Rename qdisc helpers for built-in queue
Rename all helper functions dealing with the built-in queue of
struct Qdisc (sch->q) to qdisc_q_... to make the naming more
consistent and avoid naming clashes with the next patch, which
introduces a few simple helpers that should logically use those
names.
Signed-off-by: Patrick McHardy <kaber@trash.net>
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 60b4b35..3ade673 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -180,8 +180,8 @@ extern struct Qdisc *qdisc_create_dflt(struct net_device *dev,
extern void tcf_destroy(struct tcf_proto *tp);
extern void tcf_destroy_chain(struct tcf_proto *fl);
-static inline int __qdisc_enqueue_tail(struct sk_buff *skb, struct Qdisc *sch,
- struct sk_buff_head *list)
+static inline int __qdisc_q_enqueue_tail(struct sk_buff *skb, struct Qdisc *sch,
+ struct sk_buff_head *list)
{
__skb_queue_tail(list, skb);
sch->qstats.backlog += skb->len;
@@ -191,13 +191,13 @@ static inline int __qdisc_enqueue_tail(struct sk_buff *skb, struct Qdisc *sch,
return NET_XMIT_SUCCESS;
}
-static inline int qdisc_enqueue_tail(struct sk_buff *skb, struct Qdisc *sch)
+static inline int qdisc_q_enqueue_tail(struct sk_buff *skb, struct Qdisc *sch)
{
- return __qdisc_enqueue_tail(skb, sch, &sch->q);
+ return __qdisc_q_enqueue_tail(skb, sch, &sch->q);
}
-static inline struct sk_buff *__qdisc_dequeue_head(struct Qdisc *sch,
- struct sk_buff_head *list)
+static inline struct sk_buff *__qdisc_q_dequeue_head(struct Qdisc *sch,
+ struct sk_buff_head *list)
{
struct sk_buff *skb = __skb_dequeue(list);
@@ -207,13 +207,13 @@ static inline struct sk_buff *__qdisc_dequeue_head(struct Qdisc *sch,
return skb;
}
-static inline struct sk_buff *qdisc_dequeue_head(struct Qdisc *sch)
+static inline struct sk_buff *qdisc_q_dequeue_head(struct Qdisc *sch)
{
- return __qdisc_dequeue_head(sch, &sch->q);
+ return __qdisc_q_dequeue_head(sch, &sch->q);
}
-static inline struct sk_buff *__qdisc_dequeue_tail(struct Qdisc *sch,
- struct sk_buff_head *list)
+static inline struct sk_buff *__qdisc_q_dequeue_tail(struct Qdisc *sch,
+ struct sk_buff_head *list)
{
struct sk_buff *skb = __skb_dequeue_tail(list);
@@ -223,13 +223,13 @@ static inline struct sk_buff *__qdisc_dequeue_tail(struct Qdisc *sch,
return skb;
}
-static inline struct sk_buff *qdisc_dequeue_tail(struct Qdisc *sch)
+static inline struct sk_buff *qdisc_q_dequeue_tail(struct Qdisc *sch)
{
- return __qdisc_dequeue_tail(sch, &sch->q);
+ return __qdisc_q_dequeue_tail(sch, &sch->q);
}
-static inline int __qdisc_requeue(struct sk_buff *skb, struct Qdisc *sch,
- struct sk_buff_head *list)
+static inline int __qdisc_q_requeue(struct sk_buff *skb, struct Qdisc *sch,
+ struct sk_buff_head *list)
{
__skb_queue_head(list, skb);
sch->qstats.backlog += skb->len;
@@ -238,13 +238,13 @@ static inline int __qdisc_requeue(struct sk_buff *skb, struct Qdisc *sch,
return NET_XMIT_SUCCESS;
}
-static inline int qdisc_requeue(struct sk_buff *skb, struct Qdisc *sch)
+static inline int qdisc_q_requeue(struct sk_buff *skb, struct Qdisc *sch)
{
- return __qdisc_requeue(skb, sch, &sch->q);
+ return __qdisc_q_requeue(skb, sch, &sch->q);
}
-static inline void __qdisc_reset_queue(struct Qdisc *sch,
- struct sk_buff_head *list)
+static inline void __qdisc_q_reset(struct Qdisc *sch,
+ struct sk_buff_head *list)
{
/*
* We do not know the backlog in bytes of this list, it
@@ -253,16 +253,16 @@ static inline void __qdisc_reset_queue(struct Qdisc *sch,
skb_queue_purge(list);
}
-static inline void qdisc_reset_queue(struct Qdisc *sch)
+static inline void qdisc_q_reset(struct Qdisc *sch)
{
- __qdisc_reset_queue(sch, &sch->q);
+ __qdisc_q_reset(sch, &sch->q);
sch->qstats.backlog = 0;
}
-static inline unsigned int __qdisc_queue_drop(struct Qdisc *sch,
- struct sk_buff_head *list)
+static inline unsigned int __qdisc_q_drop(struct Qdisc *sch,
+ struct sk_buff_head *list)
{
- struct sk_buff *skb = __qdisc_dequeue_tail(sch, list);
+ struct sk_buff *skb = __qdisc_q_dequeue_tail(sch, list);
if (likely(skb != NULL)) {
unsigned int len = skb->len;
@@ -273,9 +273,9 @@ static inline unsigned int __qdisc_queue_drop(struct Qdisc *sch,
return 0;
}
-static inline unsigned int qdisc_queue_drop(struct Qdisc *sch)
+static inline unsigned int qdisc_q_drop(struct Qdisc *sch)
{
- return __qdisc_queue_drop(sch, &sch->q);
+ return __qdisc_q_drop(sch, &sch->q);
}
static inline int qdisc_drop(struct sk_buff *skb, struct Qdisc *sch)
diff --git a/net/sched/sch_fifo.c b/net/sched/sch_fifo.c
index f9bf58b..e4a4dc2 100644
--- a/net/sched/sch_fifo.c
+++ b/net/sched/sch_fifo.c
@@ -28,7 +28,7 @@ static int bfifo_enqueue(struct sk_buff *skb, struct Qdisc* sch)
struct fifo_sched_data *q = qdisc_priv(sch);
if (likely(sch->qstats.backlog + skb->len <= q->limit))
- return qdisc_enqueue_tail(skb, sch);
+ return qdisc_q_enqueue_tail(skb, sch);
return qdisc_reshape_fail(skb, sch);
}
@@ -38,7 +38,7 @@ static int pfifo_enqueue(struct sk_buff *skb, struct Qdisc* sch)
struct fifo_sched_data *q = qdisc_priv(sch);
if (likely(skb_queue_len(&sch->q) < q->limit))
- return qdisc_enqueue_tail(skb, sch);
+ return qdisc_q_enqueue_tail(skb, sch);
return qdisc_reshape_fail(skb, sch);
}
@@ -82,11 +82,11 @@ struct Qdisc_ops pfifo_qdisc_ops __read_mostly = {
.id = "pfifo",
.priv_size = sizeof(struct fifo_sched_data),
.enqueue = pfifo_enqueue,
- .dequeue = qdisc_dequeue_head,
- .requeue = qdisc_requeue,
- .drop = qdisc_queue_drop,
+ .dequeue = qdisc_q_dequeue_head,
+ .requeue = qdisc_q_requeue,
+ .drop = qdisc_q_drop,
.init = fifo_init,
- .reset = qdisc_reset_queue,
+ .reset = qdisc_q_reset,
.change = fifo_init,
.dump = fifo_dump,
.owner = THIS_MODULE,
@@ -96,11 +96,11 @@ struct Qdisc_ops bfifo_qdisc_ops __read_mostly = {
.id = "bfifo",
.priv_size = sizeof(struct fifo_sched_data),
.enqueue = bfifo_enqueue,
- .dequeue = qdisc_dequeue_head,
- .requeue = qdisc_requeue,
- .drop = qdisc_queue_drop,
+ .dequeue = qdisc_q_dequeue_head,
+ .requeue = qdisc_q_requeue,
+ .drop = qdisc_q_drop,
.init = fifo_init,
- .reset = qdisc_reset_queue,
+ .reset = qdisc_q_reset,
.change = fifo_init,
.dump = fifo_dump,
.owner = THIS_MODULE,
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 9be2f15..6afd59e 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -344,7 +344,7 @@ static int pfifo_fast_enqueue(struct sk_buff *skb, struct Qdisc* qdisc)
if (skb_queue_len(list) < qdisc->dev->tx_queue_len) {
qdisc->q.qlen++;
- return __qdisc_enqueue_tail(skb, qdisc, list);
+ return __qdisc_q_enqueue_tail(skb, qdisc, list);
}
return qdisc_drop(skb, qdisc);
@@ -358,7 +358,7 @@ static struct sk_buff *pfifo_fast_dequeue(struct Qdisc* qdisc)
for (prio = 0; prio < PFIFO_FAST_BANDS; prio++) {
if (!skb_queue_empty(list + prio)) {
qdisc->q.qlen--;
- return __qdisc_dequeue_head(qdisc, list + prio);
+ return __qdisc_q_dequeue_head(qdisc, list + prio);
}
}
@@ -368,7 +368,7 @@ static struct sk_buff *pfifo_fast_dequeue(struct Qdisc* qdisc)
static int pfifo_fast_requeue(struct sk_buff *skb, struct Qdisc* qdisc)
{
qdisc->q.qlen++;
- return __qdisc_requeue(skb, qdisc, prio2list(skb, qdisc));
+ return __qdisc_q_requeue(skb, qdisc, prio2list(skb, qdisc));
}
static void pfifo_fast_reset(struct Qdisc* qdisc)
@@ -377,7 +377,7 @@ static void pfifo_fast_reset(struct Qdisc* qdisc)
struct sk_buff_head *list = qdisc_priv(qdisc);
for (prio = 0; prio < PFIFO_FAST_BANDS; prio++)
- __qdisc_reset_queue(qdisc, list + prio);
+ __qdisc_q_reset(qdisc, list + prio);
qdisc->qstats.backlog = 0;
qdisc->q.qlen = 0;
diff --git a/net/sched/sch_gred.c b/net/sched/sch_gred.c
index e2bcd66..d933565 100644
--- a/net/sched/sch_gred.c
+++ b/net/sched/sch_gred.c
@@ -165,7 +165,7 @@ static int gred_enqueue(struct sk_buff *skb, struct Qdisc* sch)
* allows for DP flows to be left untouched.
*/
if (skb_queue_len(&sch->q) < sch->dev->tx_queue_len)
- return qdisc_enqueue_tail(skb, sch);
+ return qdisc_q_enqueue_tail(skb, sch);
else
goto drop;
}
@@ -228,7 +228,7 @@ static int gred_enqueue(struct sk_buff *skb, struct Qdisc* sch)
if (q->backlog + skb->len <= q->limit) {
q->backlog += skb->len;
- return qdisc_enqueue_tail(skb, sch);
+ return qdisc_q_enqueue_tail(skb, sch);
}
q->stats.pdrop++;
@@ -257,7 +257,7 @@ static int gred_requeue(struct sk_buff *skb, struct Qdisc* sch)
q->backlog += skb->len;
}
- return qdisc_requeue(skb, sch);
+ return qdisc_q_requeue(skb, sch);
}
static struct sk_buff *gred_dequeue(struct Qdisc* sch)
@@ -265,7 +265,7 @@ static struct sk_buff *gred_dequeue(struct Qdisc* sch)
struct sk_buff *skb;
struct gred_sched *t = qdisc_priv(sch);
- skb = qdisc_dequeue_head(sch);
+ skb = qdisc_q_dequeue_head(sch);
if (skb) {
struct gred_sched_data *q;
@@ -297,7 +297,7 @@ static unsigned int gred_drop(struct Qdisc* sch)
struct sk_buff *skb;
struct gred_sched *t = qdisc_priv(sch);
- skb = qdisc_dequeue_tail(sch);
+ skb = qdisc_q_dequeue_tail(sch);
if (skb) {
unsigned int len = skb->len;
struct gred_sched_data *q;
@@ -332,7 +332,7 @@ static void gred_reset(struct Qdisc* sch)
int i;
struct gred_sched *t = qdisc_priv(sch);
- qdisc_reset_queue(sch);
+ qdisc_q_reset(sch);
for (i = 0; i < t->DPs; i++) {
struct gred_sched_data *q = t->tab[i];
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index 5342a2f..3ec4a81 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -470,7 +470,7 @@ static int tfifo_enqueue(struct sk_buff *nskb, struct Qdisc *sch)
/* Optimize for add at tail */
if (likely(skb_queue_empty(list) || tnext >= q->oldest)) {
q->oldest = tnext;
- return qdisc_enqueue_tail(nskb, sch);
+ return qdisc_q_enqueue_tail(nskb, sch);
}
skb_queue_reverse_walk(list, skb) {
@@ -526,11 +526,11 @@ static struct Qdisc_ops tfifo_qdisc_ops __read_mostly = {
.id = "tfifo",
.priv_size = sizeof(struct fifo_sched_data),
.enqueue = tfifo_enqueue,
- .dequeue = qdisc_dequeue_head,
- .requeue = qdisc_requeue,
- .drop = qdisc_queue_drop,
+ .dequeue = qdisc_q_dequeue_head,
+ .requeue = qdisc_q_requeue,
+ .drop = qdisc_q_drop,
.init = tfifo_init,
- .reset = qdisc_reset_queue,
+ .reset = qdisc_q_reset,
.change = tfifo_init,
.dump = tfifo_dump,
};
^ permalink raw reply related
* [RFC NET_SCHED 03/05]: Introduce child qdisc helpers
From: Patrick McHardy @ 2008-01-20 18:28 UTC (permalink / raw)
To: netdev; +Cc: Patrick McHardy
In-Reply-To: <20080120182848.10972.46380.sendpatchset@localhost.localdomain>
commit a6d1954517202bffb14f5122756891d8c5b8e2e2
Author: Patrick McHardy <kaber@trash.net>
Date: Wed Jan 16 12:08:18 2008 +0100
[NET_SCHED]: Introduce child qdisc helpers
Introduce a few helpers to dispatch calls to child qdiscs without
repeating the qdisc argument every time.
Signed-off-by: Patrick McHardy <kaber@trash.net>
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 3ade673..decc339 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -180,6 +180,26 @@ extern struct Qdisc *qdisc_create_dflt(struct net_device *dev,
extern void tcf_destroy(struct tcf_proto *tp);
extern void tcf_destroy_chain(struct tcf_proto *fl);
+static inline int qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch)
+{
+ return sch->enqueue(skb, sch);
+}
+
+static inline struct sk_buff *qdisc_dequeue(struct Qdisc *sch)
+{
+ return sch->dequeue(sch);
+}
+
+static inline int qdisc_requeue(struct sk_buff *skb, struct Qdisc *sch)
+{
+ return sch->ops->requeue(skb, sch);
+}
+
+static inline unsigned int qdisc_drop(struct Qdisc *sch)
+{
+ return sch->ops->drop ? sch->ops->drop(sch) : 0;
+}
+
static inline int __qdisc_q_enqueue_tail(struct sk_buff *skb, struct Qdisc *sch,
struct sk_buff_head *list)
{
@@ -278,7 +298,7 @@ static inline unsigned int qdisc_q_drop(struct Qdisc *sch)
return __qdisc_q_drop(sch, &sch->q);
}
-static inline int qdisc_drop(struct sk_buff *skb, struct Qdisc *sch)
+static inline int qdisc_drop_skb(struct sk_buff *skb, struct Qdisc *sch)
{
kfree_skb(skb);
sch->qstats.drops++;
diff --git a/net/sched/sch_blackhole.c b/net/sched/sch_blackhole.c
index 507fb48..ac374eb 100644
--- a/net/sched/sch_blackhole.c
+++ b/net/sched/sch_blackhole.c
@@ -19,7 +19,7 @@
static int blackhole_enqueue(struct sk_buff *skb, struct Qdisc *sch)
{
- qdisc_drop(skb, sch);
+ qdisc_drop_skb(skb, sch);
return NET_XMIT_SUCCESS;
}
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 6afd59e..8e186e1 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -347,7 +347,7 @@ static int pfifo_fast_enqueue(struct sk_buff *skb, struct Qdisc* qdisc)
return __qdisc_q_enqueue_tail(skb, qdisc, list);
}
- return qdisc_drop(skb, qdisc);
+ return qdisc_drop_skb(skb, qdisc);
}
static struct sk_buff *pfifo_fast_dequeue(struct Qdisc* qdisc)
diff --git a/net/sched/sch_gred.c b/net/sched/sch_gred.c
index d933565..ca65e7c 100644
--- a/net/sched/sch_gred.c
+++ b/net/sched/sch_gred.c
@@ -233,10 +233,10 @@ static int gred_enqueue(struct sk_buff *skb, struct Qdisc* sch)
q->stats.pdrop++;
drop:
- return qdisc_drop(skb, sch);
+ return qdisc_drop_skb(skb, sch);
congestion_drop:
- qdisc_drop(skb, sch);
+ qdisc_drop_skb(skb, sch);
return NET_XMIT_CN;
}
@@ -316,7 +316,7 @@ static unsigned int gred_drop(struct Qdisc* sch)
red_start_of_idle_period(&q->parms);
}
- qdisc_drop(skb, sch);
+ qdisc_drop_skb(skb, sch);
return len;
}
diff --git a/net/sched/sch_red.c b/net/sched/sch_red.c
index 699f83d..acf06d9 100644
--- a/net/sched/sch_red.c
+++ b/net/sched/sch_red.c
@@ -104,7 +104,7 @@ static int red_enqueue(struct sk_buff *skb, struct Qdisc* sch)
return ret;
congestion_drop:
- qdisc_drop(skb, sch);
+ qdisc_drop_skb(skb, sch);
return NET_XMIT_CN;
}
diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c
index c58fa6e..0b46589 100644
--- a/net/sched/sch_sfq.c
+++ b/net/sched/sch_sfq.c
@@ -257,7 +257,7 @@ sfq_enqueue(struct sk_buff *skb, struct Qdisc* sch)
* i.e. drop _this_ packet.
*/
if (q->qs[x].qlen >= q->limit)
- return qdisc_drop(skb, sch);
+ return qdisc_drop_skb(skb, sch);
sch->qstats.backlog += skb->len;
__skb_queue_tail(&q->qs[x], skb);
^ permalink raw reply related
* [RFC NET_SCHED 04/05]: Use qdisc helpers
From: Patrick McHardy @ 2008-01-20 18:28 UTC (permalink / raw)
To: netdev; +Cc: Patrick McHardy
In-Reply-To: <20080120182848.10972.46380.sendpatchset@localhost.localdomain>
commit 8b0737e99efbf5b51f950d9fa95d69f96bf0a926
Author: Patrick McHardy <kaber@trash.net>
Date: Wed Jan 16 12:22:00 2008 +0100
[NET_SCHED]: Use qdisc helpers
Use the new qdisc helpers where possible. Also pull return value
assignments out of conditions and use proper NET_XMIT codes where
possible.
Signed-off-by: Patrick McHardy <kaber@trash.net>
diff --git a/net/core/dev.c b/net/core/dev.c
index 385b799..663031c 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1673,7 +1673,7 @@ gso:
if (q->enqueue) {
/* reset queue_mapping to zero */
skb_set_queue_mapping(skb, 0);
- rc = q->enqueue(skb, q);
+ rc = qdisc_enqueue(skb, q);
qdisc_run(dev);
spin_unlock(&dev->queue_lock);
@@ -1970,7 +1970,7 @@ static int ing_filter(struct sk_buff *skb)
spin_lock(&dev->ingress_lock);
if ((q = dev->qdisc_ingress) != NULL)
- result = q->enqueue(skb, q);
+ result = qdisc_enqueue(skb, q);
spin_unlock(&dev->ingress_lock);
return result;
diff --git a/net/sched/sch_atm.c b/net/sched/sch_atm.c
index d870a41..844774d 100644
--- a/net/sched/sch_atm.c
+++ b/net/sched/sch_atm.c
@@ -430,7 +430,8 @@ static int atm_tc_enqueue(struct sk_buff *skb, struct Qdisc *sch)
#endif
}
- if ((ret = flow->q->enqueue(skb, flow->q)) != 0) {
+ ret = qdisc_enqueue(skb, flow->q);
+ if (ret != NET_XMIT_SUCCESS) {
drop: __maybe_unused
sch->qstats.drops++;
if (flow)
@@ -478,9 +479,9 @@ static void sch_atm_dequeue(unsigned long data)
* If traffic is properly shaped, this won't generate nasty
* little bursts. Otherwise, it may ... (but that's okay)
*/
- while ((skb = flow->q->dequeue(flow->q))) {
+ while ((skb = qdisc_dequeue(flow->q))) {
if (!atm_may_send(flow->vcc, skb->truesize)) {
- (void)flow->q->ops->requeue(skb, flow->q);
+ qdisc_requeue(skb, flow->q);
break;
}
D2PRINTK("atm_tc_dequeue: sending on class %p\n", flow);
@@ -514,7 +515,7 @@ static struct sk_buff *atm_tc_dequeue(struct Qdisc *sch)
D2PRINTK("atm_tc_dequeue(sch %p,[qdisc %p])\n", sch, p);
tasklet_schedule(&p->task);
- skb = p->link.q->dequeue(p->link.q);
+ skb = qdisc_dequeue(p->link.q);
if (skb)
sch->q.qlen--;
return skb;
@@ -526,7 +527,7 @@ static int atm_tc_requeue(struct sk_buff *skb, struct Qdisc *sch)
int ret;
D2PRINTK("atm_tc_requeue(skb %p,sch %p,[qdisc %p])\n", skb, sch, p);
- ret = p->link.q->ops->requeue(skb, p->link.q);
+ ret = qdisc_requeue(skb, p->link.q);
if (!ret) {
sch->q.qlen++;
sch->qstats.requeues++;
@@ -544,9 +545,11 @@ static unsigned int atm_tc_drop(struct Qdisc *sch)
unsigned int len;
DPRINTK("atm_tc_drop(sch %p,[qdisc %p])\n", sch, p);
- for (flow = p->flows; flow; flow = flow->next)
- if (flow->q->ops->drop && (len = flow->q->ops->drop(flow->q)))
+ for (flow = p->flows; flow; flow = flow->next) {
+ len = qdisc_drop(flow->q);
+ if (len > 0)
return len;
+ }
return 0;
}
diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c
index bea123f..8731f51 100644
--- a/net/sched/sch_cbq.c
+++ b/net/sched/sch_cbq.c
@@ -396,7 +396,8 @@ cbq_enqueue(struct sk_buff *skb, struct Qdisc *sch)
#ifdef CONFIG_NET_CLS_ACT
cl->q->__parent = sch;
#endif
- if ((ret = cl->q->enqueue(skb, cl->q)) == NET_XMIT_SUCCESS) {
+ ret = qdisc_enqueue(skb, cl->q);
+ if (ret == NET_XMIT_SUCCESS) {
sch->q.qlen++;
sch->bstats.packets++;
sch->bstats.bytes+=len;
@@ -432,7 +433,8 @@ cbq_requeue(struct sk_buff *skb, struct Qdisc *sch)
q->rx_class = cl;
cl->q->__parent = sch;
#endif
- if ((ret = cl->q->ops->requeue(skb, cl->q)) == 0) {
+ ret = qdisc_requeue(skb, cl->q);
+ if (ret == NET_XMIT_SUCCESS) {
sch->q.qlen++;
sch->qstats.requeues++;
if (!cl->next_alive)
@@ -580,9 +582,8 @@ static void cbq_ovl_lowprio(struct cbq_class *cl)
static void cbq_ovl_drop(struct cbq_class *cl)
{
- if (cl->q->ops->drop)
- if (cl->q->ops->drop(cl->q))
- cl->qdisc->q.qlen--;
+ if (qdisc_drop(cl->q))
+ cl->qdisc->q.qlen--;
cl->xstats.overactions++;
cbq_ovl_classic(cl);
}
@@ -680,7 +681,7 @@ static int cbq_reshape_fail(struct sk_buff *skb, struct Qdisc *child)
q->rx_class = cl;
cl->q->__parent = sch;
- if (cl->q->enqueue(skb, cl->q) == 0) {
+ if (qdisc_enqueue(skb, cl->q) == NET_XMIT_SUCCESS) {
sch->q.qlen++;
sch->bstats.packets++;
sch->bstats.bytes+=len;
@@ -880,7 +881,7 @@ cbq_dequeue_prio(struct Qdisc *sch, int prio)
goto next_class;
}
- skb = cl->q->dequeue(cl->q);
+ skb = qdisc_dequeue(cl->q);
/* Class did not give us any skb :-(
It could occur even if cl->q->q.qlen != 0
@@ -1226,7 +1227,8 @@ static unsigned int cbq_drop(struct Qdisc* sch)
cl = cl_head;
do {
- if (cl->q->ops->drop && (len = cl->q->ops->drop(cl->q))) {
+ len = qdisc_drop(cl->q);
+ if (len > 0) {
sch->q.qlen--;
if (!cl->q->q.qlen)
cbq_deactivate_class(cl);
diff --git a/net/sched/sch_dsmark.c b/net/sched/sch_dsmark.c
index b9fe697..9bdb46e 100644
--- a/net/sched/sch_dsmark.c
+++ b/net/sched/sch_dsmark.c
@@ -257,7 +257,7 @@ static int dsmark_enqueue(struct sk_buff *skb,struct Qdisc *sch)
}
}
- err = p->q->enqueue(skb,p->q);
+ err = qdisc_enqueue(skb, p->q);
if (err != NET_XMIT_SUCCESS) {
sch->qstats.drops++;
return err;
@@ -278,7 +278,7 @@ static struct sk_buff *dsmark_dequeue(struct Qdisc *sch)
D2PRINTK("dsmark_dequeue(sch %p,[qdisc %p])\n", sch, p);
- skb = p->q->ops->dequeue(p->q);
+ skb = qdisc_dequeue(p->q);
if (skb == NULL)
return NULL;
@@ -319,7 +319,7 @@ static int dsmark_requeue(struct sk_buff *skb,struct Qdisc *sch)
D2PRINTK("dsmark_requeue(skb %p,sch %p,[qdisc %p])\n", skb, sch, p);
- err = p->q->ops->requeue(skb, p->q);
+ err = qdisc_requeue(skb, p->q);
if (err != NET_XMIT_SUCCESS) {
sch->qstats.drops++;
return err;
@@ -338,10 +338,7 @@ static unsigned int dsmark_drop(struct Qdisc *sch)
DPRINTK("dsmark_reset(sch %p,[qdisc %p])\n", sch, p);
- if (p->q->ops->drop == NULL)
- return 0;
-
- len = p->q->ops->drop(p->q);
+ len = qdisc_drop(p->q);
if (len)
sch->q.qlen--;
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 8e186e1..483f753 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -76,7 +76,7 @@ static inline struct sk_buff *dev_dequeue_skb(struct net_device *dev,
if ((skb = dev->gso_skb))
dev->gso_skb = NULL;
else
- skb = q->dequeue(q);
+ skb = qdisc_dequeue(q);
return skb;
}
diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c
index ff03327..71d7442 100644
--- a/net/sched/sch_hfsc.c
+++ b/net/sched/sch_hfsc.c
@@ -892,14 +892,14 @@ qdisc_peek_len(struct Qdisc *sch)
struct sk_buff *skb;
unsigned int len;
- skb = sch->dequeue(sch);
+ skb = qdisc_dequeue(sch);
if (skb == NULL) {
if (net_ratelimit())
printk("qdisc_peek_len: non work-conserving qdisc ?\n");
return 0;
}
len = skb->len;
- if (unlikely(sch->ops->requeue(skb, sch) != NET_XMIT_SUCCESS)) {
+ if (unlikely(qdisc_requeue(skb, sch) != NET_XMIT_SUCCESS)) {
if (net_ratelimit())
printk("qdisc_peek_len: failed to requeue\n");
qdisc_tree_decrease_qlen(sch, 1);
@@ -1574,7 +1574,7 @@ hfsc_enqueue(struct sk_buff *skb, struct Qdisc *sch)
}
len = skb->len;
- err = cl->qdisc->enqueue(skb, cl->qdisc);
+ err = qdisc_enqueue(skb, cl->qdisc);
if (unlikely(err != NET_XMIT_SUCCESS)) {
cl->qstats.drops++;
sch->qstats.drops++;
@@ -1630,7 +1630,7 @@ hfsc_dequeue(struct Qdisc *sch)
}
}
- skb = cl->qdisc->dequeue(cl->qdisc);
+ skb = qdisc_dequeue(cl->qdisc);
if (skb == NULL) {
if (net_ratelimit())
printk("HFSC: Non-work-conserving qdisc ?\n");
@@ -1681,8 +1681,8 @@ hfsc_drop(struct Qdisc *sch)
unsigned int len;
list_for_each_entry(cl, &q->droplist, dlist) {
- if (cl->qdisc->ops->drop != NULL &&
- (len = cl->qdisc->ops->drop(cl->qdisc)) > 0) {
+ len = qdisc_drop(cl->qdisc);
+ if (len > 0) {
if (cl->qdisc->q.qlen == 0) {
update_vf(cl, 0, 0);
set_passive(cl);
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 72beb66..ca3d4a5 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -592,7 +592,7 @@ static int htb_enqueue(struct sk_buff *skb, struct Qdisc *sch)
kfree_skb(skb);
return ret;
#endif
- } else if (cl->un.leaf.q->enqueue(skb, cl->un.leaf.q) !=
+ } else if (qdisc_enqueue(skb, cl->un.leaf.q) !=
NET_XMIT_SUCCESS) {
sch->qstats.drops++;
cl->qstats.drops++;
@@ -629,7 +629,7 @@ static int htb_requeue(struct sk_buff *skb, struct Qdisc *sch)
sch->qstats.drops++;
return NET_XMIT_CN;
}
- } else if (cl->un.leaf.q->ops->requeue(skb, cl->un.leaf.q) !=
+ } else if (qdisc_requeue(skb, cl->un.leaf.q) !=
NET_XMIT_SUCCESS) {
sch->qstats.drops++;
cl->qstats.drops++;
@@ -849,7 +849,7 @@ next:
goto next;
}
- skb = cl->un.leaf.q->dequeue(cl->un.leaf.q);
+ skb = qdisc_dequeue(cl->un.leaf.q);
if (likely(skb != NULL))
break;
if (!cl->warned) {
@@ -949,8 +949,9 @@ static unsigned int htb_drop(struct Qdisc *sch)
struct htb_class *cl = list_entry(p, struct htb_class,
un.leaf.drop_list);
unsigned int len;
- if (cl->un.leaf.q->ops->drop &&
- (len = cl->un.leaf.q->ops->drop(cl->un.leaf.q))) {
+
+ len = qdisc_drop(cl->un.leaf.q);
+ if (len) {
sch->q.qlen--;
if (!cl->un.leaf.q->q.qlen)
htb_deactivate(q, cl);
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index 3ec4a81..f6c24fd 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -184,7 +184,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
u32 dupsave = q->duplicate; /* prevent duplicating a dup... */
q->duplicate = 0;
- rootq->enqueue(skb2, rootq);
+ qdisc_enqueue(skb2, rootq);
q->duplicate = dupsave;
}
@@ -218,7 +218,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
now = psched_get_time();
cb->time_to_send = now + delay;
++q->counter;
- ret = q->qdisc->enqueue(skb, q->qdisc);
+ ret = qdisc_enqueue(skb, q->qdisc);
} else {
/*
* Do re-ordering by putting one out of N packets at the front
@@ -226,7 +226,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
*/
cb->time_to_send = psched_get_time();
q->counter = 0;
- ret = q->qdisc->ops->requeue(skb, q->qdisc);
+ ret = qdisc_requeue(skb, q->qdisc);
}
if (likely(ret == NET_XMIT_SUCCESS)) {
@@ -246,7 +246,8 @@ static int netem_requeue(struct sk_buff *skb, struct Qdisc *sch)
struct netem_sched_data *q = qdisc_priv(sch);
int ret;
- if ((ret = q->qdisc->ops->requeue(skb, q->qdisc)) == 0) {
+ ret = qdisc_requeue(skb, q->qdisc);
+ if (ret == NET_XMIT_SUCCESS) {
sch->q.qlen++;
sch->qstats.requeues++;
}
@@ -259,7 +260,8 @@ static unsigned int netem_drop(struct Qdisc* sch)
struct netem_sched_data *q = qdisc_priv(sch);
unsigned int len = 0;
- if (q->qdisc->ops->drop && (len = q->qdisc->ops->drop(q->qdisc)) != 0) {
+ len = qdisc_drop(q->qdisc);
+ if (len > 0) {
sch->q.qlen--;
sch->qstats.drops++;
}
@@ -275,7 +277,7 @@ static struct sk_buff *netem_dequeue(struct Qdisc *sch)
if (sch->flags & TCQ_F_THROTTLED)
return NULL;
- skb = q->qdisc->dequeue(q->qdisc);
+ skb = qdisc_dequeue(q->qdisc);
if (skb) {
const struct netem_skb_cb *cb
= (const struct netem_skb_cb *)skb->cb;
@@ -288,7 +290,7 @@ static struct sk_buff *netem_dequeue(struct Qdisc *sch)
return skb;
}
- if (unlikely(q->qdisc->ops->requeue(skb, q->qdisc) != NET_XMIT_SUCCESS)) {
+ if (unlikely(qdisc_requeue(skb, q->qdisc) != NET_XMIT_SUCCESS)) {
qdisc_tree_decrease_qlen(q->qdisc, 1);
sch->qstats.drops++;
printk(KERN_ERR "netem: %s could not requeue\n",
diff --git a/net/sched/sch_prio.c b/net/sched/sch_prio.c
index 2243aaa..800accc 100644
--- a/net/sched/sch_prio.c
+++ b/net/sched/sch_prio.c
@@ -86,7 +86,8 @@ prio_enqueue(struct sk_buff *skb, struct Qdisc *sch)
}
#endif
- if ((ret = qdisc->enqueue(skb, qdisc)) == NET_XMIT_SUCCESS) {
+ ret = qdisc_enqueue(skb, qdisc);
+ if (ret == NET_XMIT_SUCCESS) {
sch->bstats.bytes += skb->len;
sch->bstats.packets++;
sch->q.qlen++;
@@ -113,7 +114,8 @@ prio_requeue(struct sk_buff *skb, struct Qdisc* sch)
}
#endif
- if ((ret = qdisc->ops->requeue(skb, qdisc)) == NET_XMIT_SUCCESS) {
+ ret = qdisc_requeue(skb, qdisc);
+ if (ret == NET_XMIT_SUCCESS) {
sch->q.qlen++;
sch->qstats.requeues++;
return 0;
@@ -138,7 +140,7 @@ prio_dequeue(struct Qdisc* sch)
*/
if (!__netif_subqueue_stopped(sch->dev, (q->mq ? prio : 0))) {
qdisc = q->queues[prio];
- skb = qdisc->dequeue(qdisc);
+ skb = qdisc_dequeue(qdisc);
if (skb) {
sch->q.qlen--;
return skb;
@@ -168,7 +170,7 @@ static struct sk_buff *rr_dequeue(struct Qdisc* sch)
if (!__netif_subqueue_stopped(sch->dev,
(q->mq ? q->curband : 0))) {
qdisc = q->queues[q->curband];
- skb = qdisc->dequeue(qdisc);
+ skb = qdisc_dequeue(qdisc);
if (skb) {
sch->q.qlen--;
q->curband++;
@@ -193,7 +195,8 @@ static unsigned int prio_drop(struct Qdisc* sch)
for (prio = q->bands-1; prio >= 0; prio--) {
qdisc = q->queues[prio];
- if (qdisc->ops->drop && (len = qdisc->ops->drop(qdisc)) != 0) {
+ len = qdisc_drop(qdisc);
+ if (len > 0) {
sch->q.qlen--;
return len;
}
diff --git a/net/sched/sch_red.c b/net/sched/sch_red.c
index acf06d9..076f1ef 100644
--- a/net/sched/sch_red.c
+++ b/net/sched/sch_red.c
@@ -92,7 +92,7 @@ static int red_enqueue(struct sk_buff *skb, struct Qdisc* sch)
break;
}
- ret = child->enqueue(skb, child);
+ ret = qdisc_enqueue(skb, child);
if (likely(ret == NET_XMIT_SUCCESS)) {
sch->bstats.bytes += skb->len;
sch->bstats.packets++;
@@ -117,7 +117,7 @@ static int red_requeue(struct sk_buff *skb, struct Qdisc* sch)
if (red_is_idling(&q->parms))
red_end_of_idle_period(&q->parms);
- ret = child->ops->requeue(skb, child);
+ ret = qdisc_requeue(skb, child);
if (likely(ret == NET_XMIT_SUCCESS)) {
sch->qstats.requeues++;
sch->q.qlen++;
@@ -131,7 +131,7 @@ static struct sk_buff * red_dequeue(struct Qdisc* sch)
struct red_sched_data *q = qdisc_priv(sch);
struct Qdisc *child = q->qdisc;
- skb = child->dequeue(child);
+ skb = qdisc_dequeue(child);
if (skb)
sch->q.qlen--;
else if (!red_is_idling(&q->parms))
@@ -146,7 +146,8 @@ static unsigned int red_drop(struct Qdisc* sch)
struct Qdisc *child = q->qdisc;
unsigned int len;
- if (child->ops->drop && (len = child->ops->drop(child)) > 0) {
+ len = qdisc_drop(child);
+ if (len > 0) {
q->stats.other++;
sch->qstats.drops++;
sch->q.qlen--;
diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
index bd34355..5fd4dff 100644
--- a/net/sched/sch_tbf.c
+++ b/net/sched/sch_tbf.c
@@ -133,7 +133,8 @@ static int tbf_enqueue(struct sk_buff *skb, struct Qdisc* sch)
return NET_XMIT_DROP;
}
- if ((ret = q->qdisc->enqueue(skb, q->qdisc)) != 0) {
+ ret = qdisc_enqueue(skb, q->qdisc);
+ if (ret != NET_XMIT_SUCCESS) {
sch->qstats.drops++;
return ret;
}
@@ -149,7 +150,8 @@ static int tbf_requeue(struct sk_buff *skb, struct Qdisc* sch)
struct tbf_sched_data *q = qdisc_priv(sch);
int ret;
- if ((ret = q->qdisc->ops->requeue(skb, q->qdisc)) == 0) {
+ ret = qdisc_requeue(skb, q->qdisc);
+ if (ret == NET_XMIT_SUCCESS) {
sch->q.qlen++;
sch->qstats.requeues++;
}
@@ -162,7 +164,8 @@ static unsigned int tbf_drop(struct Qdisc* sch)
struct tbf_sched_data *q = qdisc_priv(sch);
unsigned int len = 0;
- if (q->qdisc->ops->drop && (len = q->qdisc->ops->drop(q->qdisc)) != 0) {
+ len = qdisc_drop(q->qdisc);
+ if (len > 0) {
sch->q.qlen--;
sch->qstats.drops++;
}
@@ -174,7 +177,7 @@ static struct sk_buff *tbf_dequeue(struct Qdisc* sch)
struct tbf_sched_data *q = qdisc_priv(sch);
struct sk_buff *skb;
- skb = q->qdisc->dequeue(q->qdisc);
+ skb = qdisc_dequeue(q->qdisc);
if (skb) {
psched_time_t now;
^ permalink raw reply related
* [RFC NET_SCHED 05/05]: Consolidate class ops for pseudo classful qdisc
From: Patrick McHardy @ 2008-01-20 18:28 UTC (permalink / raw)
To: netdev; +Cc: Patrick McHardy
In-Reply-To: <20080120182848.10972.46380.sendpatchset@localhost.localdomain>
commit e97ba18f7a8f9342fa06d0f5606a186b18e1d7f8
Author: Patrick McHardy <kaber@trash.net>
Date: Wed Jan 16 12:22:06 2008 +0100
[NET_SCHED]: Consolidate class ops for pseudo classful qdisc
Signed-off-by: Patrick McHardy <kaber@trash.net>
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index decc339..ca6e4de 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -351,4 +351,10 @@ static inline struct sk_buff *skb_act_clone(struct sk_buff *skb, gfp_t gfp_mask)
}
#endif
+struct pc_sched_data {
+ struct Qdisc *qdisc;
+};
+
+extern const struct Qdisc_class_ops pseudo_classful_ops;
+
#endif
diff --git a/net/sched/Kconfig b/net/sched/Kconfig
index f5ab54b..63882c5 100644
--- a/net/sched/Kconfig
+++ b/net/sched/Kconfig
@@ -43,6 +43,9 @@ if NET_SCHED
comment "Queueing/Scheduling"
+config NET_SCH_PC
+ tristate
+
config NET_SCH_CBQ
tristate "Class Based Queueing (CBQ)"
---help---
@@ -141,6 +144,7 @@ config NET_SCH_SFQ
config NET_SCH_TEQL
tristate "True Link Equalizer (TEQL)"
+ select NET_SCH_PC
---help---
Say Y here if you want to use the True Link Equalizer (TLE) packet
scheduling algorithm. This queueing discipline allows the combination
@@ -153,6 +157,7 @@ config NET_SCH_TEQL
config NET_SCH_TBF
tristate "Token Bucket Filter (TBF)"
+ select NET_SCH_PC
---help---
Say Y here if you want to use the Token Bucket Filter (TBF) packet
scheduling algorithm.
@@ -186,6 +191,7 @@ config NET_SCH_DSMARK
config NET_SCH_NETEM
tristate "Network emulator (NETEM)"
+ select NET_SCH_PC
---help---
Say Y if you want to emulate network delay, loss, and packet
re-ordering. This is often useful to simulate networks when
diff --git a/net/sched/Makefile b/net/sched/Makefile
index 81ecbe8..593bb3a 100644
--- a/net/sched/Makefile
+++ b/net/sched/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_NET_ACT_IPT) += act_ipt.o
obj-$(CONFIG_NET_ACT_NAT) += act_nat.o
obj-$(CONFIG_NET_ACT_PEDIT) += act_pedit.o
obj-$(CONFIG_NET_ACT_SIMP) += act_simple.o
+obj-$(CONFIG_NET_SCH_PC) += sch_pseudo_classful.o
obj-$(CONFIG_NET_SCH_FIFO) += sch_fifo.o
obj-$(CONFIG_NET_SCH_CBQ) += sch_cbq.o
obj-$(CONFIG_NET_SCH_HTB) += sch_htb.o
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index f6c24fd..2444a97 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -52,7 +52,8 @@
*/
struct netem_sched_data {
- struct Qdisc *qdisc;
+ struct pc_sched_data class;
+
struct qdisc_watchdog watchdog;
psched_tdiff_t latency;
@@ -218,7 +219,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
now = psched_get_time();
cb->time_to_send = now + delay;
++q->counter;
- ret = qdisc_enqueue(skb, q->qdisc);
+ ret = qdisc_enqueue(skb, q->class.qdisc);
} else {
/*
* Do re-ordering by putting one out of N packets at the front
@@ -226,7 +227,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
*/
cb->time_to_send = psched_get_time();
q->counter = 0;
- ret = qdisc_requeue(skb, q->qdisc);
+ ret = qdisc_requeue(skb, q->class.qdisc);
}
if (likely(ret == NET_XMIT_SUCCESS)) {
@@ -246,7 +247,7 @@ static int netem_requeue(struct sk_buff *skb, struct Qdisc *sch)
struct netem_sched_data *q = qdisc_priv(sch);
int ret;
- ret = qdisc_requeue(skb, q->qdisc);
+ ret = qdisc_requeue(skb, q->class.qdisc);
if (ret == NET_XMIT_SUCCESS) {
sch->q.qlen++;
sch->qstats.requeues++;
@@ -260,7 +261,7 @@ static unsigned int netem_drop(struct Qdisc* sch)
struct netem_sched_data *q = qdisc_priv(sch);
unsigned int len = 0;
- len = qdisc_drop(q->qdisc);
+ len = qdisc_drop(q->class.qdisc);
if (len > 0) {
sch->q.qlen--;
sch->qstats.drops++;
@@ -277,7 +278,7 @@ static struct sk_buff *netem_dequeue(struct Qdisc *sch)
if (sch->flags & TCQ_F_THROTTLED)
return NULL;
- skb = qdisc_dequeue(q->qdisc);
+ skb = qdisc_dequeue(q->class.qdisc);
if (skb) {
const struct netem_skb_cb *cb
= (const struct netem_skb_cb *)skb->cb;
@@ -290,11 +291,11 @@ static struct sk_buff *netem_dequeue(struct Qdisc *sch)
return skb;
}
- if (unlikely(qdisc_requeue(skb, q->qdisc) != NET_XMIT_SUCCESS)) {
- qdisc_tree_decrease_qlen(q->qdisc, 1);
+ if (unlikely(qdisc_requeue(skb, q->class.qdisc) != NET_XMIT_SUCCESS)) {
+ qdisc_tree_decrease_qlen(q->class.qdisc, 1);
sch->qstats.drops++;
printk(KERN_ERR "netem: %s could not requeue\n",
- q->qdisc->ops->id);
+ q->class.qdisc->ops->id);
}
qdisc_watchdog_schedule(&q->watchdog, cb->time_to_send);
@@ -307,7 +308,7 @@ static void netem_reset(struct Qdisc *sch)
{
struct netem_sched_data *q = qdisc_priv(sch);
- qdisc_reset(q->qdisc);
+ qdisc_reset(q->class.qdisc);
sch->q.qlen = 0;
qdisc_watchdog_cancel(&q->watchdog);
}
@@ -394,7 +395,7 @@ static int netem_change(struct Qdisc *sch, struct rtattr *opt)
return -EINVAL;
qopt = RTA_DATA(opt);
- ret = fifo_set_limit(q->qdisc, qopt->limit);
+ ret = fifo_set_limit(q->class.qdisc, qopt->limit);
if (ret) {
pr_debug("netem: can't set fifo limit\n");
return ret;
@@ -547,9 +548,9 @@ static int netem_init(struct Qdisc *sch, struct rtattr *opt)
qdisc_watchdog_init(&q->watchdog, sch);
- q->qdisc = qdisc_create_dflt(sch->dev, &tfifo_qdisc_ops,
- TC_H_MAKE(sch->handle, 1));
- if (!q->qdisc) {
+ q->class.qdisc = qdisc_create_dflt(sch->dev, &tfifo_qdisc_ops,
+ TC_H_MAKE(sch->handle, 1));
+ if (!q->class.qdisc) {
pr_debug("netem: qdisc create failed\n");
return -ENOMEM;
}
@@ -557,7 +558,7 @@ static int netem_init(struct Qdisc *sch, struct rtattr *opt)
ret = netem_change(sch, opt);
if (ret) {
pr_debug("netem: change failed\n");
- qdisc_destroy(q->qdisc);
+ qdisc_destroy(q->class.qdisc);
}
return ret;
}
@@ -567,7 +568,7 @@ static void netem_destroy(struct Qdisc *sch)
struct netem_sched_data *q = qdisc_priv(sch);
qdisc_watchdog_cancel(&q->watchdog);
- qdisc_destroy(q->qdisc);
+ qdisc_destroy(q->class.qdisc);
kfree(q->delay_dist);
}
@@ -611,95 +612,9 @@ rtattr_failure:
return -1;
}
-static int netem_dump_class(struct Qdisc *sch, unsigned long cl,
- struct sk_buff *skb, struct tcmsg *tcm)
-{
- struct netem_sched_data *q = qdisc_priv(sch);
-
- if (cl != 1) /* only one class */
- return -ENOENT;
-
- tcm->tcm_handle |= TC_H_MIN(1);
- tcm->tcm_info = q->qdisc->handle;
-
- return 0;
-}
-
-static int netem_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
- struct Qdisc **old)
-{
- struct netem_sched_data *q = qdisc_priv(sch);
-
- if (new == NULL)
- new = &noop_qdisc;
-
- sch_tree_lock(sch);
- *old = xchg(&q->qdisc, new);
- qdisc_tree_decrease_qlen(*old, (*old)->q.qlen);
- qdisc_reset(*old);
- sch_tree_unlock(sch);
-
- return 0;
-}
-
-static struct Qdisc *netem_leaf(struct Qdisc *sch, unsigned long arg)
-{
- struct netem_sched_data *q = qdisc_priv(sch);
- return q->qdisc;
-}
-
-static unsigned long netem_get(struct Qdisc *sch, u32 classid)
-{
- return 1;
-}
-
-static void netem_put(struct Qdisc *sch, unsigned long arg)
-{
-}
-
-static int netem_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
- struct rtattr **tca, unsigned long *arg)
-{
- return -ENOSYS;
-}
-
-static int netem_delete(struct Qdisc *sch, unsigned long arg)
-{
- return -ENOSYS;
-}
-
-static void netem_walk(struct Qdisc *sch, struct qdisc_walker *walker)
-{
- if (!walker->stop) {
- if (walker->count >= walker->skip)
- if (walker->fn(sch, 1, walker) < 0) {
- walker->stop = 1;
- return;
- }
- walker->count++;
- }
-}
-
-static struct tcf_proto **netem_find_tcf(struct Qdisc *sch, unsigned long cl)
-{
- return NULL;
-}
-
-static const struct Qdisc_class_ops netem_class_ops = {
- .graft = netem_graft,
- .leaf = netem_leaf,
- .get = netem_get,
- .put = netem_put,
- .change = netem_change_class,
- .delete = netem_delete,
- .walk = netem_walk,
- .tcf_chain = netem_find_tcf,
- .dump = netem_dump_class,
-};
-
static struct Qdisc_ops netem_qdisc_ops __read_mostly = {
.id = "netem",
- .cl_ops = &netem_class_ops,
+ .cl_ops = &pseudo_classful_ops,
.priv_size = sizeof(struct netem_sched_data),
.enqueue = netem_enqueue,
.dequeue = netem_dequeue,
diff --git a/net/sched/sch_pseudo_classful.c b/net/sched/sch_pseudo_classful.c
new file mode 100644
index 0000000..5b9fba5
--- /dev/null
+++ b/net/sched/sch_pseudo_classful.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2007 Patrick McHardy, <kaber@trash.net>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/skbuff.h>
+#include <net/sch_generic.h>
+#include <net/pkt_sched.h>
+
+static int sch_pc_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
+ struct Qdisc **old)
+{
+ struct pc_sched_data *q = qdisc_priv(sch);
+
+ if (new == NULL)
+ new = &noop_qdisc;
+
+ sch_tree_lock(sch);
+ *old = xchg(&q->qdisc, new);
+ qdisc_tree_decrease_qlen(*old, (*old)->q.qlen);
+ qdisc_reset(*old);
+ sch_tree_unlock(sch);
+ return 0;
+}
+
+static int sch_pc_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
+ struct rtattr **tca, unsigned long *arg)
+{
+ return -ENOSYS;
+}
+
+static struct Qdisc *sch_pc_leaf(struct Qdisc *sch, unsigned long arg)
+{
+ return ((struct pc_sched_data *)qdisc_priv(sch))->qdisc;
+}
+
+static unsigned long sch_pc_get(struct Qdisc *sch, u32 classid)
+{
+ return 1;
+}
+
+static void sch_pc_put(struct Qdisc *sch, unsigned long arg)
+{
+ return;
+}
+
+static int sch_pc_delete(struct Qdisc *sch, unsigned long arg)
+{
+ return -ENOSYS;
+}
+
+static struct tcf_proto **sch_pc_tcf_chain(struct Qdisc *sch, unsigned long cl)
+{
+ return NULL;
+}
+
+static int sch_pc_dump_class(struct Qdisc *sch, unsigned long cl,
+ struct sk_buff *skb, struct tcmsg *tcm)
+{
+ struct pc_sched_data *q = qdisc_priv(sch);
+
+ if (cl != 1)
+ return -ENOENT;
+
+ tcm->tcm_handle |= TC_H_MIN(1);
+ tcm->tcm_info = q->qdisc->handle;
+ return 0;
+}
+
+static void sch_pc_walk(struct Qdisc *sch, struct qdisc_walker *walker)
+{
+ if (!walker->stop) {
+ if (walker->count >= walker->skip)
+ if (walker->fn(sch, 1, walker) < 0) {
+ walker->stop = 1;
+ return;
+ }
+ walker->count++;
+ }
+}
+
+const struct Qdisc_class_ops pseudo_classful_ops = {
+ .graft = sch_pc_graft,
+ .leaf = sch_pc_leaf,
+ .get = sch_pc_get,
+ .put = sch_pc_put,
+ .change = sch_pc_change_class,
+ .delete = sch_pc_delete,
+ .walk = sch_pc_walk,
+ .tcf_chain = sch_pc_tcf_chain,
+ .dump = sch_pc_dump_class,
+};
+EXPORT_SYMBOL(pseudo_classful_ops);
+
+MODULE_LICENSE("GPL");
diff --git a/net/sched/sch_red.c b/net/sched/sch_red.c
index 076f1ef..fc61675 100644
--- a/net/sched/sch_red.c
+++ b/net/sched/sch_red.c
@@ -38,11 +38,12 @@
struct red_sched_data
{
+ struct pc_sched_data class;
+
u32 limit; /* HARD maximal queue length */
unsigned char flags;
struct red_parms parms;
struct red_stats stats;
- struct Qdisc *qdisc;
};
static inline int red_use_ecn(struct red_sched_data *q)
@@ -58,7 +59,7 @@ static inline int red_use_harddrop(struct red_sched_data *q)
static int red_enqueue(struct sk_buff *skb, struct Qdisc* sch)
{
struct red_sched_data *q = qdisc_priv(sch);
- struct Qdisc *child = q->qdisc;
+ struct Qdisc *child = q->class.qdisc;
int ret;
q->parms.qavg = red_calc_qavg(&q->parms, child->qstats.backlog);
@@ -111,7 +112,7 @@ congestion_drop:
static int red_requeue(struct sk_buff *skb, struct Qdisc* sch)
{
struct red_sched_data *q = qdisc_priv(sch);
- struct Qdisc *child = q->qdisc;
+ struct Qdisc *child = q->class.qdisc;
int ret;
if (red_is_idling(&q->parms))
@@ -129,7 +130,7 @@ static struct sk_buff * red_dequeue(struct Qdisc* sch)
{
struct sk_buff *skb;
struct red_sched_data *q = qdisc_priv(sch);
- struct Qdisc *child = q->qdisc;
+ struct Qdisc *child = q->class.qdisc;
skb = qdisc_dequeue(child);
if (skb)
@@ -143,7 +144,7 @@ static struct sk_buff * red_dequeue(struct Qdisc* sch)
static unsigned int red_drop(struct Qdisc* sch)
{
struct red_sched_data *q = qdisc_priv(sch);
- struct Qdisc *child = q->qdisc;
+ struct Qdisc *child = q->class.qdisc;
unsigned int len;
len = qdisc_drop(child);
@@ -164,7 +165,7 @@ static void red_reset(struct Qdisc* sch)
{
struct red_sched_data *q = qdisc_priv(sch);
- qdisc_reset(q->qdisc);
+ qdisc_reset(q->class.qdisc);
sch->q.qlen = 0;
red_restart(&q->parms);
}
@@ -172,7 +173,7 @@ static void red_reset(struct Qdisc* sch)
static void red_destroy(struct Qdisc *sch)
{
struct red_sched_data *q = qdisc_priv(sch);
- qdisc_destroy(q->qdisc);
+ qdisc_destroy(q->class.qdisc);
}
static int red_change(struct Qdisc *sch, struct rtattr *opt)
@@ -203,8 +204,9 @@ static int red_change(struct Qdisc *sch, struct rtattr *opt)
q->flags = ctl->flags;
q->limit = ctl->limit;
if (child) {
- qdisc_tree_decrease_qlen(q->qdisc, q->qdisc->q.qlen);
- qdisc_destroy(xchg(&q->qdisc, child));
+ qdisc_tree_decrease_qlen(q->class.qdisc,
+ q->class.qdisc->q.qlen);
+ qdisc_destroy(xchg(&q->class.qdisc, child));
}
red_set_parms(&q->parms, ctl->qth_min, ctl->qth_max, ctl->Wlog,
@@ -222,7 +224,7 @@ static int red_init(struct Qdisc* sch, struct rtattr *opt)
{
struct red_sched_data *q = qdisc_priv(sch);
- q->qdisc = &noop_qdisc;
+ q->class.qdisc = &noop_qdisc;
return red_change(sch, opt);
}
@@ -261,94 +263,10 @@ static int red_dump_stats(struct Qdisc *sch, struct gnet_dump *d)
return gnet_stats_copy_app(d, &st, sizeof(st));
}
-static int red_dump_class(struct Qdisc *sch, unsigned long cl,
- struct sk_buff *skb, struct tcmsg *tcm)
-{
- struct red_sched_data *q = qdisc_priv(sch);
-
- if (cl != 1)
- return -ENOENT;
- tcm->tcm_handle |= TC_H_MIN(1);
- tcm->tcm_info = q->qdisc->handle;
- return 0;
-}
-
-static int red_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
- struct Qdisc **old)
-{
- struct red_sched_data *q = qdisc_priv(sch);
-
- if (new == NULL)
- new = &noop_qdisc;
-
- sch_tree_lock(sch);
- *old = xchg(&q->qdisc, new);
- qdisc_tree_decrease_qlen(*old, (*old)->q.qlen);
- qdisc_reset(*old);
- sch_tree_unlock(sch);
- return 0;
-}
-
-static struct Qdisc *red_leaf(struct Qdisc *sch, unsigned long arg)
-{
- struct red_sched_data *q = qdisc_priv(sch);
- return q->qdisc;
-}
-
-static unsigned long red_get(struct Qdisc *sch, u32 classid)
-{
- return 1;
-}
-
-static void red_put(struct Qdisc *sch, unsigned long arg)
-{
- return;
-}
-
-static int red_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
- struct rtattr **tca, unsigned long *arg)
-{
- return -ENOSYS;
-}
-
-static int red_delete(struct Qdisc *sch, unsigned long cl)
-{
- return -ENOSYS;
-}
-
-static void red_walk(struct Qdisc *sch, struct qdisc_walker *walker)
-{
- if (!walker->stop) {
- if (walker->count >= walker->skip)
- if (walker->fn(sch, 1, walker) < 0) {
- walker->stop = 1;
- return;
- }
- walker->count++;
- }
-}
-
-static struct tcf_proto **red_find_tcf(struct Qdisc *sch, unsigned long cl)
-{
- return NULL;
-}
-
-static const struct Qdisc_class_ops red_class_ops = {
- .graft = red_graft,
- .leaf = red_leaf,
- .get = red_get,
- .put = red_put,
- .change = red_change_class,
- .delete = red_delete,
- .walk = red_walk,
- .tcf_chain = red_find_tcf,
- .dump = red_dump_class,
-};
-
static struct Qdisc_ops red_qdisc_ops __read_mostly = {
.id = "red",
.priv_size = sizeof(struct red_sched_data),
- .cl_ops = &red_class_ops,
+ .cl_ops = &pseudo_classful_ops,
.enqueue = red_enqueue,
.dequeue = red_dequeue,
.requeue = red_requeue,
diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
index 5fd4dff..6590ce3 100644
--- a/net/sched/sch_tbf.c
+++ b/net/sched/sch_tbf.c
@@ -99,6 +99,8 @@
struct tbf_sched_data
{
+ struct pc_sched_data class;
+
/* Parameters */
u32 limit; /* Maximal length of backlog: bytes */
u32 buffer; /* Token bucket depth/rate: MUST BE >= MTU/B */
@@ -111,7 +113,6 @@ struct tbf_sched_data
long tokens; /* Current number of B tokens */
long ptokens; /* Current number of P tokens */
psched_time_t t_c; /* Time check-point */
- struct Qdisc *qdisc; /* Inner qdisc, default - bfifo queue */
struct qdisc_watchdog watchdog; /* Watchdog timer */
};
@@ -133,7 +134,7 @@ static int tbf_enqueue(struct sk_buff *skb, struct Qdisc* sch)
return NET_XMIT_DROP;
}
- ret = qdisc_enqueue(skb, q->qdisc);
+ ret = qdisc_enqueue(skb, q->class.qdisc);
if (ret != NET_XMIT_SUCCESS) {
sch->qstats.drops++;
return ret;
@@ -150,7 +151,7 @@ static int tbf_requeue(struct sk_buff *skb, struct Qdisc* sch)
struct tbf_sched_data *q = qdisc_priv(sch);
int ret;
- ret = qdisc_requeue(skb, q->qdisc);
+ ret = qdisc_requeue(skb, q->class.qdisc);
if (ret == NET_XMIT_SUCCESS) {
sch->q.qlen++;
sch->qstats.requeues++;
@@ -164,7 +165,7 @@ static unsigned int tbf_drop(struct Qdisc* sch)
struct tbf_sched_data *q = qdisc_priv(sch);
unsigned int len = 0;
- len = qdisc_drop(q->qdisc);
+ len = qdisc_drop(q->class.qdisc);
if (len > 0) {
sch->q.qlen--;
sch->qstats.drops++;
@@ -177,7 +178,7 @@ static struct sk_buff *tbf_dequeue(struct Qdisc* sch)
struct tbf_sched_data *q = qdisc_priv(sch);
struct sk_buff *skb;
- skb = qdisc_dequeue(q->qdisc);
+ skb = qdisc_dequeue(q->class.qdisc);
if (skb) {
psched_time_t now;
@@ -222,9 +223,9 @@ static struct sk_buff *tbf_dequeue(struct Qdisc* sch)
(cf. CSZ, HPFQ, HFSC)
*/
- if (q->qdisc->ops->requeue(skb, q->qdisc) != NET_XMIT_SUCCESS) {
+ if (q->class.qdisc->ops->requeue(skb, q->class.qdisc) != NET_XMIT_SUCCESS) {
/* When requeue fails skb is dropped */
- qdisc_tree_decrease_qlen(q->qdisc, 1);
+ qdisc_tree_decrease_qlen(q->class.qdisc, 1);
sch->qstats.drops++;
}
@@ -237,7 +238,7 @@ static void tbf_reset(struct Qdisc* sch)
{
struct tbf_sched_data *q = qdisc_priv(sch);
- qdisc_reset(q->qdisc);
+ qdisc_reset(q->class.qdisc);
sch->q.qlen = 0;
q->t_c = psched_get_time();
q->tokens = q->buffer;
@@ -295,8 +296,8 @@ static int tbf_change(struct Qdisc* sch, struct rtattr *opt)
sch_tree_lock(sch);
if (child) {
- qdisc_tree_decrease_qlen(q->qdisc, q->qdisc->q.qlen);
- qdisc_destroy(xchg(&q->qdisc, child));
+ qdisc_tree_decrease_qlen(q->class.qdisc, q->class.qdisc->q.qlen);
+ qdisc_destroy(xchg(&q->class.qdisc, child));
}
q->limit = qopt->limit;
q->mtu = qopt->mtu;
@@ -325,7 +326,7 @@ static int tbf_init(struct Qdisc* sch, struct rtattr *opt)
q->t_c = psched_get_time();
qdisc_watchdog_init(&q->watchdog, sch);
- q->qdisc = &noop_qdisc;
+ q->class.qdisc = &noop_qdisc;
return tbf_change(sch, opt);
}
@@ -341,7 +342,7 @@ static void tbf_destroy(struct Qdisc *sch)
if (q->R_tab)
qdisc_put_rtab(q->R_tab);
- qdisc_destroy(q->qdisc);
+ qdisc_destroy(q->class.qdisc);
}
static int tbf_dump(struct Qdisc *sch, struct sk_buff *skb)
@@ -372,96 +373,8 @@ rtattr_failure:
return -1;
}
-static int tbf_dump_class(struct Qdisc *sch, unsigned long cl,
- struct sk_buff *skb, struct tcmsg *tcm)
-{
- struct tbf_sched_data *q = qdisc_priv(sch);
-
- if (cl != 1) /* only one class */
- return -ENOENT;
-
- tcm->tcm_handle |= TC_H_MIN(1);
- tcm->tcm_info = q->qdisc->handle;
-
- return 0;
-}
-
-static int tbf_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
- struct Qdisc **old)
-{
- struct tbf_sched_data *q = qdisc_priv(sch);
-
- if (new == NULL)
- new = &noop_qdisc;
-
- sch_tree_lock(sch);
- *old = xchg(&q->qdisc, new);
- qdisc_tree_decrease_qlen(*old, (*old)->q.qlen);
- qdisc_reset(*old);
- sch_tree_unlock(sch);
-
- return 0;
-}
-
-static struct Qdisc *tbf_leaf(struct Qdisc *sch, unsigned long arg)
-{
- struct tbf_sched_data *q = qdisc_priv(sch);
- return q->qdisc;
-}
-
-static unsigned long tbf_get(struct Qdisc *sch, u32 classid)
-{
- return 1;
-}
-
-static void tbf_put(struct Qdisc *sch, unsigned long arg)
-{
-}
-
-static int tbf_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
- struct rtattr **tca, unsigned long *arg)
-{
- return -ENOSYS;
-}
-
-static int tbf_delete(struct Qdisc *sch, unsigned long arg)
-{
- return -ENOSYS;
-}
-
-static void tbf_walk(struct Qdisc *sch, struct qdisc_walker *walker)
-{
- if (!walker->stop) {
- if (walker->count >= walker->skip)
- if (walker->fn(sch, 1, walker) < 0) {
- walker->stop = 1;
- return;
- }
- walker->count++;
- }
-}
-
-static struct tcf_proto **tbf_find_tcf(struct Qdisc *sch, unsigned long cl)
-{
- return NULL;
-}
-
-static const struct Qdisc_class_ops tbf_class_ops =
-{
- .graft = tbf_graft,
- .leaf = tbf_leaf,
- .get = tbf_get,
- .put = tbf_put,
- .change = tbf_change_class,
- .delete = tbf_delete,
- .walk = tbf_walk,
- .tcf_chain = tbf_find_tcf,
- .dump = tbf_dump_class,
-};
-
static struct Qdisc_ops tbf_qdisc_ops __read_mostly = {
- .next = NULL,
- .cl_ops = &tbf_class_ops,
+ .cl_ops = &pseudo_classful_ops,
.id = "tbf",
.priv_size = sizeof(struct tbf_sched_data),
.enqueue = tbf_enqueue,
^ permalink raw reply related
* Re: [RFC NET_SCHED 05/05]: Consolidate class ops for pseudo classful qdisc
From: Patrick McHardy @ 2008-01-20 18:32 UTC (permalink / raw)
To: netdev
In-Reply-To: <20080120182855.10972.24622.sendpatchset@localhost.localdomain>
[-- Attachment #1: Type: text/plain, Size: 440 bytes --]
Patrick McHardy wrote:
> commit e97ba18f7a8f9342fa06d0f5606a186b18e1d7f8
> Author: Patrick McHardy <kaber@trash.net>
> Date: Wed Jan 16 12:22:06 2008 +0100
>
> [NET_SCHED]: Consolidate class ops for pseudo classful qdisc
>
> Signed-off-by: Patrick McHardy <kaber@trash.net>
>
> config NET_SCH_TEQL
> tristate "True Link Equalizer (TEQL)"
> + select NET_SCH_PC
Oops .. this should have been at the NET_SCH_RED entry.
[-- Attachment #2: 05.diff --]
[-- Type: text/x-patch, Size: 21118 bytes --]
commit d89898d2e77b5c1753d21174870277d235994afa
Author: Patrick McHardy <kaber@trash.net>
Date: Sun Jan 20 19:31:05 2008 +0100
[NET_SCHED]: Consolidate class ops for pseudo classful qdisc
Signed-off-by: Patrick McHardy <kaber@trash.net>
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index decc339..ca6e4de 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -351,4 +351,10 @@ static inline struct sk_buff *skb_act_clone(struct sk_buff *skb, gfp_t gfp_mask)
}
#endif
+struct pc_sched_data {
+ struct Qdisc *qdisc;
+};
+
+extern const struct Qdisc_class_ops pseudo_classful_ops;
+
#endif
diff --git a/net/sched/Kconfig b/net/sched/Kconfig
index f5ab54b..b6b4260 100644
--- a/net/sched/Kconfig
+++ b/net/sched/Kconfig
@@ -43,6 +43,9 @@ if NET_SCHED
comment "Queueing/Scheduling"
+config NET_SCH_PC
+ tristate
+
config NET_SCH_CBQ
tristate "Class Based Queueing (CBQ)"
---help---
@@ -119,6 +122,7 @@ config NET_SCH_RR
config NET_SCH_RED
tristate "Random Early Detection (RED)"
+ select NET_SCH_PC
---help---
Say Y here if you want to use the Random Early Detection (RED)
packet scheduling algorithm.
@@ -153,6 +157,7 @@ config NET_SCH_TEQL
config NET_SCH_TBF
tristate "Token Bucket Filter (TBF)"
+ select NET_SCH_PC
---help---
Say Y here if you want to use the Token Bucket Filter (TBF) packet
scheduling algorithm.
@@ -186,6 +191,7 @@ config NET_SCH_DSMARK
config NET_SCH_NETEM
tristate "Network emulator (NETEM)"
+ select NET_SCH_PC
---help---
Say Y if you want to emulate network delay, loss, and packet
re-ordering. This is often useful to simulate networks when
diff --git a/net/sched/Makefile b/net/sched/Makefile
index 81ecbe8..593bb3a 100644
--- a/net/sched/Makefile
+++ b/net/sched/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_NET_ACT_IPT) += act_ipt.o
obj-$(CONFIG_NET_ACT_NAT) += act_nat.o
obj-$(CONFIG_NET_ACT_PEDIT) += act_pedit.o
obj-$(CONFIG_NET_ACT_SIMP) += act_simple.o
+obj-$(CONFIG_NET_SCH_PC) += sch_pseudo_classful.o
obj-$(CONFIG_NET_SCH_FIFO) += sch_fifo.o
obj-$(CONFIG_NET_SCH_CBQ) += sch_cbq.o
obj-$(CONFIG_NET_SCH_HTB) += sch_htb.o
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index f6c24fd..2444a97 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -52,7 +52,8 @@
*/
struct netem_sched_data {
- struct Qdisc *qdisc;
+ struct pc_sched_data class;
+
struct qdisc_watchdog watchdog;
psched_tdiff_t latency;
@@ -218,7 +219,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
now = psched_get_time();
cb->time_to_send = now + delay;
++q->counter;
- ret = qdisc_enqueue(skb, q->qdisc);
+ ret = qdisc_enqueue(skb, q->class.qdisc);
} else {
/*
* Do re-ordering by putting one out of N packets at the front
@@ -226,7 +227,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
*/
cb->time_to_send = psched_get_time();
q->counter = 0;
- ret = qdisc_requeue(skb, q->qdisc);
+ ret = qdisc_requeue(skb, q->class.qdisc);
}
if (likely(ret == NET_XMIT_SUCCESS)) {
@@ -246,7 +247,7 @@ static int netem_requeue(struct sk_buff *skb, struct Qdisc *sch)
struct netem_sched_data *q = qdisc_priv(sch);
int ret;
- ret = qdisc_requeue(skb, q->qdisc);
+ ret = qdisc_requeue(skb, q->class.qdisc);
if (ret == NET_XMIT_SUCCESS) {
sch->q.qlen++;
sch->qstats.requeues++;
@@ -260,7 +261,7 @@ static unsigned int netem_drop(struct Qdisc* sch)
struct netem_sched_data *q = qdisc_priv(sch);
unsigned int len = 0;
- len = qdisc_drop(q->qdisc);
+ len = qdisc_drop(q->class.qdisc);
if (len > 0) {
sch->q.qlen--;
sch->qstats.drops++;
@@ -277,7 +278,7 @@ static struct sk_buff *netem_dequeue(struct Qdisc *sch)
if (sch->flags & TCQ_F_THROTTLED)
return NULL;
- skb = qdisc_dequeue(q->qdisc);
+ skb = qdisc_dequeue(q->class.qdisc);
if (skb) {
const struct netem_skb_cb *cb
= (const struct netem_skb_cb *)skb->cb;
@@ -290,11 +291,11 @@ static struct sk_buff *netem_dequeue(struct Qdisc *sch)
return skb;
}
- if (unlikely(qdisc_requeue(skb, q->qdisc) != NET_XMIT_SUCCESS)) {
- qdisc_tree_decrease_qlen(q->qdisc, 1);
+ if (unlikely(qdisc_requeue(skb, q->class.qdisc) != NET_XMIT_SUCCESS)) {
+ qdisc_tree_decrease_qlen(q->class.qdisc, 1);
sch->qstats.drops++;
printk(KERN_ERR "netem: %s could not requeue\n",
- q->qdisc->ops->id);
+ q->class.qdisc->ops->id);
}
qdisc_watchdog_schedule(&q->watchdog, cb->time_to_send);
@@ -307,7 +308,7 @@ static void netem_reset(struct Qdisc *sch)
{
struct netem_sched_data *q = qdisc_priv(sch);
- qdisc_reset(q->qdisc);
+ qdisc_reset(q->class.qdisc);
sch->q.qlen = 0;
qdisc_watchdog_cancel(&q->watchdog);
}
@@ -394,7 +395,7 @@ static int netem_change(struct Qdisc *sch, struct rtattr *opt)
return -EINVAL;
qopt = RTA_DATA(opt);
- ret = fifo_set_limit(q->qdisc, qopt->limit);
+ ret = fifo_set_limit(q->class.qdisc, qopt->limit);
if (ret) {
pr_debug("netem: can't set fifo limit\n");
return ret;
@@ -547,9 +548,9 @@ static int netem_init(struct Qdisc *sch, struct rtattr *opt)
qdisc_watchdog_init(&q->watchdog, sch);
- q->qdisc = qdisc_create_dflt(sch->dev, &tfifo_qdisc_ops,
- TC_H_MAKE(sch->handle, 1));
- if (!q->qdisc) {
+ q->class.qdisc = qdisc_create_dflt(sch->dev, &tfifo_qdisc_ops,
+ TC_H_MAKE(sch->handle, 1));
+ if (!q->class.qdisc) {
pr_debug("netem: qdisc create failed\n");
return -ENOMEM;
}
@@ -557,7 +558,7 @@ static int netem_init(struct Qdisc *sch, struct rtattr *opt)
ret = netem_change(sch, opt);
if (ret) {
pr_debug("netem: change failed\n");
- qdisc_destroy(q->qdisc);
+ qdisc_destroy(q->class.qdisc);
}
return ret;
}
@@ -567,7 +568,7 @@ static void netem_destroy(struct Qdisc *sch)
struct netem_sched_data *q = qdisc_priv(sch);
qdisc_watchdog_cancel(&q->watchdog);
- qdisc_destroy(q->qdisc);
+ qdisc_destroy(q->class.qdisc);
kfree(q->delay_dist);
}
@@ -611,95 +612,9 @@ rtattr_failure:
return -1;
}
-static int netem_dump_class(struct Qdisc *sch, unsigned long cl,
- struct sk_buff *skb, struct tcmsg *tcm)
-{
- struct netem_sched_data *q = qdisc_priv(sch);
-
- if (cl != 1) /* only one class */
- return -ENOENT;
-
- tcm->tcm_handle |= TC_H_MIN(1);
- tcm->tcm_info = q->qdisc->handle;
-
- return 0;
-}
-
-static int netem_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
- struct Qdisc **old)
-{
- struct netem_sched_data *q = qdisc_priv(sch);
-
- if (new == NULL)
- new = &noop_qdisc;
-
- sch_tree_lock(sch);
- *old = xchg(&q->qdisc, new);
- qdisc_tree_decrease_qlen(*old, (*old)->q.qlen);
- qdisc_reset(*old);
- sch_tree_unlock(sch);
-
- return 0;
-}
-
-static struct Qdisc *netem_leaf(struct Qdisc *sch, unsigned long arg)
-{
- struct netem_sched_data *q = qdisc_priv(sch);
- return q->qdisc;
-}
-
-static unsigned long netem_get(struct Qdisc *sch, u32 classid)
-{
- return 1;
-}
-
-static void netem_put(struct Qdisc *sch, unsigned long arg)
-{
-}
-
-static int netem_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
- struct rtattr **tca, unsigned long *arg)
-{
- return -ENOSYS;
-}
-
-static int netem_delete(struct Qdisc *sch, unsigned long arg)
-{
- return -ENOSYS;
-}
-
-static void netem_walk(struct Qdisc *sch, struct qdisc_walker *walker)
-{
- if (!walker->stop) {
- if (walker->count >= walker->skip)
- if (walker->fn(sch, 1, walker) < 0) {
- walker->stop = 1;
- return;
- }
- walker->count++;
- }
-}
-
-static struct tcf_proto **netem_find_tcf(struct Qdisc *sch, unsigned long cl)
-{
- return NULL;
-}
-
-static const struct Qdisc_class_ops netem_class_ops = {
- .graft = netem_graft,
- .leaf = netem_leaf,
- .get = netem_get,
- .put = netem_put,
- .change = netem_change_class,
- .delete = netem_delete,
- .walk = netem_walk,
- .tcf_chain = netem_find_tcf,
- .dump = netem_dump_class,
-};
-
static struct Qdisc_ops netem_qdisc_ops __read_mostly = {
.id = "netem",
- .cl_ops = &netem_class_ops,
+ .cl_ops = &pseudo_classful_ops,
.priv_size = sizeof(struct netem_sched_data),
.enqueue = netem_enqueue,
.dequeue = netem_dequeue,
diff --git a/net/sched/sch_pseudo_classful.c b/net/sched/sch_pseudo_classful.c
new file mode 100644
index 0000000..5b9fba5
--- /dev/null
+++ b/net/sched/sch_pseudo_classful.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2007 Patrick McHardy, <kaber@trash.net>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/skbuff.h>
+#include <net/sch_generic.h>
+#include <net/pkt_sched.h>
+
+static int sch_pc_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
+ struct Qdisc **old)
+{
+ struct pc_sched_data *q = qdisc_priv(sch);
+
+ if (new == NULL)
+ new = &noop_qdisc;
+
+ sch_tree_lock(sch);
+ *old = xchg(&q->qdisc, new);
+ qdisc_tree_decrease_qlen(*old, (*old)->q.qlen);
+ qdisc_reset(*old);
+ sch_tree_unlock(sch);
+ return 0;
+}
+
+static int sch_pc_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
+ struct rtattr **tca, unsigned long *arg)
+{
+ return -ENOSYS;
+}
+
+static struct Qdisc *sch_pc_leaf(struct Qdisc *sch, unsigned long arg)
+{
+ return ((struct pc_sched_data *)qdisc_priv(sch))->qdisc;
+}
+
+static unsigned long sch_pc_get(struct Qdisc *sch, u32 classid)
+{
+ return 1;
+}
+
+static void sch_pc_put(struct Qdisc *sch, unsigned long arg)
+{
+ return;
+}
+
+static int sch_pc_delete(struct Qdisc *sch, unsigned long arg)
+{
+ return -ENOSYS;
+}
+
+static struct tcf_proto **sch_pc_tcf_chain(struct Qdisc *sch, unsigned long cl)
+{
+ return NULL;
+}
+
+static int sch_pc_dump_class(struct Qdisc *sch, unsigned long cl,
+ struct sk_buff *skb, struct tcmsg *tcm)
+{
+ struct pc_sched_data *q = qdisc_priv(sch);
+
+ if (cl != 1)
+ return -ENOENT;
+
+ tcm->tcm_handle |= TC_H_MIN(1);
+ tcm->tcm_info = q->qdisc->handle;
+ return 0;
+}
+
+static void sch_pc_walk(struct Qdisc *sch, struct qdisc_walker *walker)
+{
+ if (!walker->stop) {
+ if (walker->count >= walker->skip)
+ if (walker->fn(sch, 1, walker) < 0) {
+ walker->stop = 1;
+ return;
+ }
+ walker->count++;
+ }
+}
+
+const struct Qdisc_class_ops pseudo_classful_ops = {
+ .graft = sch_pc_graft,
+ .leaf = sch_pc_leaf,
+ .get = sch_pc_get,
+ .put = sch_pc_put,
+ .change = sch_pc_change_class,
+ .delete = sch_pc_delete,
+ .walk = sch_pc_walk,
+ .tcf_chain = sch_pc_tcf_chain,
+ .dump = sch_pc_dump_class,
+};
+EXPORT_SYMBOL(pseudo_classful_ops);
+
+MODULE_LICENSE("GPL");
diff --git a/net/sched/sch_red.c b/net/sched/sch_red.c
index 076f1ef..fc61675 100644
--- a/net/sched/sch_red.c
+++ b/net/sched/sch_red.c
@@ -38,11 +38,12 @@
struct red_sched_data
{
+ struct pc_sched_data class;
+
u32 limit; /* HARD maximal queue length */
unsigned char flags;
struct red_parms parms;
struct red_stats stats;
- struct Qdisc *qdisc;
};
static inline int red_use_ecn(struct red_sched_data *q)
@@ -58,7 +59,7 @@ static inline int red_use_harddrop(struct red_sched_data *q)
static int red_enqueue(struct sk_buff *skb, struct Qdisc* sch)
{
struct red_sched_data *q = qdisc_priv(sch);
- struct Qdisc *child = q->qdisc;
+ struct Qdisc *child = q->class.qdisc;
int ret;
q->parms.qavg = red_calc_qavg(&q->parms, child->qstats.backlog);
@@ -111,7 +112,7 @@ congestion_drop:
static int red_requeue(struct sk_buff *skb, struct Qdisc* sch)
{
struct red_sched_data *q = qdisc_priv(sch);
- struct Qdisc *child = q->qdisc;
+ struct Qdisc *child = q->class.qdisc;
int ret;
if (red_is_idling(&q->parms))
@@ -129,7 +130,7 @@ static struct sk_buff * red_dequeue(struct Qdisc* sch)
{
struct sk_buff *skb;
struct red_sched_data *q = qdisc_priv(sch);
- struct Qdisc *child = q->qdisc;
+ struct Qdisc *child = q->class.qdisc;
skb = qdisc_dequeue(child);
if (skb)
@@ -143,7 +144,7 @@ static struct sk_buff * red_dequeue(struct Qdisc* sch)
static unsigned int red_drop(struct Qdisc* sch)
{
struct red_sched_data *q = qdisc_priv(sch);
- struct Qdisc *child = q->qdisc;
+ struct Qdisc *child = q->class.qdisc;
unsigned int len;
len = qdisc_drop(child);
@@ -164,7 +165,7 @@ static void red_reset(struct Qdisc* sch)
{
struct red_sched_data *q = qdisc_priv(sch);
- qdisc_reset(q->qdisc);
+ qdisc_reset(q->class.qdisc);
sch->q.qlen = 0;
red_restart(&q->parms);
}
@@ -172,7 +173,7 @@ static void red_reset(struct Qdisc* sch)
static void red_destroy(struct Qdisc *sch)
{
struct red_sched_data *q = qdisc_priv(sch);
- qdisc_destroy(q->qdisc);
+ qdisc_destroy(q->class.qdisc);
}
static int red_change(struct Qdisc *sch, struct rtattr *opt)
@@ -203,8 +204,9 @@ static int red_change(struct Qdisc *sch, struct rtattr *opt)
q->flags = ctl->flags;
q->limit = ctl->limit;
if (child) {
- qdisc_tree_decrease_qlen(q->qdisc, q->qdisc->q.qlen);
- qdisc_destroy(xchg(&q->qdisc, child));
+ qdisc_tree_decrease_qlen(q->class.qdisc,
+ q->class.qdisc->q.qlen);
+ qdisc_destroy(xchg(&q->class.qdisc, child));
}
red_set_parms(&q->parms, ctl->qth_min, ctl->qth_max, ctl->Wlog,
@@ -222,7 +224,7 @@ static int red_init(struct Qdisc* sch, struct rtattr *opt)
{
struct red_sched_data *q = qdisc_priv(sch);
- q->qdisc = &noop_qdisc;
+ q->class.qdisc = &noop_qdisc;
return red_change(sch, opt);
}
@@ -261,94 +263,10 @@ static int red_dump_stats(struct Qdisc *sch, struct gnet_dump *d)
return gnet_stats_copy_app(d, &st, sizeof(st));
}
-static int red_dump_class(struct Qdisc *sch, unsigned long cl,
- struct sk_buff *skb, struct tcmsg *tcm)
-{
- struct red_sched_data *q = qdisc_priv(sch);
-
- if (cl != 1)
- return -ENOENT;
- tcm->tcm_handle |= TC_H_MIN(1);
- tcm->tcm_info = q->qdisc->handle;
- return 0;
-}
-
-static int red_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
- struct Qdisc **old)
-{
- struct red_sched_data *q = qdisc_priv(sch);
-
- if (new == NULL)
- new = &noop_qdisc;
-
- sch_tree_lock(sch);
- *old = xchg(&q->qdisc, new);
- qdisc_tree_decrease_qlen(*old, (*old)->q.qlen);
- qdisc_reset(*old);
- sch_tree_unlock(sch);
- return 0;
-}
-
-static struct Qdisc *red_leaf(struct Qdisc *sch, unsigned long arg)
-{
- struct red_sched_data *q = qdisc_priv(sch);
- return q->qdisc;
-}
-
-static unsigned long red_get(struct Qdisc *sch, u32 classid)
-{
- return 1;
-}
-
-static void red_put(struct Qdisc *sch, unsigned long arg)
-{
- return;
-}
-
-static int red_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
- struct rtattr **tca, unsigned long *arg)
-{
- return -ENOSYS;
-}
-
-static int red_delete(struct Qdisc *sch, unsigned long cl)
-{
- return -ENOSYS;
-}
-
-static void red_walk(struct Qdisc *sch, struct qdisc_walker *walker)
-{
- if (!walker->stop) {
- if (walker->count >= walker->skip)
- if (walker->fn(sch, 1, walker) < 0) {
- walker->stop = 1;
- return;
- }
- walker->count++;
- }
-}
-
-static struct tcf_proto **red_find_tcf(struct Qdisc *sch, unsigned long cl)
-{
- return NULL;
-}
-
-static const struct Qdisc_class_ops red_class_ops = {
- .graft = red_graft,
- .leaf = red_leaf,
- .get = red_get,
- .put = red_put,
- .change = red_change_class,
- .delete = red_delete,
- .walk = red_walk,
- .tcf_chain = red_find_tcf,
- .dump = red_dump_class,
-};
-
static struct Qdisc_ops red_qdisc_ops __read_mostly = {
.id = "red",
.priv_size = sizeof(struct red_sched_data),
- .cl_ops = &red_class_ops,
+ .cl_ops = &pseudo_classful_ops,
.enqueue = red_enqueue,
.dequeue = red_dequeue,
.requeue = red_requeue,
diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
index 5fd4dff..6590ce3 100644
--- a/net/sched/sch_tbf.c
+++ b/net/sched/sch_tbf.c
@@ -99,6 +99,8 @@
struct tbf_sched_data
{
+ struct pc_sched_data class;
+
/* Parameters */
u32 limit; /* Maximal length of backlog: bytes */
u32 buffer; /* Token bucket depth/rate: MUST BE >= MTU/B */
@@ -111,7 +113,6 @@ struct tbf_sched_data
long tokens; /* Current number of B tokens */
long ptokens; /* Current number of P tokens */
psched_time_t t_c; /* Time check-point */
- struct Qdisc *qdisc; /* Inner qdisc, default - bfifo queue */
struct qdisc_watchdog watchdog; /* Watchdog timer */
};
@@ -133,7 +134,7 @@ static int tbf_enqueue(struct sk_buff *skb, struct Qdisc* sch)
return NET_XMIT_DROP;
}
- ret = qdisc_enqueue(skb, q->qdisc);
+ ret = qdisc_enqueue(skb, q->class.qdisc);
if (ret != NET_XMIT_SUCCESS) {
sch->qstats.drops++;
return ret;
@@ -150,7 +151,7 @@ static int tbf_requeue(struct sk_buff *skb, struct Qdisc* sch)
struct tbf_sched_data *q = qdisc_priv(sch);
int ret;
- ret = qdisc_requeue(skb, q->qdisc);
+ ret = qdisc_requeue(skb, q->class.qdisc);
if (ret == NET_XMIT_SUCCESS) {
sch->q.qlen++;
sch->qstats.requeues++;
@@ -164,7 +165,7 @@ static unsigned int tbf_drop(struct Qdisc* sch)
struct tbf_sched_data *q = qdisc_priv(sch);
unsigned int len = 0;
- len = qdisc_drop(q->qdisc);
+ len = qdisc_drop(q->class.qdisc);
if (len > 0) {
sch->q.qlen--;
sch->qstats.drops++;
@@ -177,7 +178,7 @@ static struct sk_buff *tbf_dequeue(struct Qdisc* sch)
struct tbf_sched_data *q = qdisc_priv(sch);
struct sk_buff *skb;
- skb = qdisc_dequeue(q->qdisc);
+ skb = qdisc_dequeue(q->class.qdisc);
if (skb) {
psched_time_t now;
@@ -222,9 +223,9 @@ static struct sk_buff *tbf_dequeue(struct Qdisc* sch)
(cf. CSZ, HPFQ, HFSC)
*/
- if (q->qdisc->ops->requeue(skb, q->qdisc) != NET_XMIT_SUCCESS) {
+ if (q->class.qdisc->ops->requeue(skb, q->class.qdisc) != NET_XMIT_SUCCESS) {
/* When requeue fails skb is dropped */
- qdisc_tree_decrease_qlen(q->qdisc, 1);
+ qdisc_tree_decrease_qlen(q->class.qdisc, 1);
sch->qstats.drops++;
}
@@ -237,7 +238,7 @@ static void tbf_reset(struct Qdisc* sch)
{
struct tbf_sched_data *q = qdisc_priv(sch);
- qdisc_reset(q->qdisc);
+ qdisc_reset(q->class.qdisc);
sch->q.qlen = 0;
q->t_c = psched_get_time();
q->tokens = q->buffer;
@@ -295,8 +296,8 @@ static int tbf_change(struct Qdisc* sch, struct rtattr *opt)
sch_tree_lock(sch);
if (child) {
- qdisc_tree_decrease_qlen(q->qdisc, q->qdisc->q.qlen);
- qdisc_destroy(xchg(&q->qdisc, child));
+ qdisc_tree_decrease_qlen(q->class.qdisc, q->class.qdisc->q.qlen);
+ qdisc_destroy(xchg(&q->class.qdisc, child));
}
q->limit = qopt->limit;
q->mtu = qopt->mtu;
@@ -325,7 +326,7 @@ static int tbf_init(struct Qdisc* sch, struct rtattr *opt)
q->t_c = psched_get_time();
qdisc_watchdog_init(&q->watchdog, sch);
- q->qdisc = &noop_qdisc;
+ q->class.qdisc = &noop_qdisc;
return tbf_change(sch, opt);
}
@@ -341,7 +342,7 @@ static void tbf_destroy(struct Qdisc *sch)
if (q->R_tab)
qdisc_put_rtab(q->R_tab);
- qdisc_destroy(q->qdisc);
+ qdisc_destroy(q->class.qdisc);
}
static int tbf_dump(struct Qdisc *sch, struct sk_buff *skb)
@@ -372,96 +373,8 @@ rtattr_failure:
return -1;
}
-static int tbf_dump_class(struct Qdisc *sch, unsigned long cl,
- struct sk_buff *skb, struct tcmsg *tcm)
-{
- struct tbf_sched_data *q = qdisc_priv(sch);
-
- if (cl != 1) /* only one class */
- return -ENOENT;
-
- tcm->tcm_handle |= TC_H_MIN(1);
- tcm->tcm_info = q->qdisc->handle;
-
- return 0;
-}
-
-static int tbf_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
- struct Qdisc **old)
-{
- struct tbf_sched_data *q = qdisc_priv(sch);
-
- if (new == NULL)
- new = &noop_qdisc;
-
- sch_tree_lock(sch);
- *old = xchg(&q->qdisc, new);
- qdisc_tree_decrease_qlen(*old, (*old)->q.qlen);
- qdisc_reset(*old);
- sch_tree_unlock(sch);
-
- return 0;
-}
-
-static struct Qdisc *tbf_leaf(struct Qdisc *sch, unsigned long arg)
-{
- struct tbf_sched_data *q = qdisc_priv(sch);
- return q->qdisc;
-}
-
-static unsigned long tbf_get(struct Qdisc *sch, u32 classid)
-{
- return 1;
-}
-
-static void tbf_put(struct Qdisc *sch, unsigned long arg)
-{
-}
-
-static int tbf_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
- struct rtattr **tca, unsigned long *arg)
-{
- return -ENOSYS;
-}
-
-static int tbf_delete(struct Qdisc *sch, unsigned long arg)
-{
- return -ENOSYS;
-}
-
-static void tbf_walk(struct Qdisc *sch, struct qdisc_walker *walker)
-{
- if (!walker->stop) {
- if (walker->count >= walker->skip)
- if (walker->fn(sch, 1, walker) < 0) {
- walker->stop = 1;
- return;
- }
- walker->count++;
- }
-}
-
-static struct tcf_proto **tbf_find_tcf(struct Qdisc *sch, unsigned long cl)
-{
- return NULL;
-}
-
-static const struct Qdisc_class_ops tbf_class_ops =
-{
- .graft = tbf_graft,
- .leaf = tbf_leaf,
- .get = tbf_get,
- .put = tbf_put,
- .change = tbf_change_class,
- .delete = tbf_delete,
- .walk = tbf_walk,
- .tcf_chain = tbf_find_tcf,
- .dump = tbf_dump_class,
-};
-
static struct Qdisc_ops tbf_qdisc_ops __read_mostly = {
- .next = NULL,
- .cl_ops = &tbf_class_ops,
+ .cl_ops = &pseudo_classful_ops,
.id = "tbf",
.priv_size = sizeof(struct tbf_sched_data),
.enqueue = tbf_enqueue,
^ permalink raw reply related
* Re: net 2.6.25 is broken when building with wireless/iwlwifi
From: Jeff Garzik @ 2008-01-20 19:23 UTC (permalink / raw)
To: Ian Brown
Cc: netdev-u79uwXL29TY76Z2rM5mHXA, John Linville,
linux-wireless-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <d0383f90801200601y71472ae6ha638c1567d4abde4-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
Ian Brown wrote:
> Hello,
> net 2.6.25 is broken when building with the wireless/iwlwifi
> subtree; we get the following errors (we noticed that iwl_down() and
> iwl_resume()
> implementation do exist in garzik tree, but there are more differences
> so a simple
> patch with only adding these two methods might be risky)
>
> ...
> ...
>
> CHK include/linux/version.h
> CHK include/linux/utsrelease.h
> CALL scripts/checksyscalls.sh
> CHK include/linux/compile.h
> CC [M] drivers/net/wireless/iwlwifi/iwl3945-base.o
> drivers/net/wireless/iwlwifi/iwl3945-base.c: In function 'iwl3945_pci_remove':
> drivers/net/wireless/iwlwifi/iwl3945-base.c:8639: error: implicit
> declaration of function 'iwl_down'
> drivers/net/wireless/iwlwifi/iwl3945-base.c: In function 'iwl3945_pci_resume':
> drivers/net/wireless/iwlwifi/iwl3945-base.c:8779: error: implicit
> declaration of function 'iwl_resume'
> make[4]: *** [drivers/net/wireless/iwlwifi/iwl3945-base.o] Error 1
> make[3]: *** [drivers/net/wireless/iwlwifi] Error 2
> make[2]: *** [drivers/net/wireless] Error 2
> make[1]: *** [drivers/net] Error 2
> make: *** [drivers] Error 2
hrm, that sounds like a potential mis-merge on my part (though
ultimately linville should be re-syncing with net-2.6.25 soon anyway)
Jeff
^ permalink raw reply
* 2.6.24 regression: reference count leak in PPPoE
From: Andi Kleen @ 2008-01-20 19:53 UTC (permalink / raw)
To: netdev, linux-kernel
My workstation running 2.6.24-rc8 just hung during shutdown with an endless
(or rather I didn't wait more than a few minutes) loop of
unregister_netdev: waiting for ppp-device to become free. Usage count = 1
ppp-device was an active PPPoE device.
No more information currently.
-Andi
^ permalink raw reply
* Re: 2.6.24 regression: reference count leak in PPPoE
From: Ingo Molnar @ 2008-01-20 20:01 UTC (permalink / raw)
To: Andi Kleen; +Cc: netdev, linux-kernel, Linus Torvalds
In-Reply-To: <200801202053.30386.ak@suse.de>
* Andi Kleen <ak@suse.de> wrote:
> My workstation running 2.6.24-rc8 just hung during shutdown with an
> endless (or rather I didn't wait more than a few minutes) loop of
>
> unregister_netdev: waiting for ppp-device to become free. Usage count
> = 1
>
> ppp-device was an active PPPoE device.
>
> No more information currently.
i've seen such problems (locked up box with endless loop of usage count
== 1) with pppoe in the past, and it seemed to be related to dynamic
IPs. (i saw that well before 2.6.24 - reported it once to davem)
It seems to have stopped when i stopped using ipsec and started using
vpnc. (but no firm info - this was sporadic - happened every few months
or so) Are you using ipsec and dynamic IPs by any chance?
Ingo
^ permalink raw reply
* Re: 2.6.24 regression: reference count leak in PPPoE
From: Daniel Lezcano @ 2008-01-20 20:09 UTC (permalink / raw)
To: Andi Kleen; +Cc: netdev, linux-kernel
In-Reply-To: <200801202053.30386.ak@suse.de>
Andi Kleen wrote:
> My workstation running 2.6.24-rc8 just hung during shutdown with an endless
> (or rather I didn't wait more than a few minutes) loop of
>
> unregister_netdev: waiting for ppp-device to become free. Usage count = 1
>
> ppp-device was an active PPPoE device.
>
> No more information currently.
>
> -Andi
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
I think this bug has been identified.
[Bug 9778] New: unregister_netdevice: waiting for [device] to become free
Thanks.
-- Daniel
^ permalink raw reply
* Re: 2.6.24 regression: reference count leak in PPPoE
From: Frans Pop @ 2008-01-20 20:14 UTC (permalink / raw)
To: Andi Kleen; +Cc: linux-kernel, netdev
In-Reply-To: <200801202053.30386.ak@suse.de>
Andi Kleen wrote:
> My workstation running 2.6.24-rc8 just hung during shutdown with an
> endless (or rather I didn't wait more than a few minutes) loop of
>
> unregister_netdev: waiting for ppp-device to become free. Usage count = 1
Same as http://lkml.org/lkml/2008/1/20/27? See also follow-up to that.
Cheers,
FJP
^ permalink raw reply
* Re: 2.6.24 regression: reference count leak in PPPoE
From: Malte Schröder @ 2008-01-20 20:16 UTC (permalink / raw)
To: Andi Kleen; +Cc: netdev, linux-kernel
In-Reply-To: <200801202053.30386.ak@suse.de>
[-- Attachment #1: Type: text/plain, Size: 771 bytes --]
On Sun, 20 Jan 2008 20:53:30 +0100
Andi Kleen <ak@suse.de> wrote:
>
> My workstation running 2.6.24-rc8 just hung during shutdown with an endless
> (or rather I didn't wait more than a few minutes) loop of
>
> unregister_netdev: waiting for ppp-device to become free. Usage count = 1
>
> ppp-device was an active PPPoE device.
>
> No more information currently.
Now that you mention it, this happened to me too this morning. My
system stops the ppp interface (pppoe) and starts it again (my provider
shuts down the link every 24 hours, I want that to happen during the
night, so I do a ifdown ppp0).
--
---------------------------------------
Malte Schröder
MalteSch@gmx.de
ICQ# 68121508
---------------------------------------
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox