[PATCH 2/3] net-2.6.24: wrap hard_header_parse

Previous thread: [PATCH 1/4] net: Dynamically allocate the per cpu counters for the loopback device. by Eric W. Biederman on Wednesday, September 26, 2007 - 4:53 pm. (16 messages)

Next thread: [PATCH] sky2: sky2 FE+ receive status workaround by Stephen Hemminger on Wednesday, September 26, 2007 - 5:58 pm. (9 messages)
From: Stephen Hemminger
Date: Wednesday, September 26, 2007 - 5:21 pm

Wrap the hard_header_parse function to simplify next step
of header_ops conversion.

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>

--- a/include/linux/netdevice.h	2007-09-26 16:26:03.000000000 -0700
+++ b/include/linux/netdevice.h	2007-09-26 16:26:04.000000000 -0700
@@ -657,7 +657,7 @@ struct net_device
 	void			(*vlan_rx_kill_vid)(struct net_device *dev,
 						    unsigned short vid);
 
-	int			(*hard_header_parse)(struct sk_buff *skb,
+	int			(*hard_header_parse)(const struct sk_buff *skb,
 						     unsigned char *haddr);
 	int			(*neigh_setup)(struct net_device *dev, struct neigh_parms *);
 #ifdef CONFIG_NETPOLL
@@ -810,6 +810,16 @@ static inline int dev_hard_header(struct
 	return dev->hard_header(skb, dev, type, daddr, saddr, len);
 }
 
+static inline int dev_parse_header(const struct sk_buff *skb,
+				   unsigned char *haddr)
+{
+	const struct net_device *dev = skb->dev;
+
+	if (!dev->hard_header_parse)
+		return 0;
+	return dev->hard_header_parse(skb, haddr);
+}
+
 typedef int gifconf_func_t(struct net_device * dev, char __user * bufptr, int len);
 extern int		register_gifconf(unsigned int family, gifconf_func_t * gifconf);
 static inline int unregister_gifconf(unsigned int family)
--- a/net/netfilter/nfnetlink_log.c	2007-09-26 15:07:35.000000000 -0700
+++ b/net/netfilter/nfnetlink_log.c	2007-09-26 16:26:04.000000000 -0700
@@ -481,12 +481,13 @@ __build_packet_message(struct nfulnl_ins
 		NFA_PUT(inst->skb, NFULA_MARK, sizeof(tmp_uint), &tmp_uint);
 	}
 
-	if (indev && skb->dev && skb->dev->hard_header_parse) {
+	if (indev && skb->dev) {
 		struct nfulnl_msg_packet_hw phw;
-		int len = skb->dev->hard_header_parse((struct sk_buff *)skb,
-						    phw.hw_addr);
-		phw.hw_addrlen = htons(len);
-		NFA_PUT(inst->skb, NFULA_HWADDR, sizeof(phw), &phw);
+		int len = dev_parse_header(skb, phw.hw_addr);
+		if (len > 0) {
+			phw.hw_addrlen = htons(len);
+			NFA_PUT(inst->skb, NFULA_HWADDR, sizeof(phw), &phw);
+		}
 	}
 
 	if ...
From: David Miller
Date: Wednesday, September 26, 2007 - 10:13 pm

From: Stephen Hemminger <shemminger@linux-foundation.org>

Applied.
-

Previous thread: [PATCH 1/4] net: Dynamically allocate the per cpu counters for the loopback device. by Eric W. Biederman on Wednesday, September 26, 2007 - 4:53 pm. (16 messages)

Next thread: [PATCH] sky2: sky2 FE+ receive status workaround by Stephen Hemminger on Wednesday, September 26, 2007 - 5:58 pm. (9 messages)