OpenVZ Forum


Home » Mailing lists » Devel » [PATCH 0/5] Diet struct net_device a bit
[PATCH 0/5] Diet struct net_device a bit [message #22143] Mon, 22 October 2007 12:31 Go to next message
Pavel Emelianov is currently offline  Pavel Emelianov
Messages: 1149
Registered: September 2006
Senior Member
There are some pointers, that are used in protocols/drivers/etc
in this struct. E.g. br_port, macvlan_port, ec_ptr, etc. Some of
them can be simply compile out with ifdefs, some require a bit
closer look.

Here's the summary:
Compiled out in this set with appropriate ifdef:
 * br_port
 * macvlan_port
 * dn_ptr
 * ec_ptr
 * ax25_ptr

Require a closer look:
 * atalk_ptr is shared with irda with "should we get our own 
   field?" comment;
 * ip_ptr and
 * ip6_ptr are used in headers and gcc complains when trying
   to compile net/socket.c that these fields are unreclared;
 * ieee80211_ptr is used in many wireless drivers. Need time
   to check for the config dependencies.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
[PATCH 1/5] Cut off br_port fied from net_device [message #22144 is a reply to message #22143] Mon, 22 October 2007 12:33 Go to previous messageGo to next message
Pavel Emelianov is currently offline  Pavel Emelianov
Messages: 1149
Registered: September 2006
Senior Member
And add the forward declaration for br_handle_frame_hook in
include/linux/if_bridge.h

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>

---

diff --git a/include/linux/if_bridge.h b/include/linux/if_bridge.h
index 58e43e5..a718586 100644
--- a/include/linux/if_bridge.h
+++ b/include/linux/if_bridge.h
@@ -104,6 +104,8 @@ struct __fdb_entry
 
 #include <linux/netdevice.h>
 
+struct net_bridge_port;
+
 extern void brioctl_set(int (*ioctl_hook)(struct net *, unsigned int, void __user *));
 extern struct sk_buff *(*br_handle_frame_hook)(struct net_bridge_port *p,
 					       struct sk_buff *skb);
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 4a3f54e..469e04f 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -699,8 +699,10 @@ struct net_device
 	/* Network namespace this network device is inside */
 	struct net		*nd_net;
 
+#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
 	/* bridge stuff */
 	struct net_bridge_port	*br_port;
+#endif
 	/* macvlan */
 	struct macvlan_port	*macvlan_port;
 
-- 
1.5.3.4
[PATCH 2/5] Cut off macvlan_port from net_device [message #22145 is a reply to message #22143] Mon, 22 October 2007 12:34 Go to previous messageGo to next message
Pavel Emelianov is currently offline  Pavel Emelianov
Messages: 1149
Registered: September 2006
Senior Member
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>

---

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 469e04f..c41a5c4 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -703,8 +703,10 @@ struct net_device
 	/* bridge stuff */
 	struct net_bridge_port	*br_port;
 #endif
+#if defined(CONFIG_MACVLAN) || defined(CONFIG_MACVLAN_MODULE)
 	/* macvlan */
 	struct macvlan_port	*macvlan_port;
+#endif
 
 	/* class/net/name entry */
 	struct device		dev;
-- 
1.5.3.4
[PATCH 3/5] Cut off ax25_ptr from net_device [message #22146 is a reply to message #22143] Mon, 22 October 2007 12:35 Go to previous messageGo to next message
Pavel Emelianov is currently offline  Pavel Emelianov
Messages: 1149
Registered: September 2006
Senior Member
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>

---

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index c41a5c4..504f843 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -580,7 +580,9 @@ struct net_device
 	void                    *dn_ptr;        /* DECnet specific data */
 	void                    *ip6_ptr;       /* IPv6 specific data */
 	void			*ec_ptr;	/* Econet specific data	*/
+#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
 	void			*ax25_ptr;	/* AX.25 specific data */
+#endif
 	struct wireless_dev	*ieee80211_ptr;	/* IEEE 802.11 specific data,
 						   assign before registering */
 
-- 
1.5.3.4
[PATCH 4/5] Cut off ec_ptr from net_device [message #22147 is a reply to message #22143] Mon, 22 October 2007 12:36 Go to previous messageGo to next message
Pavel Emelianov is currently offline  Pavel Emelianov
Messages: 1149
Registered: September 2006
Senior Member
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>

---

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 504f843..472d9cc 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -579,7 +579,9 @@ struct net_device
 	void			*ip_ptr;	/* IPv4 specific data	*/  
 	void                    *dn_ptr;        /* DECnet specific data */
 	void                    *ip6_ptr;       /* IPv6 specific data */
+#if defined(CONFIG_ECONET) || defined(CONFIG_ECONET_MODULE)
 	void			*ec_ptr;	/* Econet specific data	*/
+#endif
 #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
 	void			*ax25_ptr;	/* AX.25 specific data */
 #endif
-- 
1.5.3.4
[PATCH 5/5] Cut off dn_ptr from net_device [message #22148 is a reply to message #22143] Mon, 22 October 2007 12:37 Go to previous messageGo to next message
Pavel Emelianov is currently offline  Pavel Emelianov
Messages: 1149
Registered: September 2006
Senior Member
And remove a BUG_TRAP from netdev_run_todo as well.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>

---

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 472d9cc..e94c636 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -577,7 +577,9 @@ struct net_device
 	
 	void 			*atalk_ptr;	/* AppleTalk link 	*/
 	void			*ip_ptr;	/* IPv4 specific data	*/  
+#if defined(CONFIG_DECNET) || defined(CONFIG_DECNET_MODULE)
 	void                    *dn_ptr;        /* DECnet specific data */
+#endif
 	void                    *ip6_ptr;       /* IPv6 specific data */
 #if defined(CONFIG_ECONET) || defined(CONFIG_ECONET_MODULE)
 	void			*ec_ptr;	/* Econet specific data	*/
diff --git a/net/core/dev.c b/net/core/dev.c
index 8726589..3ac35fe 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3781,7 +3781,9 @@ void netdev_run_todo(void)
 		BUG_ON(atomic_read(&dev->refcnt));
 		BUG_TRAP(!dev->ip_ptr);
 		BUG_TRAP(!dev->ip6_ptr);
+#if defined(CONFIG_DECNET) || defined(CONFIG_DECNET_MODULE)
 		BUG_TRAP(!dev->dn_ptr);
+#endif
 
 		if (dev->destructor)
 			dev->destructor(dev);
-- 
1.5.3.4
Re: [PATCH 1/5] Cut off br_port fied from net_device [message #22149 is a reply to message #22144] Mon, 22 October 2007 12:49 Go to previous messageGo to next message
Alexey Dobriyan is currently offline  Alexey Dobriyan
Messages: 195
Registered: August 2006
Senior Member
On Mon, Oct 22, 2007 at 04:33:33PM +0400, Pavel Emelyanov wrote:
> And add the forward declaration for br_handle_frame_hook in
> include/linux/if_bridge.h

> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -699,8 +699,10 @@ struct net_device
>  	/* Network namespace this network device is inside */
>  	struct net		*nd_net;
>  
> +#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
>  	/* bridge stuff */
>  	struct net_bridge_port	*br_port;
> +#endif

Such ifdefs are troublesome, because one can compile kernel with
CONFIG_BRIDGE=n and later decide he needs BRIDGE=m and go boom.

IPv6 -- the biggest violator of this rule should not be taken as
example. :^)
Re: [PATCH 1/5] Cut off br_port fied from net_device [message #22151 is a reply to message #22149] Mon, 22 October 2007 13:02 Go to previous messageGo to next message
Pavel Emelianov is currently offline  Pavel Emelianov
Messages: 1149
Registered: September 2006
Senior Member
Alexey Dobriyan wrote:
> On Mon, Oct 22, 2007 at 04:33:33PM +0400, Pavel Emelyanov wrote:
>> And add the forward declaration for br_handle_frame_hook in
>> include/linux/if_bridge.h
> 
>> --- a/include/linux/netdevice.h
>> +++ b/include/linux/netdevice.h
>> @@ -699,8 +699,10 @@ struct net_device
>>  	/* Network namespace this network device is inside */
>>  	struct net		*nd_net;
>>  
>> +#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
>>  	/* bridge stuff */
>>  	struct net_bridge_port	*br_port;
>> +#endif
> 
> Such ifdefs are troublesome, because one can compile kernel with
> CONFIG_BRIDGE=n and later decide he needs BRIDGE=m and go boom.

You will have to recompile the whole kernel when this config
is on. Look at netif_receive_skb() ;)

> IPv6 -- the biggest violator of this rule should not be taken as
> example. :^)
> 
>
Re: [PATCH 0/5] Diet struct net_device a bit [message #22260 is a reply to message #22143] Tue, 23 October 2007 17:07 Go to previous message
Johannes Berg is currently offline  Johannes Berg
Messages: 16
Registered: April 2007
Junior Member
On Mon, 2007-10-22 at 16:31 +0400, Pavel Emelyanov wrote:

>  * ieee80211_ptr is used in many wireless drivers. Need time
>    to check for the config dependencies.

Depending on CFG80211 should be fine, if not that's a bug elsewhere.

johannes
Previous Topic: [PATCH] nf_sockopts list head cleanup
Next Topic: Re: LSM and Containers (was: LSM conversion to static interface)
Goto Forum:
  


Current Time: Fri Oct 18 21:31:42 GMT 2024

Total time taken to generate the page: 0.05159 seconds