move dev_mc_discard from dev_mcast.c to dev.c
Subsystems (2)
PATCH 1/4 move dev_mc_discard from dev_mcast.c to dev.c
because this function is only called by unregister_netdevice, this moving could make this non-global function static, and also remove a function declaration in netdevice.h
another way, the sequential call to dev_unicast_discard and then dev_mc_discard in unregister_netdevice have a similar mechanism that:
(netif_tx_lock_bh / __dev_addr_discard / netif_tx_unlock_bh), they should merged into one to eliminate duplicates in acquiring and releasing the dev->_xmit_lock, this would be done in my following patch.
--- include/linux/netdevice.h | 1 - net/core/dev.c | 12 ++++++++++++ net/core/dev_mcast.c | 12 ------------ 3 files changed, 12 insertions(+), 13 deletions(-)
include/linux/netdevice.h +0 -1
@@ -1108,7 +1108,6 @@ extern int dev_mc_delete(struct net_device *dev, void *addr, int alen, int allextern int dev_mc_add (struct net_device *dev,void *addr,int alen,int newonly);extern int dev_mc_sync (struct net_device *to,struct net_device *from);extern void dev_mc_unsync (struct net_device *to,struct net_device *from); -extern void dev_mc_discard (struct net_device *dev);extern int __dev_addr_delete (struct dev_addr_list **list,int *count,void *addr,int alen,int all);extern int __dev_addr_add (struct dev_addr_list **list,int *count,void *addr,int alen,int newonly);extern void __dev_addr_discard (struct dev_addr_list **list);
net/core/dev.c +12 -0
@@ -2785,6 +2785,18 @@ static void dev_unicast_discard(struct net_device *dev)netif_tx_unlock_bh (dev); } +/* +* Discard multicast list when a device is downed +*/ + +static void dev_mc_discard (struct net_device *dev) +{ +netif_tx_lock_bh (dev); +__dev_addr_discard (&dev->mc_list); + dev->mc_count =0 ; +netif_tx_unlock_bh (dev); +} +unsigned dev_get_flags (const struct net_device *dev) {unsigned flags;
net/core/dev_mcast.c +0 -12
@@ -177,18 +177,6 @@ void dev_mc_unsync(struct net_device *to, struct net_device *from) }EXPORT_SYMBOL (dev_mc_unsync); -/* -* Discard multicast list when a device is downed -*/ - -void dev_mc_discard (struct net_device *dev) -{ -netif_tx_lock_bh (dev); -__dev_addr_discard (&dev->mc_list); - dev->mc_count =0 ; -netif_tx_unlock_bh (dev); -} -#ifdef CONFIG_PROC_FS static void *dev_mc_seq_start (struct seq_file *seq,loff_t *pos) {
Signature · 1 line
1.5.2.2
PATCH 2/4 make non-global function __dev_addr_discard static
and remove its declaration in header file include/linux/netdevice.h
--- include/linux/netdevice.h | 1 - net/core/dev.c | 2 +- 2 files changed, 1 insertions(+), 2 deletions(-)
include/linux/netdevice.h +0 -1
@@ -1110,7 +1110,6 @@ extern int dev_mc_sync(struct net_device *to, struct net_device *from);extern void dev_mc_unsync (struct net_device *to,struct net_device *from);extern int __dev_addr_delete (struct dev_addr_list **list,int *count,void *addr,int alen,int all);extern int __dev_addr_add (struct dev_addr_list **list,int *count,void *addr,int alen,int newonly); -extern void __dev_addr_discard (struct dev_addr_list **list);extern void dev_set_promiscuity (struct net_device *dev,int inc);extern void dev_set_allmulti (struct net_device *dev,int inc);extern void netdev_state_change (struct net_device *dev);
net/core/dev.c +1 -1
@@ -2715,7 +2715,7 @@ int __dev_addr_add(struct dev_addr_list **list, int *count,return 0 ; } -void __dev_addr_discard (struct dev_addr_list **list) +static void __dev_addr_discard (struct dev_addr_list **list) {struct dev_addr_list *tmp;
Signature · 1 line
1.5.2.2
PATCH 3/4 merge dev_unicast_discard and dev_mc_discard into one
this two functions can share the dev->_xmit_lock acquired context.
--- net/core/dev.c | 16 ++++------------ 1 files changed, 4 insertions(+), 12 deletions(-)
net/core/dev.c +4 -12
@@ -2777,23 +2777,16 @@ int dev_unicast_add(struct net_device *dev, void *addr, int alen) }EXPORT_SYMBOL (dev_unicast_add); -static void dev_unicast_discard (struct net_device *dev) +static void dev_addr_discard (struct net_device *dev) {netif_tx_lock_bh (dev); +__dev_addr_discard (&dev->uc_list); dev->uc_count =0 ; -netif_tx_unlock_bh (dev); -} -/* -* Discard multicast list when a device is downed -*/ - -static void dev_mc_discard (struct net_device *dev) -{ -netif_tx_lock_bh (dev);__dev_addr_discard (&dev->mc_list); dev->mc_count =0 ; +netif_tx_unlock_bh (dev); }
@@ -3751,8 +3744,7 @@ void unregister_netdevice(struct net_device *dev)/* * Flush the unicast and multicast chains */ -dev_unicast_discard (dev); -dev_mc_discard (dev); +dev_addr_discard (dev);if (dev->uninit) dev->uninit (dev);
Signature · 1 line
1.5.2.2
PATCH 4/4 move __dev_addr_discard adjacent to dev_addr_discard for readability
--- net/core/dev.c | 28 ++++++++++++++-------------- 1 files changed, 14 insertions(+), 14 deletions(-)
net/core/dev.c +14 -14
@@ -2715,20 +2715,6 @@ int __dev_addr_add(struct dev_addr_list **list, int *count,return 0 ; } -static void __dev_addr_discard (struct dev_addr_list **list) -{ -struct dev_addr_list *tmp; - -while (*list !=NULL ) { - tmp = *list; - *list = tmp->next; -if (tmp->da_users > tmp->da_gusers) -printk ("__dev_addr_discard: address leakage! " -"da_users=%d\n" , tmp->da_users); -kfree (tmp); - } -} -/** * dev_unicast_delete - Release secondary unicast address. * @dev: device
@@ -2777,6 +2763,20 @@ int dev_unicast_add(struct net_device *dev, void *addr, int alen) }EXPORT_SYMBOL (dev_unicast_add); +static void __dev_addr_discard (struct dev_addr_list **list) +{ +struct dev_addr_list *tmp; + +while (*list !=NULL ) { + tmp = *list; + *list = tmp->next; +if (tmp->da_users > tmp->da_gusers) +printk ("__dev_addr_discard: address leakage! " +"da_users=%d\n" , tmp->da_users); +kfree (tmp); + } +} +static void dev_addr_discard (struct net_device *dev) {netif_tx_lock_bh (dev);
Signature · 1 line
1.5.2.2
PATCH 1/3 move dev_mc_discard from dev_mcast.c to dev.c
In reply to Denis ChengBecause this function is only called by unregister_netdevice, this moving could make this non-global function static, and also remove its declaration in netdevice.h;
Any further, function __dev_addr_discard is also just called by dev_mc_discard and dev_unicast_discard, keeping this two functions both in one c file could make __dev_addr_discard also static and remove its declaration in netdevice.h;
Futhermore, the sequential call to dev_unicast_discard and then dev_mc_discard in unregister_netdevice have a similar mechanism that:
(netif_tx_lock_bh / __dev_addr_discard / netif_tx_unlock_bh), they should merged into one to eliminate duplicates in acquiring and releasing the dev->_xmit_lock, this would be done in my following patch.
--- include/linux/netdevice.h | 2 -- net/core/dev.c | 14 +++++++++++++- net/core/dev_mcast.c | 12 ------------ 3 files changed, 13 insertions(+), 15 deletions(-)
include/linux/netdevice.h +0 -2
@@ -1098,10 +1098,8 @@ extern int dev_mc_delete(struct net_device *dev, void *addr, int alen, int allextern int dev_mc_add (struct net_device *dev,void *addr,int alen,int newonly);extern int dev_mc_sync (struct net_device *to,struct net_device *from);extern void dev_mc_unsync (struct net_device *to,struct net_device *from); -extern void dev_mc_discard (struct net_device *dev);extern int __dev_addr_delete (struct dev_addr_list **list,int *count,void *addr,int alen,int all);extern int __dev_addr_add (struct dev_addr_list **list,int *count,void *addr,int alen,int newonly); -extern void __dev_addr_discard (struct dev_addr_list **list);extern void dev_set_promiscuity (struct net_device *dev,int inc);extern void dev_set_allmulti (struct net_device *dev,int inc);extern void netdev_state_change (struct net_device *dev);
net/core/dev.c +13 -1
@@ -2715,7 +2715,7 @@ int __dev_addr_add(struct dev_addr_list **list, int *count,return 0 ; } -void __dev_addr_discard (struct dev_addr_list **list) +static void __dev_addr_discard (struct dev_addr_list **list) {struct dev_addr_list *tmp;
@@ -2785,6 +2785,18 @@ static void dev_unicast_discard(struct net_device *dev)netif_tx_unlock_bh (dev); } +/* +* Discard multicast list when a device is downed +*/ + +static void dev_mc_discard (struct net_device *dev) +{ +netif_tx_lock_bh (dev); +__dev_addr_discard (&dev->mc_list); + dev->mc_count =0 ; +netif_tx_unlock_bh (dev); +} +unsigned dev_get_flags (const struct net_device *dev) {unsigned flags;
net/core/dev_mcast.c +0 -12
@@ -177,18 +177,6 @@ void dev_mc_unsync(struct net_device *to, struct net_device *from) }EXPORT_SYMBOL (dev_mc_unsync); -/* -* Discard multicast list when a device is downed -*/ - -void dev_mc_discard (struct net_device *dev) -{ -netif_tx_lock_bh (dev); -__dev_addr_discard (&dev->mc_list); - dev->mc_count =0 ; -netif_tx_unlock_bh (dev); -} -#ifdef CONFIG_PROC_FS static void *dev_mc_seq_start (struct seq_file *seq,loff_t *pos) {
Signature · 1 line
1.5.2.2
PATCH 2/3 merge dev_unicast_discard and dev_mc_discard into one
this two functions could share the dev->_xmit_lock acquired context.
--- net/core/dev.c | 16 ++++------------ 1 files changed, 4 insertions(+), 12 deletions(-)
net/core/dev.c +4 -12
@@ -2777,23 +2777,16 @@ int dev_unicast_add(struct net_device *dev, void *addr, int alen) }EXPORT_SYMBOL (dev_unicast_add); -static void dev_unicast_discard (struct net_device *dev) +static void dev_addr_discard (struct net_device *dev) {netif_tx_lock_bh (dev); +__dev_addr_discard (&dev->uc_list); dev->uc_count =0 ; -netif_tx_unlock_bh (dev); -} -/* -* Discard multicast list when a device is downed -*/ - -static void dev_mc_discard (struct net_device *dev) -{ -netif_tx_lock_bh (dev);__dev_addr_discard (&dev->mc_list); dev->mc_count =0 ; +netif_tx_unlock_bh (dev); }
@@ -3751,8 +3744,7 @@ void unregister_netdevice(struct net_device *dev)/* * Flush the unicast and multicast chains */ -dev_unicast_discard (dev); -dev_mc_discard (dev); +dev_addr_discard (dev);if (dev->uninit) dev->uninit (dev);
Signature · 1 line
1.5.2.2
PATCH 3/3 move __dev_addr_discard adjacent to dev_addr_discard for readability
--- net/core/dev.c | 28 ++++++++++++++-------------- 1 files changed, 14 insertions(+), 14 deletions(-)
net/core/dev.c +14 -14
@@ -2715,20 +2715,6 @@ int __dev_addr_add(struct dev_addr_list **list, int *count,return 0 ; } -static void __dev_addr_discard (struct dev_addr_list **list) -{ -struct dev_addr_list *tmp; - -while (*list !=NULL ) { - tmp = *list; - *list = tmp->next; -if (tmp->da_users > tmp->da_gusers) -printk ("__dev_addr_discard: address leakage! " -"da_users=%d\n" , tmp->da_users); -kfree (tmp); - } -} -/** * dev_unicast_delete - Release secondary unicast address. * @dev: device
@@ -2777,6 +2763,20 @@ int dev_unicast_add(struct net_device *dev, void *addr, int alen) }EXPORT_SYMBOL (dev_unicast_add); +static void __dev_addr_discard (struct dev_addr_list **list) +{ +struct dev_addr_list *tmp; + +while (*list !=NULL ) { + tmp = *list; + *list = tmp->next; +if (tmp->da_users > tmp->da_gusers) +printk ("__dev_addr_discard: address leakage! " +"da_users=%d\n" , tmp->da_users); +kfree (tmp); + } +} +static void dev_addr_discard (struct net_device *dev) {netif_tx_lock_bh (dev);
Signature · 1 line
1.5.2.2
David Miller
maintainerRe: [PATCH 3/3] [net/core] move __dev_addr_discard adjacent to dev_addr_discard for readability
From: Denis Cheng <[email protected]>
Date: Wed, 18 Jul 2007 10:41:05 +0800
Quoted 1 line
Signed-off-by Denis Cheng <[email protected]>
Also applied, thank you.
Re: [PATCH 2/3] [net/core] merge dev_unicast_discard and dev_mc_discard into one
In reply to Denis ChengFrom: Denis Cheng <[email protected]>
Date: Wed, 18 Jul 2007 10:41:04 +0800
Quoted 3 lines
this two functions could share the
dev->_xmit_lockacquired context.Signed-off-by Denis Cheng <[email protected]>
Applied, thanks.
David Miller
maintainerFrom: Denis Cheng <[email protected]>
Date: Wed, 18 Jul 2007 10:41:03 +0800
Quoted 9 lines
Because this function is only called by
unregister_netdevice, this moving could make this non-global function static, and also remove its declaration innetdevice.h;Any further, function
__dev_addr_discardis also just called bydev_mc_discardanddev_unicast_discard, keeping this two functions both in one c file could make__dev_addr_discardalso static and remove its declaration innetdevice.h;
Quoted 7 lines
Futhermore, the sequential call to
dev_unicast_discardand thendev_mc_discardinunregister_netdevicehave a similar mechanism that:
(netif_tx_lock_bh/__dev_addr_discard/netif_tx_unlock_bh), they should merged into one to eliminate duplicates in acquiring and releasing thedev->_xmit_lock, this would be done in my following patch.Signed-off-by Denis Cheng <[email protected]>
Patch applied, thanks.
Quoted 18 lines · David Miller
From: Denis Cheng <[email protected]>
Date: Wed, 18 Jul 2007 10:41:03 +0800Quoted 15 lines
Because this function is only called by
unregister_netdevice, this moving could make this non-global function static, and also remove its declaration innetdevice.h;Any further, function
__dev_addr_discardis also just called bydev_mc_discardanddev_unicast_discard, keeping this two functions both in one c file could make__dev_addr_discardalso static and remove its declaration innetdevice.h;Futhermore, the sequential call to
dev_unicast_discardand thendev_mc_discardinunregister_netdevicehave a similar mechanism that:
(netif_tx_lock_bh/__dev_addr_discard/netif_tx_unlock_bh), they should merged into one to eliminate duplicates in acquiring and releasing thedev->_xmit_lock, this would be done in my following patch.
Quoted 3 lines
Quoted 1 line
Signed-off-by Denis Cheng <[email protected]>Patch applied, thanks.
Thanks for applying, too.
And then the dev_mcast.c is now only 256 lines long(versus dev.c 4052 lines), just left a few multicast related functions definition and "dev_mcast" procfs code,
I have an idea to merge all code dev_mcast.c into dev.c, that would:
- remove two functions (__dev_addr_delete, __dev_set_rx_mode) from netdevice.h, and then tag them static,
those two are also defined in dev.c and only called from dev_mcast.c,
- reducing one file would benefit the compilation process.
All in one word, I don't think the single file dev_mcast.c is needed anymore.
Quoted 1 line
Signature · 5 lines
Denis Cheng Linux Application Developer "One of my most productive days was throwing away 1000 lines of code." - Ken Thompson.
Quoted 2 lines · rae l
All in one word, I don't think the single file
dev_mcast.cis needed anymore.
Agreed. But dev.c is growing larger and larger, maybe dev_addr.c? Or dev_config.c, with some of the other device configuration functions?
David Miller
maintainerFrom: Patrick McHardy <[email protected]>
Date: Wed, 18 Jul 2007 12:01:38 +0200
Quoted 6 lines
Quoted 2 lines · rae l
All in one word, I don't think the single file
dev_mcast.cis needed anymore.Agreed. But
dev.cis growing larger and larger, maybedev_addr.c? Ordev_config.c, with some of the other device configuration functions?
I don't know, a sizable dev.c is inevitable, allows better refactoring and consolidation. And the be honest you're going to have to likely touch things in dev.c whenever you make changes to dev_addr.c or whatever you want to name it. :-)
Quoted 9 lines · David Miller
From: Patrick McHardy <[email protected]>
Date: Wed, 18 Jul 2007 12:01:38 +0200Quoted 5 lines
Quoted 2 lines · rae l
All in one word, I don't think the single file
dev_mcast.cis needed anymore.
Quoted 8 lines
Quoted 2 lines
Agreed. But
dev.cis growing larger and larger, maybedev_addr.c? Ordev_config.c, with some of the other device configuration functions?I don't know, a sizable
dev.cis inevitable, allows better refactoring and consolidation. And the be honest you're going to have to likely touch things indev.cwhenever you make changes todev_addr.cor whatever you want to name it. :-)
You're probably right. Killing dev_mcast.c makes sense to me though.
David Miller
maintainerFrom: "rae l" <[email protected]>
Date: Wed, 18 Jul 2007 17:59:52 +0800
Quoted 5 lines
And then the
dev_mcast.cis now only 256 lines long(versusdev.c4052 lines), just left a few multicast related functions definition and "dev_mcast" procfs code,
I have an idea to merge all codedev_mcast.cintodev.c, that would:
Quoted 7 lines
- remove two functions (
__dev_addr_delete,__dev_set_rx_mode) fromnetdevice.h, and then tag them static,
those two are also defined indev.cand only called fromdev_mcast.c,- reducing one file would benefit the compilation process.
All in one word, I don't think the single file
dev_mcast.cis needed anymore.
Agreed.
PATCH 1/2 net/core: merge the content of dev_mcast.c into dev.c
- removed three function declarations from header file to mark them static,
- reduced one file
---
this one is just merging by concatenating, and I'll try to adjust some function definitions' order to make it more readable.
include/linux/netdevice.h | 3 - net/core/Makefile | 2 +- net/core/dev.c | 239 +++++++++++++++++++++++++++++++++++++++++- net/core/dev_mcast.c | 255 --------------------------------------------- 4 files changed, 237 insertions(+), 262 deletions(-) delete mode 100644 net/core/dev_mcast.c
include/linux/netdevice.h +0 -3
@@ -1091,15 +1091,12 @@ extern int register_netdev(struct net_device *dev);extern void unregister_netdev (struct net_device *dev);/* Functions used for secondary unicast and multicast support */ extern void dev_set_rx_mode (struct net_device *dev); -extern void __dev_set_rx_mode (struct net_device *dev);extern int dev_unicast_delete (struct net_device *dev,void *addr,int alen);extern int dev_unicast_add (struct net_device *dev,void *addr,int alen);extern int dev_mc_delete (struct net_device *dev,void *addr,int alen,int all);extern int dev_mc_add (struct net_device *dev,void *addr,int alen,int newonly);extern int dev_mc_sync (struct net_device *to,struct net_device *from);extern void dev_mc_unsync (struct net_device *to,struct net_device *from); -extern int __dev_addr_delete (struct dev_addr_list **list,int *count,void *addr,int alen,int all); -extern int __dev_addr_add (struct dev_addr_list **list,int *count,void *addr,int alen,int newonly);extern void dev_set_promiscuity (struct net_device *dev,int inc);extern void dev_set_allmulti (struct net_device *dev,int inc);extern void netdev_state_change (struct net_device *dev);
net/core/Makefile +1 -1
@@ -7,7 +7,7 @@ obj-y := sock.o request_sock.o skbuff.o iovec.o datagram.o stream.o scm.o \ obj-$(CONFIG_SYSCTL) += sysctl_net_core.o -obj-y += dev.o ethtool.o dev_mcast.o dst.o netevent.o \ +obj-y += dev.o ethtool.o dst.o netevent.o \ neighbour.o rtnetlink.o utils.o link_watch.o filter.o obj-$(CONFIG_XFRM) += flow.o
net/core/dev.c +236 -3
272 lines not on this page · raw message
net/core/dev_mcast.c deleted +0 -255
255 lines not on this page · raw message
Signature · 1 line
1.5.2.2
PATCH 2/2 net/core: some functions' definition order adjustment for readability
--- net/core/dev.c | 407 ++++++++++++++++++++++++++++---------------------------- 1 files changed, 201 insertions(+), 206 deletions(-)
net/core/dev.c +201 -206
@@ -2790,6 +2790,134 @@ int dev_unicast_add(struct net_device *dev, void *addr, int alen) }EXPORT_SYMBOL (dev_unicast_add); +/* +* Device multicast list maintenance. +* +* This is used both by IP and by the user level maintenance functions. +* Unlike BSD we maintain a usage count on a given multicast address so +* that a casual user application can add/delete multicasts used by +* protocols without doing damage to the protocols when it deletes the +* entries. It also helps IP as it tracks overlapping maps. +* +* Device mc lists are changed by bh at least if IPv6 is enabled, +* so that it must be bh protected. +* +* We block accesses to device mc filters with netif_tx_lock. +*/ + +/* +* Delete a device level multicast +*/ +int dev_mc_delete (struct net_device *dev,void *addr,int alen,int glbl) +{ +int err; + +netif_tx_lock_bh (dev); + err =__dev_addr_delete (&dev->mc_list, &dev->mc_count, + addr, alen, glbl); +if (!err) { +/* +* We have altered the list, so the card +* loaded filter is now wrong. Fix it +*/ + +__dev_set_rx_mode (dev); + } +netif_tx_unlock_bh (dev); +return err; +} +EXPORT_SYMBOL (dev_mc_delete); + +/* +* Add a device level multicast +*/ +int dev_mc_add (struct net_device *dev,void *addr,int alen,int glbl) +{ +int err; + +netif_tx_lock_bh (dev); + err =__dev_addr_add (&dev->mc_list, &dev->mc_count, addr, alen, glbl); +if (!err) +__dev_set_rx_mode (dev); +netif_tx_unlock_bh (dev); +return err; +} +EXPORT_SYMBOL (dev_mc_add); + +/** +* dev_mc_sync - Synchronize device's multicast list to another device +* @to: destination device +* @from: source device +* +* Add newly added addresses to the destination device and release +* addresses that have no users left. The source device must be +* locked by netif_tx_lock_bh. +* +* This function is intended to be called from the dev->set_multicast_list +* function of layered software devices. +*/ +int dev_mc_sync (struct net_device *to,struct net_device *from) +{ +struct dev_addr_list *da; +int err =0 ; + +netif_tx_lock_bh (to); +for (da = from->mc_list; da !=NULL ; da = da->next) { +if (!da->da_synced) { + err =__dev_addr_add (&to->mc_list, &to->mc_count, + da->da_addr, da->da_addrlen,0 ); +if (err <0 ) +break ; + da->da_synced =1 ; + da->da_users++; + }else if (da->da_users ==1 ) { +__dev_addr_delete (&to->mc_list, &to->mc_count, + da->da_addr, da->da_addrlen,0 ); +__dev_addr_delete (&from->mc_list, &from->mc_count, + da->da_addr, da->da_addrlen,0 ); + } + } +if (!err) +__dev_set_rx_mode (to); +netif_tx_unlock_bh (to); + +return err; +} +EXPORT_SYMBOL (dev_mc_sync); + +/** +* dev_mc_unsync - Remove synchronized addresses from the destination +* device +* @to: destination device +* @from: source device +* +* Remove all addresses that were added to the destination device by +* dev_mc_sync(). This function is intended to be called from the +* dev->stop function of layered software devices. +*/ +void dev_mc_unsync (struct net_device *to,struct net_device *from) +{ +struct dev_addr_list *da; + +netif_tx_lock_bh (from); +netif_tx_lock_bh (to); + +for (da = from->mc_list; da !=NULL ; da = da->next) { +if (!da->da_synced) +continue ; +__dev_addr_delete (&to->mc_list, &to->mc_count, + da->da_addr, da->da_addrlen,0 ); + da->da_synced =0 ; +__dev_addr_delete (&from->mc_list, &from->mc_count, + da->da_addr, da->da_addrlen,0 ); + } +__dev_set_rx_mode (to); + +netif_tx_unlock_bh (to); +netif_tx_unlock_bh (from); +} +EXPORT_SYMBOL (dev_mc_unsync); +static void __dev_addr_discard (struct dev_addr_list **list) {struct dev_addr_list *tmp;
@@ -3963,6 +4091,79 @@ static int __init netdev_dma_register(void)static int __init netdev_dma_register (void ) {return -ENODEV ; }#endif /* CONFIG_NET_DMA */ +#ifdef CONFIG_PROC_FS +static void *dev_mc_seq_start (struct seq_file *seq,loff_t *pos) +{ +struct net_device *dev; +loff_t off =0 ; + +read_lock (&dev_base_lock); +for_each_netdev (dev) { +if (off++ == *pos) +return dev; + } +return NULL ; +} + +static void *dev_mc_seq_next (struct seq_file *seq,void *v,loff_t *pos) +{ + ++*pos; +return next_net_device ((struct net_device *)v); +} + +static void dev_mc_seq_stop (struct seq_file *seq,void *v) +{ +read_unlock (&dev_base_lock); +} + +static int dev_mc_seq_show (struct seq_file *seq,void *v) +{ +struct dev_addr_list *m; +struct net_device *dev = v; + +netif_tx_lock_bh (dev); +for (m = dev->mc_list; m; m = m->next) { +int i; + +seq_printf (seq,"%-4d %-15s %-5d %-5d " , dev->ifindex, + dev->name, m->dmi_users, m->dmi_gusers); + +for (i =0 ; i < m->dmi_addrlen; i++) +seq_printf (seq,"%02x" , m->dmi_addr[i]); + +seq_putc (seq,'\n' ); + } +netif_tx_unlock_bh (dev); +return 0 ; +} + +static const struct seq_operations dev_mc_seq_ops = { + .start = dev_mc_seq_start, + .next = dev_mc_seq_next, + .stop = dev_mc_seq_stop, + .show = dev_mc_seq_show, +}; + +static int dev_mc_seq_open (struct inode *inode,struct file *file) +{ +return seq_open (file, &dev_mc_seq_ops); +} + +static const struct file_operations dev_mc_seq_fops = { + .owner =THIS_MODULE , + .open = dev_mc_seq_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +#endif + +void __init dev_mcast_init (void ) +{ +proc_net_fops_create ("dev_mcast" ,0 , &dev_mc_seq_fops); +} +/* * Initialize the DEV module. At boot time this walks the device list and * unhooks any devices that fail to initialise (normally hardware not
@@ -4076,209 +4277,3 @@ EXPORT_SYMBOL(dev_load);#endif EXPORT_PER_CPU_SYMBOL (softnet_data); - -/* -* Device multicast list maintenance. -* -* This is used both by IP and by the user level maintenance functions. -* Unlike BSD we maintain a usage count on a given multicast address so -* that a casual user application can add/delete multicasts used by -* protocols without doing damage to the protocols when it deletes the -* entries. It also helps IP as it tracks overlapping maps. -* -* Device mc lists are changed by bh at least if IPv6 is enabled, -* so that it must be bh protected. -* -* We block accesses to device mc filters with netif_tx_lock. -*/ - -/* -* Delete a device level multicast -*/ - -int dev_mc_delete (struct net_device *dev,void *addr,int alen,int glbl) -{ -int err; - -netif_tx_lock_bh (dev); - err =__dev_addr_delete (&dev->mc_list, &dev->mc_count, - addr, alen, glbl); -if (!err) { -/* -* We have altered the list, so the card -* loaded filter is now wrong. Fix it -*/ - -__dev_set_rx_mode (dev); - } -netif_tx_unlock_bh (dev); -return err; -} - -/* -* Add a device level multicast -*/ - -int dev_mc_add (struct net_device *dev,void *addr,int alen,int glbl) -{ -int err; - -netif_tx_lock_bh (dev); - err =__dev_addr_add (&dev->mc_list, &dev->mc_count, addr, alen, glbl); -if (!err) -__dev_set_rx_mode (dev); -netif_tx_unlock_bh (dev); -return err; -} - -/** -* dev_mc_sync - Synchronize device's multicast list to another device -* @to: destination device -* @from: source device -* -* Add newly added addresses to the destination device and release -* addresses that have no users left. The source device must be -* locked by netif_tx_lock_bh. -* -* This function is intended to be called from the dev->set_multicast_list -* function of layered software devices. -*/ -int dev_mc_sync (struct net_device *to,struct net_device *from) -{ -struct dev_addr_list *da; -int err =0 ; - -netif_tx_lock_bh (to); -for (da = from->mc_list; da !=NULL ; da = da->next) { -if (!da->da_synced) { - err =__dev_addr_add (&to->mc_list, &to->mc_count, - da->da_addr, da->da_addrlen,0 ); -if (err <0 ) -break ; - da->da_synced =1 ; - da->da_users++; - }else if (da->da_users ==1 ) { -__dev_addr_delete (&to->mc_list, &to->mc_count, - da->da_addr, da->da_addrlen,0 ); -__dev_addr_delete (&from->mc_list, &from->mc_count, - da->da_addr, da->da_addrlen,0 ); - } - } -if (!err) -__dev_set_rx_mode (to); -netif_tx_unlock_bh (to); - -return err; -} -EXPORT_SYMBOL (dev_mc_sync); - - -/** -* dev_mc_unsync - Remove synchronized addresses from the destination -* device -* @to: destination device -* @from: source device -* -* Remove all addresses that were added to the destination device by -* dev_mc_sync(). This function is intended to be called from the -* dev->stop function of layered software devices. -*/ -void dev_mc_unsync (struct net_device *to,struct net_device *from) -{ -struct dev_addr_list *da; - -netif_tx_lock_bh (from); -netif_tx_lock_bh (to); - -for (da = from->mc_list; da !=NULL ; da = da->next) { -if (!da->da_synced) -continue ; -__dev_addr_delete (&to->mc_list, &to->mc_count, - da->da_addr, da->da_addrlen,0 ); - da->da_synced =0 ; -__dev_addr_delete (&from->mc_list, &from->mc_count, - da->da_addr, da->da_addrlen,0 ); - } -__dev_set_rx_mode (to); - -netif_tx_unlock_bh (to); -netif_tx_unlock_bh (from); -} -EXPORT_SYMBOL (dev_mc_unsync); - -#ifdef CONFIG_PROC_FS -static void *dev_mc_seq_start (struct seq_file *seq,loff_t *pos) -{ -struct net_device *dev; -loff_t off =0 ; - -read_lock (&dev_base_lock); -for_each_netdev (dev) { -if (off++ == *pos) -return dev; - } -return NULL ; -} - -static void *dev_mc_seq_next (struct seq_file *seq,void *v,loff_t *pos) -{ - ++*pos; -return next_net_device ((struct net_device *)v); -} - -static void dev_mc_seq_stop (struct seq_file *seq,void *v) -{ -read_unlock (&dev_base_lock); -} - - -static int dev_mc_seq_show (struct seq_file *seq,void *v) -{ -struct dev_addr_list *m; -struct net_device *dev = v; - -netif_tx_lock_bh (dev); -for (m = dev->mc_list; m; m = m->next) { -int i; - -seq_printf (seq,"%-4d %-15s %-5d %-5d " , dev->ifindex, - dev->name, m->dmi_users, m->dmi_gusers); - -for (i =0 ; i < m->dmi_addrlen; i++) -seq_printf (seq,"%02x" , m->dmi_addr[i]); - -seq_putc (seq,'\n' ); - } -netif_tx_unlock_bh (dev); -return 0 ; -} - -static const struct seq_operations dev_mc_seq_ops = { - .start = dev_mc_seq_start, - .next = dev_mc_seq_next, - .stop = dev_mc_seq_stop, - .show = dev_mc_seq_show, -}; - -static int dev_mc_seq_open (struct inode *inode,struct file *file) -{ -return seq_open (file, &dev_mc_seq_ops); -} - -static const struct file_operations dev_mc_seq_fops = { - .owner =THIS_MODULE , - .open = dev_mc_seq_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release, -}; - -#endif - -void __init dev_mcast_init (void ) -{ -proc_net_fops_create ("dev_mcast" ,0 , &dev_mc_seq_fops); -} - -EXPORT_SYMBOL (dev_mc_add); -EXPORT_SYMBOL (dev_mc_delete);
Signature · 1 line
1.5.2.2
Re: [PATCH 2/2] net/core: some functions' definition order adjustment for readability
This could be done in the patch moving it .. anyways,
net/core/dev.c static int __init netdev_dma_register(void) · line 4095
Quoted 2 lines · Denis Cheng
net/core/dev.c +2
-0+#ifdef CONFIG_PROC_FS +static void *dev_mc_seq_start (struct seq_file *seq,loff_t *pos)
If you're interested in doing more work, it would be nice to generalize the seq-file functions for unicast and multicast address lists and add /proc/net/dev_unicast or something like that.
OTOH we could also export this using rtnetlink. The main reason why I didn't do that is that it can only be read, not changed, but this is also true for statistics etc. Any opinions on this?
Re: [PATCH 2/2] net/core: some functions' definition order adjustment for readability
Quoted 1 line · Patrick McHardy
This could be done in the patch moving it .. anyways,
What?
Quoted 11 lines
net/core/dev.c static int __init netdev_dma_register(void) · line 4095
Quoted 2 lines · Denis Cheng
net/core/dev.c +2
-0+#ifdef CONFIG_PROC_FS +static void *dev_mc_seq_start (struct seq_file *seq,loff_t *pos)If you're interested in doing more work, it would be nice to generalize the seq-file functions for unicast and multicast address lists and add
/proc/net/dev_unicastor something like that.
Eh, there is already a dev_multicast file but lack of dev_unicast, but is dev_unicast really useful?
Quoted 4 lines
OTOH we could also export this using rtnetlink. The main reason why I didn't do that is that it can only be read, not changed, but this is also true for statistics etc. Any opinions on this?
how to do that?
Quoted 2 lines
Signature · 5 lines
Denis Cheng Linux Application Developer "One of my most productive days was throwing away 1000 lines of code." - Ken Thompson.
Re: [PATCH 1/2] net/core: merge the content of dev_mcast.c into dev.c
In reply to Denis ChengQuoted 593 lines · Denis Cheng
- removed three function declarations from header file to mark them static,
- reduced one fileSigned-off-by Denis Cheng <[email protected]>---
this one is just merging by concatenating, and I'll try to adjust some function definitions' order to make it more readable.
include/linux/netdevice.h | 3 - net/core/Makefile | 2 +- net/core/dev.c | 239 +++++++++++++++++++++++++++++++++++++++++- net/core/dev_mcast.c | 255 --------------------------------------------- 4 files changed, 237 insertions(+), 262 deletions(-) delete mode 100644 net/core/dev_mcast.cinclude/linux/netdevice.h +0
-3@@ -1091,15 +1091,12 @@ extern int register_netdev(struct net_device *dev);extern void unregister_netdev (struct net_device *dev);/* Functions used for secondary unicast and multicast support */ extern void dev_set_rx_mode (struct net_device *dev); -extern void __dev_set_rx_mode (struct net_device *dev);extern int dev_unicast_delete (struct net_device *dev,void *addr,int alen);extern int dev_unicast_add (struct net_device *dev,void *addr,int alen);extern int dev_mc_delete (struct net_device *dev,void *addr,int alen,int all);extern int dev_mc_add (struct net_device *dev,void *addr,int alen,int newonly);extern int dev_mc_sync (struct net_device *to,struct net_device *from);extern void dev_mc_unsync (struct net_device *to,struct net_device *from); -extern int __dev_addr_delete (struct dev_addr_list **list,int *count,void *addr,int alen,int all); -extern int __dev_addr_add (struct dev_addr_list **list,int *count,void *addr,int alen,int newonly);extern void dev_set_promiscuity (struct net_device *dev,int inc);extern void dev_set_allmulti (struct net_device *dev,int inc);extern void netdev_state_change (struct net_device *dev);net/core/Makefile +1
-1@@ -7,7 +7,7 @@ obj-y := sock.o request_sock.o skbuff.o iovec.o datagram.o stream.o scm.o \ obj-$(CONFIG_SYSCTL) += sysctl_net_core.o -obj-y += dev.o ethtool.o dev_mcast.o dst.o netevent.o \ +obj-y += dev.o ethtool.o dst.o netevent.o \ neighbour.o rtnetlink.o utils.o link_watch.o filter.o obj-$(CONFIG_XFRM) += flow.onet/core/dev.c +236
-3@@ -18,6 +18,7 @@* Alexey Kuznetsov <[email protected]> * Adam Sulmicki <[email protected]> * Pekka Riikonen <[email protected]> +* Denis Cheng <[email protected]> * * Changes: * D.J. Barrow : Fixed bug where dev->refcnt gets set @@ -70,6 +71,32 @@* indefinitely on dev->refcnt * J Hadi Salim : - Backlog queue sampling * - netif_rx() feedback +* Denis Cheng : Merge dev_mcast.c into it +*/ + +/* +* The original information in dev_mcast.c: +* +* Linux NET3: Multicast List maintenance. +* +* Authors: +* Tim Kordas <[email protected]> +* Richard Underwood <[email protected]> +* +* Stir fried together from the IP multicast and CAP patches above +* Alan Cox <[email protected]> +* +* Fixes: +* Alan Cox : Update the device on a real delete +* rather than any time but... +* Alan Cox : IFF_ALLMULTI support. +* Alan Cox : New format set_multicast_list() calls. +* Gleb Natapov : Remove dev_mc_lock. +* +* 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 <asm/uaccess.h> @@ -2622,7 +2649,7 @@ void dev_set_allmulti(struct net_device *dev, int inc)* filtering it is put in promiscous mode while unicast addresses * are present. */ -void __dev_set_rx_mode (struct net_device *dev) +static void __dev_set_rx_mode (struct net_device *dev) {/* dev_open will call this function so the list will stay sane. */ if (!(dev->flags&IFF_UP ))@@ -2657,7 +2684,7 @@ void dev_set_rx_mode(struct net_device *dev)netif_tx_unlock_bh (dev); } -int __dev_addr_delete (struct dev_addr_list **list,int *count, +static int __dev_addr_delete (struct dev_addr_list **list,int *count,void *addr,int alen,int glbl) {struct dev_addr_list *da;@@ -2683,7 +2710,7 @@ int __dev_addr_delete(struct dev_addr_list **list, int *count,return -ENOENT ; } -int __dev_addr_add (struct dev_addr_list **list,int *count, +static int __dev_addr_add (struct dev_addr_list **list,int *count,void *addr,int alen,int glbl) {struct dev_addr_list *da;@@ -4049,3 +4076,209 @@ EXPORT_SYMBOL(dev_load);#endif EXPORT_PER_CPU_SYMBOL (softnet_data); + +/* +* Device multicast list maintenance. +* +* This is used both by IP and by the user level maintenance functions. +* Unlike BSD we maintain a usage count on a given multicast address so +* that a casual user application can add/delete multicasts used by +* protocols without doing damage to the protocols when it deletes the +* entries. It also helps IP as it tracks overlapping maps. +* +* Device mc lists are changed by bh at least if IPv6 is enabled, +* so that it must be bh protected. +* +* We block accesses to device mc filters with netif_tx_lock. +*/ + +/* +* Delete a device level multicast +*/ + +int dev_mc_delete (struct net_device *dev,void *addr,int alen,int glbl) +{ +int err; + +netif_tx_lock_bh (dev); + err =__dev_addr_delete (&dev->mc_list, &dev->mc_count, + addr, alen, glbl); +if (!err) { +/* +* We have altered the list, so the card +* loaded filter is now wrong. Fix it +*/ + +__dev_set_rx_mode (dev); + } +netif_tx_unlock_bh (dev); +return err; +} + +/* +* Add a device level multicast +*/ + +int dev_mc_add (struct net_device *dev,void *addr,int alen,int glbl) +{ +int err; + +netif_tx_lock_bh (dev); + err =__dev_addr_add (&dev->mc_list, &dev->mc_count, addr, alen, glbl); +if (!err) +__dev_set_rx_mode (dev); +netif_tx_unlock_bh (dev); +return err; +} + +/** +* dev_mc_sync - Synchronize device's multicast list to another device +* @to: destination device +* @from: source device +* +* Add newly added addresses to the destination device and release +* addresses that have no users left. The source device must be +* locked by netif_tx_lock_bh. +* +* This function is intended to be called from the dev->set_multicast_list +* function of layered software devices. +*/ +int dev_mc_sync (struct net_device *to,struct net_device *from) +{ +struct dev_addr_list *da; +int err =0 ; + +netif_tx_lock_bh (to); +for (da = from->mc_list; da !=NULL ; da = da->next) { +if (!da->da_synced) { + err =__dev_addr_add (&to->mc_list, &to->mc_count, + da->da_addr, da->da_addrlen,0 ); +if (err <0 ) +break ; + da->da_synced =1 ; + da->da_users++; + }else if (da->da_users ==1 ) { +__dev_addr_delete (&to->mc_list, &to->mc_count, + da->da_addr, da->da_addrlen,0 ); +__dev_addr_delete (&from->mc_list, &from->mc_count, + da->da_addr, da->da_addrlen,0 ); + } + } +if (!err) +__dev_set_rx_mode (to); +netif_tx_unlock_bh (to); + +return err; +} +EXPORT_SYMBOL (dev_mc_sync); + + +/** +* dev_mc_unsync - Remove synchronized addresses from the destination +* device +* @to: destination device +* @from: source device +* +* Remove all addresses that were added to the destination device by +* dev_mc_sync(). This function is intended to be called from the +* dev->stop function of layered software devices. +*/ +void dev_mc_unsync (struct net_device *to,struct net_device *from) +{ +struct dev_addr_list *da; + +netif_tx_lock_bh (from); +netif_tx_lock_bh (to); + +for (da = from->mc_list; da !=NULL ; da = da->next) { +if (!da->da_synced) +continue ; +__dev_addr_delete (&to->mc_list, &to->mc_count, + da->da_addr, da->da_addrlen,0 ); + da->da_synced =0 ; +__dev_addr_delete (&from->mc_list, &from->mc_count, + da->da_addr, da->da_addrlen,0 ); + } +__dev_set_rx_mode (to); + +netif_tx_unlock_bh (to); +netif_tx_unlock_bh (from); +} +EXPORT_SYMBOL (dev_mc_unsync); + +#ifdef CONFIG_PROC_FS +static void *dev_mc_seq_start (struct seq_file *seq,loff_t *pos) +{ +struct net_device *dev; +loff_t off =0 ; + +read_lock (&dev_base_lock); +for_each_netdev (dev) { +if (off++ == *pos) +return dev; + } +return NULL ; +} + +static void *dev_mc_seq_next (struct seq_file *seq,void *v,loff_t *pos) +{ + ++*pos; +return next_net_device ((struct net_device *)v); +} + +static void dev_mc_seq_stop (struct seq_file *seq,void *v) +{ +read_unlock (&dev_base_lock); +} + + +static int dev_mc_seq_show (struct seq_file *seq,void *v) +{ +struct dev_addr_list *m; +struct net_device *dev = v; + +netif_tx_lock_bh (dev); +for (m = dev->mc_list; m; m = m->next) { +int i; + +seq_printf (seq,"%-4d %-15s %-5d %-5d " , dev->ifindex, + dev->name, m->dmi_users, m->dmi_gusers); + +for (i =0 ; i < m->dmi_addrlen; i++) +seq_printf (seq,"%02x" , m->dmi_addr[i]); + +seq_putc (seq,'\n' ); + } +netif_tx_unlock_bh (dev); +return 0 ; +} + +static const struct seq_operations dev_mc_seq_ops = { + .start = dev_mc_seq_start, + .next = dev_mc_seq_next, + .stop = dev_mc_seq_stop, + .show = dev_mc_seq_show, +}; + +static int dev_mc_seq_open (struct inode *inode,struct file *file) +{ +return seq_open (file, &dev_mc_seq_ops); +} + +static const struct file_operations dev_mc_seq_fops = { + .owner =THIS_MODULE , + .open = dev_mc_seq_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +#endif + +void __init dev_mcast_init (void ) +{ +proc_net_fops_create ("dev_mcast" ,0 , &dev_mc_seq_fops); +} + +EXPORT_SYMBOL (dev_mc_add); +EXPORT_SYMBOL (dev_mc_delete);net/core/dev_mcast.c deleted +0
-256@@ -1,255 +0,0 @@ -/* -* Linux NET3: Multicast List maintenance. -* -* Authors: -* Tim Kordas <[email protected]> -* Richard Underwood <[email protected]> -* -* Stir fried together from the IP multicast and CAP patches above -* Alan Cox <[email protected]> -* -* Fixes: -* Alan Cox : Update the device on a real delete -* rather than any time but... -* Alan Cox : IFF_ALLMULTI support. -* Alan Cox : New format set_multicast_list() calls. -* Gleb Natapov : Remove dev_mc_lock. -* -* 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 <asm/uaccess.h> -#include <asm/system.h> -#include <linux/bitops.h> -#include <linux/types.h> -#include <linux/kernel.h> -#include <linux/string.h> -#include <linux/mm.h> -#include <linux/socket.h> -#include <linux/sockios.h> -#include <linux/in.h> -#include <linux/errno.h> -#include <linux/interrupt.h> -#include <linux/if_ether.h> -#include <linux/inet.h> -#include <linux/netdevice.h> -#include <linux/etherdevice.h> -#include <linux/proc_fs.h> -#include <linux/seq_file.h> -#include <linux/init.h> -#include <net/ip.h> -#include <net/route.h> -#include <linux/skbuff.h> -#include <net/sock.h> -#include <net/arp.h> - - -/* -* Device multicast list maintenance. -* -* This is used both by IP and by the user level maintenance functions. -* Unlike BSD we maintain a usage count on a given multicast address so -* that a casual user application can add/delete multicasts used by -* protocols without doing damage to the protocols when it deletes the -* entries. It also helps IP as it tracks overlapping maps. -* -* Device mc lists are changed by bh at least if IPv6 is enabled, -* so that it must be bh protected. -* -* We block accesses to device mc filters with netif_tx_lock. -*/ - -/* -* Delete a device level multicast -*/ - -int dev_mc_delete (struct net_device *dev,void *addr,int alen,int glbl) -{ -int err; - -netif_tx_lock_bh (dev); - err =__dev_addr_delete (&dev->mc_list, &dev->mc_count, - addr, alen, glbl); -if (!err) { -/* -* We have altered the list, so the card -* loaded filter is now wrong. Fix it -*/ - -__dev_set_rx_mode (dev); - } -netif_tx_unlock_bh (dev); -return err; -} - -/* -* Add a device level multicast -*/ - -int dev_mc_add (struct net_device *dev,void *addr,int alen,int glbl) -{ -int err; - -netif_tx_lock_bh (dev); - err =__dev_addr_add (&dev->mc_list, &dev->mc_count, addr, alen, glbl); -if (!err) -__dev_set_rx_mode (dev); -netif_tx_unlock_bh (dev); -return err; -} - -/** -* dev_mc_sync - Synchronize device's multicast list to another device -* @to: destination device -* @from: source device -* -* Add newly added addresses to the destination device and release -* addresses that have no users left. The source device must be -* locked by netif_tx_lock_bh. -* -* This function is intended to be called from the dev->set_multicast_list -* function of layered software devices. -*/ -int dev_mc_sync (struct net_device *to,struct net_device *from) -{ -struct dev_addr_list *da; -int err =0 ; - -netif_tx_lock_bh (to); -for (da = from->mc_list; da !=NULL ; da = da->next) { -if (!da->da_synced) { - err =__dev_addr_add (&to->mc_list, &to->mc_count, - da->da_addr, da->da_addrlen,0 ); -if (err <0 ) -break ; - da->da_synced =1 ; - da->da_users++; - }else if (da->da_users ==1 ) { -__dev_addr_delete (&to->mc_list, &to->mc_count, - da->da_addr, da->da_addrlen,0 ); -__dev_addr_delete (&from->mc_list, &from->mc_count, - da->da_addr, da->da_addrlen,0 ); - } - } -if (!err) -__dev_set_rx_mode (to); -netif_tx_unlock_bh (to); - -return err; -} -EXPORT_SYMBOL (dev_mc_sync); - - -/** -* dev_mc_unsync - Remove synchronized addresses from the destination -* device -* @to: destination device -* @from: source device -* -* Remove all addresses that were added to the destination device by -* dev_mc_sync(). This function is intended to be called from the -* dev->stop function of layered software devices. -*/ -void dev_mc_unsync (struct net_device *to,struct net_device *from) -{ -struct dev_addr_list *da; - -netif_tx_lock_bh (from); -netif_tx_lock_bh (to); - -for (da = from->mc_list; da !=NULL ; da = da->next) { -if (!da->da_synced) -continue ; -__dev_addr_delete (&to->mc_list, &to->mc_count, - da->da_addr, da->da_addrlen,0 ); - da->da_synced =0 ; -__dev_addr_delete (&from->mc_list, &from->mc_count, - da->da_addr, da->da_addrlen,0 ); - } -__dev_set_rx_mode (to); - -netif_tx_unlock_bh (to); -netif_tx_unlock_bh (from); -} -EXPORT_SYMBOL (dev_mc_unsync); - -#ifdef CONFIG_PROC_FS -static void *dev_mc_seq_start (struct seq_file *seq,loff_t *pos) -{ -struct net_device *dev; -loff_t off =0 ; - -read_lock (&dev_base_lock); -for_each_netdev (dev) { -if (off++ == *pos) -return dev; - } -return NULL ; -} - -static void *dev_mc_seq_next (struct seq_file *seq,void *v,loff_t *pos) -{ - ++*pos; -return next_net_device ((struct net_device *)v); -} - -static void dev_mc_seq_stop (struct seq_file *seq,void *v) -{ -read_unlock (&dev_base_lock); -} - - -static int dev_mc_seq_show (struct seq_file *seq,void *v) -{ -struct dev_addr_list *m; -struct net_device *dev = v; - -netif_tx_lock_bh (dev); -for (m = dev->mc_list; m; m = m->next) { -int i; - -seq_printf (seq,"%-4d %-15s %-5d %-5d " , dev->ifindex, - dev->name, m->dmi_users, m->dmi_gusers); - -for (i =0 ; i < m->dmi_addrlen; i++) -seq_printf (seq,"%02x" , m->dmi_addr[i]); - -seq_putc (seq,'\n' ); - } -netif_tx_unlock_bh (dev); -return 0 ; -} - -static const struct seq_operations dev_mc_seq_ops = { - .start = dev_mc_seq_start, - .next = dev_mc_seq_next, - .stop = dev_mc_seq_stop, - .show = dev_mc_seq_show, -}; - -static int dev_mc_seq_open (struct inode *inode,struct file *file) -{ -return seq_open (file, &dev_mc_seq_ops); -} - -static const struct file_operations dev_mc_seq_fops = { - .owner =THIS_MODULE , - .open = dev_mc_seq_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release, -}; - -#endif - -void __init dev_mcast_init (void ) -{ -proc_net_fops_create ("dev_mcast" ,0 , &dev_mc_seq_fops); -} - -EXPORT_SYMBOL (dev_mc_add); -EXPORT_SYMBOL (dev_mc_delete); --
Quoted 1 line
1.5.2.2
Is there any more comments on this?
Quoted 2 lines
Signature · 5 lines
Denis Cheng Linux Application Developer "One of my most productive days was throwing away 1000 lines of code." - Ken Thompson.
David Miller
maintainerRe: [PATCH 1/2] net/core: merge the content of dev_mcast.c into dev.c
From: "rae l" <[email protected]>
Date: Fri, 20 Jul 2007 09:51:05 +0800
Quoted 1 line
Is there any more comments on this?
Please don't quote a big huge patch just to say one sentence that doesn't apply to any particular specific part of a patch.
That's wastes bandwidth, annoys people you might actually want a response from, and is bad netiquette in general.
Re: [PATCH 1/2] net/core: merge the content of dev_mcast.c into dev.c
Quoted 5 lines · David Miller
Please don't quote a big huge patch just to say one sentence that doesn't apply to any particular specific part of a patch.
That's wastes bandwidth, annoys people you might actually want a response from, and is bad netiquette in general.
Thanks.
Quoted 1 line
Signature · 5 lines
Denis Cheng Linux Application Developer "One of my most productive days was throwing away 1000 lines of code." - Ken Thompson.