[NET]: Wrap hard_header_parse
authorStephen Hemminger <shemminger@linux-foundation.org>
Thu, 27 Sep 2007 05:13:38 +0000 (22:13 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Wed, 10 Oct 2007 23:52:51 +0000 (16:52 -0700)
Wrap the hard_header_parse function to simplify next step of
header_ops conversion.

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/ieee1394/eth1394.c
drivers/net/wireless/airo.c
drivers/s390/net/qeth_main.c
include/linux/netdevice.h
net/ethernet/eth.c
net/ipv4/netfilter/ip_queue.c
net/ipv6/netfilter/ip6_queue.c
net/mac80211/ieee80211.c
net/netfilter/nfnetlink_log.c
net/netfilter/nfnetlink_queue.c
net/packet/af_packet.c

index 33b80817d68c4c6539b64d967fb9cc92d8726c44..b31f90082e359f3ac14d5da45bf36a686f3fa6bb 100644 (file)
@@ -162,7 +162,8 @@ static int ether1394_header(struct sk_buff *skb, struct net_device *dev,
                            unsigned short type, void *daddr, void *saddr,
                            unsigned len);
 static int ether1394_rebuild_header(struct sk_buff *skb);
-static int ether1394_header_parse(struct sk_buff *skb, unsigned char *haddr);
+static int ether1394_header_parse(const struct sk_buff *skb,
+                                 unsigned char *haddr);
 static int ether1394_header_cache(struct neighbour *neigh, struct hh_cache *hh);
 static void ether1394_header_cache_update(struct hh_cache *hh,
                                          struct net_device *dev,
@@ -751,11 +752,10 @@ static int ether1394_rebuild_header(struct sk_buff *skb)
        return 0;
 }
 
-static int ether1394_header_parse(struct sk_buff *skb, unsigned char *haddr)
+static int ether1394_header_parse(const struct sk_buff *skb,
+                                 unsigned char *haddr)
 {
-       struct net_device *dev = skb->dev;
-
-       memcpy(haddr, dev->dev_addr, ETH1394_ALEN);
+       memcpy(haddr, skb->dev->dev_addr, ETH1394_ALEN);
        return ETH1394_ALEN;
 }
 
index 95d3cd1c49a76812b44f77c6e9bfa390a9c4d22d..cd03a61359aac2bfb0e3052f6840bb42fc2a7936 100644 (file)
@@ -2481,7 +2481,7 @@ void stop_airo_card( struct net_device *dev, int freeres )
 
 EXPORT_SYMBOL(stop_airo_card);
 
-static int wll_header_parse(struct sk_buff *skb, unsigned char *haddr)
+static int wll_header_parse(const struct sk_buff *skb, unsigned char *haddr)
 {
        memcpy(haddr, skb_mac_header(skb) + 10, ETH_ALEN);
        return ETH_ALEN;
@@ -2698,11 +2698,6 @@ static int mpi_map_card(struct airo_info *ai, struct pci_dev *pci)
 
 static void wifi_setup(struct net_device *dev)
 {
-       dev->hard_header        = NULL;
-       dev->rebuild_header     = NULL;
-       dev->hard_header_cache  = NULL;
-       dev->header_cache_update= NULL;
-
        dev->hard_header_parse  = wll_header_parse;
        dev->hard_start_xmit = &airo_start_xmit11;
        dev->get_stats = &airo_get_stats;
index 8c46978e0afaef611ba317442d5d62204b852a34..65225b3989ddcbe6cfcfd124ad6599158fa4ca40 100644 (file)
@@ -6561,10 +6561,10 @@ static struct ethtool_ops qeth_ethtool_ops = {
 };
 
 static int
-qeth_hard_header_parse(struct sk_buff *skb, unsigned char *haddr)
+qeth_hard_header_parse(const struct sk_buff *skb, unsigned char *haddr)
 {
-       struct qeth_card *card;
-       struct ethhdr *eth;
+       const struct qeth_card *card;
+       const struct ethhdr *eth;
 
        card = qeth_get_card_from_dev(skb->dev);
        if (card->options.layer2)
index b33d084712fa410b7c8348f4bb628c65447fb07b..aae9ec367f5d295c4e0fb6d1cbeee42186ccac4f 100644 (file)
@@ -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
@@ -809,6 +809,16 @@ static inline int dev_hard_header(struct sk_buff *skb, struct net_device *dev,
        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)
index 2aaf6faf74ac195333a571a48167c90409bd9be0..bdeb2f0ace32e404680215ba98f008a39beefa17 100644 (file)
@@ -207,9 +207,9 @@ EXPORT_SYMBOL(eth_type_trans);
  * @skb: packet to extract header from
  * @haddr: destination buffer
  */
-static int eth_header_parse(struct sk_buff *skb, unsigned char *haddr)
+static int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr)
 {
-       struct ethhdr *eth = eth_hdr(skb);
+       const struct ethhdr *eth = eth_hdr(skb);
        memcpy(haddr, eth->h_source, ETH_ALEN);
        return ETH_ALEN;
 }
index 82fda92e6b97b106d0dad050a7f63774d0551483..aaa3f5c567611ab77168d0104ea0b61fd6671cba 100644 (file)
@@ -250,10 +250,8 @@ ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp)
 
        if (entry->info->indev && entry->skb->dev) {
                pmsg->hw_type = entry->skb->dev->type;
-               if (entry->skb->dev->hard_header_parse)
-                       pmsg->hw_addrlen =
-                               entry->skb->dev->hard_header_parse(entry->skb,
-                                                                  pmsg->hw_addr);
+               pmsg->hw_addrlen = dev_parse_header(entry->skb,
+                                                   pmsg->hw_addr);
        }
 
        if (data_len)
index 2f5a5245383425616a864b9c1df1690c6329be39..c75f467a8f51175c4f536109b3742e85994f20a3 100644 (file)
@@ -248,10 +248,7 @@ ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp)
 
        if (entry->info->indev && entry->skb->dev) {
                pmsg->hw_type = entry->skb->dev->type;
-               if (entry->skb->dev->hard_header_parse)
-                       pmsg->hw_addrlen =
-                               entry->skb->dev->hard_header_parse(entry->skb,
-                                                                  pmsg->hw_addr);
+               pmsg->hw_addrlen = dev_parse_header(entry->skb, pmsg->hw_addr);
        }
 
        if (data_len)
index 89be6629cfc0544d8e4e0437bdc2ff49c9372d55..0cdcf0d0c6ca847b059214da1df3ddeb440f2cc9 100644 (file)
@@ -47,7 +47,7 @@ struct ieee80211_tx_status_rtap_hdr {
 
 /* common interface routines */
 
-static int header_parse_80211(struct sk_buff *skb, unsigned char *haddr)
+static int header_parse_80211(const struct sk_buff *skb, unsigned char *haddr)
 {
        memcpy(haddr, skb_mac_header(skb) + 10, ETH_ALEN); /* addr2 */
        return ETH_ALEN;
index 8e4001b8f76469ec454a9f5e3e3d86dce9c68ff1..332e0f7f6f9eb0085e43e39fbc0fa08e0b770e43 100644 (file)
@@ -481,12 +481,13 @@ __build_packet_message(struct nfulnl_instance *inst,
                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 (skb->tstamp.tv64) {
index c97369f48db7844482cd15eaa648e297166139a7..a813185c766d7987041bb57e9ac3959d9ae06520 100644 (file)
@@ -485,14 +485,13 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue,
                NFA_PUT(skb, NFQA_MARK, sizeof(u_int32_t), &tmp_uint);
        }
 
-       if (indev && entskb->dev
-           && entskb->dev->hard_header_parse) {
+       if (indev && entskb->dev) {
                struct nfqnl_msg_packet_hw phw;
-
-               int len = entskb->dev->hard_header_parse(entskb,
-                                                          phw.hw_addr);
-               phw.hw_addrlen = htons(len);
-               NFA_PUT(skb, NFQA_HWADDR, sizeof(phw), &phw);
+               int len = dev_parse_header(entskb, phw.hw_addr);
+               if (len) {
+                       phw.hw_addrlen = htons(len);
+                       NFA_PUT(skb, NFQA_HWADDR, sizeof(phw), &phw);
+               }
        }
 
        if (entskb->tstamp.tv64) {
index c5244b3096403e510f49a24d087eb9fed49d0dbb..c9ee343c2a6c5d7d4074448a8b87ee234622a3c8 100644 (file)
@@ -519,10 +519,8 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev, struct packet
                sll->sll_ifindex = orig_dev->ifindex;
        else
                sll->sll_ifindex = dev->ifindex;
-       sll->sll_halen = 0;
 
-       if (dev->hard_header_parse)
-               sll->sll_halen = dev->hard_header_parse(skb, sll->sll_addr);
+       sll->sll_halen = dev_parse_header(skb, sll->sll_addr);
 
        PACKET_SKB_CB(skb)->origlen = skb->len;
 
@@ -658,9 +656,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packe
        h->tp_usec = tv.tv_usec;
 
        sll = (struct sockaddr_ll*)((u8*)h + TPACKET_ALIGN(sizeof(*h)));
-       sll->sll_halen = 0;
-       if (dev->hard_header_parse)
-               sll->sll_halen = dev->hard_header_parse(skb, sll->sll_addr);
+       sll->sll_halen = dev_parse_header(skb, sll->sll_addr);
        sll->sll_family = AF_PACKET;
        sll->sll_hatype = dev->type;
        sll->sll_protocol = skb->protocol;