Skip to contentSkip to conversation

Diet struct net_device a bit

PATCH In review Pavel Emelyanov 3 participants 9 messages Oct 22, 2007 – Oct 24, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Diet struct net_device a bit

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.

#1 lore raw

PATCH 1/5 Cut off br_port fied from net_device

And add the forward declaration for br_handle_frame_hook in include/linux/if_bridge.h

---

include/linux/if_bridge.h +2 -0
index 58e43e5..a718586 100644
@@ -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);
include/linux/netdevice.h +2 -0
index 4a3f54e..469e04f 100644
@@ -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;
 
Signature · 1 line
1.5.3.4
#2 lore raw

Re: [Devel] [PATCH 1/5] Cut off br_port fied from net_device

include/linux/netdevice.h struct net_device · line 705

Quoted 13 lines · Pavel Emelyanov

And add the forward declaration for br_handle_frame_hook in include/linux/if_bridge.h

include/linux/netdevice.h +2 -0
@@ -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. :^)

#3 lore raw

Re: [Devel] [PATCH 1/5] Cut off br_port fied from net_device

Quoted 10 lines · Alexey Dobriyan
Quoted 9 lines · Pavel Emelyanov

And add the forward declaration for br_handle_frame_hook in include/linux/if_bridge.h

include/linux/netdevice.h +0 -0
@@ -699,8 +699,10 @@ struct net_device
 	/* Network namespace this network device is inside */
 	struct net		*nd_net;
 
Quoted 7 lines

include/linux/netdevice.h struct net_device · line 705

Quoted 4 lines
include/linux/netdevice.h +2 -0
+#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() ;)

Quoted 4 lines

IPv6 -- the biggest violator of this rule should not be taken as example. :^)

#4 lore raw

PATCH 2/5 Cut off macvlan_port from net_device

In reply to Pavel Emelyanov

---

include/linux/netdevice.h +2 -0
index 469e04f..c41a5c4 100644
@@ -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;
Signature · 1 line
1.5.3.4
#5 lore raw

PATCH 3/5 Cut off ax25_ptr from net_device

In reply to Pavel Emelyanov

---

include/linux/netdevice.h +2 -0
index c41a5c4..504f843 100644
@@ -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 */
 
Signature · 1 line
1.5.3.4
#6 lore raw

PATCH 4/5 Cut off ec_ptr from net_device

In reply to Pavel Emelyanov

---

include/linux/netdevice.h +2 -0
index 504f843..472d9cc 100644
@@ -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
Signature · 1 line
1.5.3.4
#7 lore raw

PATCH 5/5 Cut off dn_ptr from net_device

In reply to Pavel Emelyanov

And remove a BUG_TRAP from netdev_run_todo as well.

---

include/linux/netdevice.h +2 -0
index 472d9cc..e94c636 100644
@@ -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	*/
net/core/dev.c +2 -0
index 8726589..3ac35fe 100644
@@ -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);
Signature · 1 line
1.5.3.4
#8 lore raw
In reply to Pavel Emelyanov
Quoted 2 lines · Pavel Emelyanov

* 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