diff options
author | Stephen Hemminger <shemminger@linux-foundation.org> | 2007-09-27 01:13:38 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:52:51 -0400 |
commit | b95cce3576813ac3f86bafa6b5daaaaf7574b0fe (patch) | |
tree | 54da3f245ee145722623a8e0eaab5fc49ea78511 | |
parent | 0c4e85813d0a94eeb8bf813397a4907bdd7bb610 (diff) |
[NET]: Wrap hard_header_parse
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>
-rw-r--r-- | drivers/ieee1394/eth1394.c | 10 | ||||
-rw-r--r-- | drivers/net/wireless/airo.c | 7 | ||||
-rw-r--r-- | drivers/s390/net/qeth_main.c | 6 | ||||
-rw-r--r-- | include/linux/netdevice.h | 12 | ||||
-rw-r--r-- | net/ethernet/eth.c | 4 | ||||
-rw-r--r-- | net/ipv4/netfilter/ip_queue.c | 6 | ||||
-rw-r--r-- | net/ipv6/netfilter/ip6_queue.c | 5 | ||||
-rw-r--r-- | net/mac80211/ieee80211.c | 2 | ||||
-rw-r--r-- | net/netfilter/nfnetlink_log.c | 11 | ||||
-rw-r--r-- | net/netfilter/nfnetlink_queue.c | 13 | ||||
-rw-r--r-- | net/packet/af_packet.c | 8 |
11 files changed, 40 insertions, 44 deletions
diff --git a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c index 33b80817d68c..b31f90082e35 100644 --- a/drivers/ieee1394/eth1394.c +++ b/drivers/ieee1394/eth1394.c | |||
@@ -162,7 +162,8 @@ static int ether1394_header(struct sk_buff *skb, struct net_device *dev, | |||
162 | unsigned short type, void *daddr, void *saddr, | 162 | unsigned short type, void *daddr, void *saddr, |
163 | unsigned len); | 163 | unsigned len); |
164 | static int ether1394_rebuild_header(struct sk_buff *skb); | 164 | static int ether1394_rebuild_header(struct sk_buff *skb); |
165 | static int ether1394_header_parse(struct sk_buff *skb, unsigned char *haddr); | 165 | static int ether1394_header_parse(const struct sk_buff *skb, |
166 | unsigned char *haddr); | ||
166 | static int ether1394_header_cache(struct neighbour *neigh, struct hh_cache *hh); | 167 | static int ether1394_header_cache(struct neighbour *neigh, struct hh_cache *hh); |
167 | static void ether1394_header_cache_update(struct hh_cache *hh, | 168 | static void ether1394_header_cache_update(struct hh_cache *hh, |
168 | struct net_device *dev, | 169 | struct net_device *dev, |
@@ -751,11 +752,10 @@ static int ether1394_rebuild_header(struct sk_buff *skb) | |||
751 | return 0; | 752 | return 0; |
752 | } | 753 | } |
753 | 754 | ||
754 | static int ether1394_header_parse(struct sk_buff *skb, unsigned char *haddr) | 755 | static int ether1394_header_parse(const struct sk_buff *skb, |
756 | unsigned char *haddr) | ||
755 | { | 757 | { |
756 | struct net_device *dev = skb->dev; | 758 | memcpy(haddr, skb->dev->dev_addr, ETH1394_ALEN); |
757 | |||
758 | memcpy(haddr, dev->dev_addr, ETH1394_ALEN); | ||
759 | return ETH1394_ALEN; | 759 | return ETH1394_ALEN; |
760 | } | 760 | } |
761 | 761 | ||
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c index 95d3cd1c49a7..cd03a61359aa 100644 --- a/drivers/net/wireless/airo.c +++ b/drivers/net/wireless/airo.c | |||
@@ -2481,7 +2481,7 @@ void stop_airo_card( struct net_device *dev, int freeres ) | |||
2481 | 2481 | ||
2482 | EXPORT_SYMBOL(stop_airo_card); | 2482 | EXPORT_SYMBOL(stop_airo_card); |
2483 | 2483 | ||
2484 | static int wll_header_parse(struct sk_buff *skb, unsigned char *haddr) | 2484 | static int wll_header_parse(const struct sk_buff *skb, unsigned char *haddr) |
2485 | { | 2485 | { |
2486 | memcpy(haddr, skb_mac_header(skb) + 10, ETH_ALEN); | 2486 | memcpy(haddr, skb_mac_header(skb) + 10, ETH_ALEN); |
2487 | return ETH_ALEN; | 2487 | return ETH_ALEN; |
@@ -2698,11 +2698,6 @@ static int mpi_map_card(struct airo_info *ai, struct pci_dev *pci) | |||
2698 | 2698 | ||
2699 | static void wifi_setup(struct net_device *dev) | 2699 | static void wifi_setup(struct net_device *dev) |
2700 | { | 2700 | { |
2701 | dev->hard_header = NULL; | ||
2702 | dev->rebuild_header = NULL; | ||
2703 | dev->hard_header_cache = NULL; | ||
2704 | dev->header_cache_update= NULL; | ||
2705 | |||
2706 | dev->hard_header_parse = wll_header_parse; | 2701 | dev->hard_header_parse = wll_header_parse; |
2707 | dev->hard_start_xmit = &airo_start_xmit11; | 2702 | dev->hard_start_xmit = &airo_start_xmit11; |
2708 | dev->get_stats = &airo_get_stats; | 2703 | dev->get_stats = &airo_get_stats; |
diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c index 8c46978e0afa..65225b3989dd 100644 --- a/drivers/s390/net/qeth_main.c +++ b/drivers/s390/net/qeth_main.c | |||
@@ -6561,10 +6561,10 @@ static struct ethtool_ops qeth_ethtool_ops = { | |||
6561 | }; | 6561 | }; |
6562 | 6562 | ||
6563 | static int | 6563 | static int |
6564 | qeth_hard_header_parse(struct sk_buff *skb, unsigned char *haddr) | 6564 | qeth_hard_header_parse(const struct sk_buff *skb, unsigned char *haddr) |
6565 | { | 6565 | { |
6566 | struct qeth_card *card; | 6566 | const struct qeth_card *card; |
6567 | struct ethhdr *eth; | 6567 | const struct ethhdr *eth; |
6568 | 6568 | ||
6569 | card = qeth_get_card_from_dev(skb->dev); | 6569 | card = qeth_get_card_from_dev(skb->dev); |
6570 | if (card->options.layer2) | 6570 | if (card->options.layer2) |
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index b33d084712fa..aae9ec367f5d 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -657,7 +657,7 @@ struct net_device | |||
657 | void (*vlan_rx_kill_vid)(struct net_device *dev, | 657 | void (*vlan_rx_kill_vid)(struct net_device *dev, |
658 | unsigned short vid); | 658 | unsigned short vid); |
659 | 659 | ||
660 | int (*hard_header_parse)(struct sk_buff *skb, | 660 | int (*hard_header_parse)(const struct sk_buff *skb, |
661 | unsigned char *haddr); | 661 | unsigned char *haddr); |
662 | int (*neigh_setup)(struct net_device *dev, struct neigh_parms *); | 662 | int (*neigh_setup)(struct net_device *dev, struct neigh_parms *); |
663 | #ifdef CONFIG_NETPOLL | 663 | #ifdef CONFIG_NETPOLL |
@@ -809,6 +809,16 @@ static inline int dev_hard_header(struct sk_buff *skb, struct net_device *dev, | |||
809 | return dev->hard_header(skb, dev, type, daddr, saddr, len); | 809 | return dev->hard_header(skb, dev, type, daddr, saddr, len); |
810 | } | 810 | } |
811 | 811 | ||
812 | static inline int dev_parse_header(const struct sk_buff *skb, | ||
813 | unsigned char *haddr) | ||
814 | { | ||
815 | const struct net_device *dev = skb->dev; | ||
816 | |||
817 | if (!dev->hard_header_parse) | ||
818 | return 0; | ||
819 | return dev->hard_header_parse(skb, haddr); | ||
820 | } | ||
821 | |||
812 | typedef int gifconf_func_t(struct net_device * dev, char __user * bufptr, int len); | 822 | typedef int gifconf_func_t(struct net_device * dev, char __user * bufptr, int len); |
813 | extern int register_gifconf(unsigned int family, gifconf_func_t * gifconf); | 823 | extern int register_gifconf(unsigned int family, gifconf_func_t * gifconf); |
814 | static inline int unregister_gifconf(unsigned int family) | 824 | static inline int unregister_gifconf(unsigned int family) |
diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c index 2aaf6faf74ac..bdeb2f0ace32 100644 --- a/net/ethernet/eth.c +++ b/net/ethernet/eth.c | |||
@@ -207,9 +207,9 @@ EXPORT_SYMBOL(eth_type_trans); | |||
207 | * @skb: packet to extract header from | 207 | * @skb: packet to extract header from |
208 | * @haddr: destination buffer | 208 | * @haddr: destination buffer |
209 | */ | 209 | */ |
210 | static int eth_header_parse(struct sk_buff *skb, unsigned char *haddr) | 210 | static int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr) |
211 | { | 211 | { |
212 | struct ethhdr *eth = eth_hdr(skb); | 212 | const struct ethhdr *eth = eth_hdr(skb); |
213 | memcpy(haddr, eth->h_source, ETH_ALEN); | 213 | memcpy(haddr, eth->h_source, ETH_ALEN); |
214 | return ETH_ALEN; | 214 | return ETH_ALEN; |
215 | } | 215 | } |
diff --git a/net/ipv4/netfilter/ip_queue.c b/net/ipv4/netfilter/ip_queue.c index 82fda92e6b97..aaa3f5c56761 100644 --- a/net/ipv4/netfilter/ip_queue.c +++ b/net/ipv4/netfilter/ip_queue.c | |||
@@ -250,10 +250,8 @@ ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp) | |||
250 | 250 | ||
251 | if (entry->info->indev && entry->skb->dev) { | 251 | if (entry->info->indev && entry->skb->dev) { |
252 | pmsg->hw_type = entry->skb->dev->type; | 252 | pmsg->hw_type = entry->skb->dev->type; |
253 | if (entry->skb->dev->hard_header_parse) | 253 | pmsg->hw_addrlen = dev_parse_header(entry->skb, |
254 | pmsg->hw_addrlen = | 254 | pmsg->hw_addr); |
255 | entry->skb->dev->hard_header_parse(entry->skb, | ||
256 | pmsg->hw_addr); | ||
257 | } | 255 | } |
258 | 256 | ||
259 | if (data_len) | 257 | if (data_len) |
diff --git a/net/ipv6/netfilter/ip6_queue.c b/net/ipv6/netfilter/ip6_queue.c index 2f5a52453834..c75f467a8f51 100644 --- a/net/ipv6/netfilter/ip6_queue.c +++ b/net/ipv6/netfilter/ip6_queue.c | |||
@@ -248,10 +248,7 @@ ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp) | |||
248 | 248 | ||
249 | if (entry->info->indev && entry->skb->dev) { | 249 | if (entry->info->indev && entry->skb->dev) { |
250 | pmsg->hw_type = entry->skb->dev->type; | 250 | pmsg->hw_type = entry->skb->dev->type; |
251 | if (entry->skb->dev->hard_header_parse) | 251 | pmsg->hw_addrlen = dev_parse_header(entry->skb, pmsg->hw_addr); |
252 | pmsg->hw_addrlen = | ||
253 | entry->skb->dev->hard_header_parse(entry->skb, | ||
254 | pmsg->hw_addr); | ||
255 | } | 252 | } |
256 | 253 | ||
257 | if (data_len) | 254 | if (data_len) |
diff --git a/net/mac80211/ieee80211.c b/net/mac80211/ieee80211.c index 89be6629cfc0..0cdcf0d0c6ca 100644 --- a/net/mac80211/ieee80211.c +++ b/net/mac80211/ieee80211.c | |||
@@ -47,7 +47,7 @@ struct ieee80211_tx_status_rtap_hdr { | |||
47 | 47 | ||
48 | /* common interface routines */ | 48 | /* common interface routines */ |
49 | 49 | ||
50 | static int header_parse_80211(struct sk_buff *skb, unsigned char *haddr) | 50 | static int header_parse_80211(const struct sk_buff *skb, unsigned char *haddr) |
51 | { | 51 | { |
52 | memcpy(haddr, skb_mac_header(skb) + 10, ETH_ALEN); /* addr2 */ | 52 | memcpy(haddr, skb_mac_header(skb) + 10, ETH_ALEN); /* addr2 */ |
53 | return ETH_ALEN; | 53 | return ETH_ALEN; |
diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c index 8e4001b8f764..332e0f7f6f9e 100644 --- a/net/netfilter/nfnetlink_log.c +++ b/net/netfilter/nfnetlink_log.c | |||
@@ -481,12 +481,13 @@ __build_packet_message(struct nfulnl_instance *inst, | |||
481 | NFA_PUT(inst->skb, NFULA_MARK, sizeof(tmp_uint), &tmp_uint); | 481 | NFA_PUT(inst->skb, NFULA_MARK, sizeof(tmp_uint), &tmp_uint); |
482 | } | 482 | } |
483 | 483 | ||
484 | if (indev && skb->dev && skb->dev->hard_header_parse) { | 484 | if (indev && skb->dev) { |
485 | struct nfulnl_msg_packet_hw phw; | 485 | struct nfulnl_msg_packet_hw phw; |
486 | int len = skb->dev->hard_header_parse((struct sk_buff *)skb, | 486 | int len = dev_parse_header(skb, phw.hw_addr); |
487 | phw.hw_addr); | 487 | if (len > 0) { |
488 | phw.hw_addrlen = htons(len); | 488 | phw.hw_addrlen = htons(len); |
489 | NFA_PUT(inst->skb, NFULA_HWADDR, sizeof(phw), &phw); | 489 | NFA_PUT(inst->skb, NFULA_HWADDR, sizeof(phw), &phw); |
490 | } | ||
490 | } | 491 | } |
491 | 492 | ||
492 | if (skb->tstamp.tv64) { | 493 | if (skb->tstamp.tv64) { |
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c index c97369f48db7..a813185c766d 100644 --- a/net/netfilter/nfnetlink_queue.c +++ b/net/netfilter/nfnetlink_queue.c | |||
@@ -485,14 +485,13 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue, | |||
485 | NFA_PUT(skb, NFQA_MARK, sizeof(u_int32_t), &tmp_uint); | 485 | NFA_PUT(skb, NFQA_MARK, sizeof(u_int32_t), &tmp_uint); |
486 | } | 486 | } |
487 | 487 | ||
488 | if (indev && entskb->dev | 488 | if (indev && entskb->dev) { |
489 | && entskb->dev->hard_header_parse) { | ||
490 | struct nfqnl_msg_packet_hw phw; | 489 | struct nfqnl_msg_packet_hw phw; |
491 | 490 | int len = dev_parse_header(entskb, phw.hw_addr); | |
492 | int len = entskb->dev->hard_header_parse(entskb, | 491 | if (len) { |
493 | phw.hw_addr); | 492 | phw.hw_addrlen = htons(len); |
494 | phw.hw_addrlen = htons(len); | 493 | NFA_PUT(skb, NFQA_HWADDR, sizeof(phw), &phw); |
495 | NFA_PUT(skb, NFQA_HWADDR, sizeof(phw), &phw); | 494 | } |
496 | } | 495 | } |
497 | 496 | ||
498 | if (entskb->tstamp.tv64) { | 497 | if (entskb->tstamp.tv64) { |
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index c5244b309640..c9ee343c2a6c 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -519,10 +519,8 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev, struct packet | |||
519 | sll->sll_ifindex = orig_dev->ifindex; | 519 | sll->sll_ifindex = orig_dev->ifindex; |
520 | else | 520 | else |
521 | sll->sll_ifindex = dev->ifindex; | 521 | sll->sll_ifindex = dev->ifindex; |
522 | sll->sll_halen = 0; | ||
523 | 522 | ||
524 | if (dev->hard_header_parse) | 523 | sll->sll_halen = dev_parse_header(skb, sll->sll_addr); |
525 | sll->sll_halen = dev->hard_header_parse(skb, sll->sll_addr); | ||
526 | 524 | ||
527 | PACKET_SKB_CB(skb)->origlen = skb->len; | 525 | PACKET_SKB_CB(skb)->origlen = skb->len; |
528 | 526 | ||
@@ -658,9 +656,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packe | |||
658 | h->tp_usec = tv.tv_usec; | 656 | h->tp_usec = tv.tv_usec; |
659 | 657 | ||
660 | sll = (struct sockaddr_ll*)((u8*)h + TPACKET_ALIGN(sizeof(*h))); | 658 | sll = (struct sockaddr_ll*)((u8*)h + TPACKET_ALIGN(sizeof(*h))); |
661 | sll->sll_halen = 0; | 659 | sll->sll_halen = dev_parse_header(skb, sll->sll_addr); |
662 | if (dev->hard_header_parse) | ||
663 | sll->sll_halen = dev->hard_header_parse(skb, sll->sll_addr); | ||
664 | sll->sll_family = AF_PACKET; | 660 | sll->sll_family = AF_PACKET; |
665 | sll->sll_hatype = dev->type; | 661 | sll->sll_hatype = dev->type; |
666 | sll->sll_protocol = skb->protocol; | 662 | sll->sll_protocol = skb->protocol; |