diff options
author | Stephen Hemminger <shemminger@linux-foundation.org> | 2007-10-09 04:36:32 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:52:50 -0400 |
commit | 0c4e85813d0a94eeb8bf813397a4907bdd7bb610 (patch) | |
tree | 53ee948abc930bb1c5cd270c490f87fda5eb45b3 /net | |
parent | 4c94f8c0c9a82fad84bc5df453aff755cfed70b7 (diff) |
[NET]: Wrap netdevice hardware header creation.
Add inline for common usage of hardware header creation, and
fix bug in IPV6 mcast where the assumption about negative return is
an errno. Negative return from hard_header means not enough space
was available,(ie -N bytes).
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/802/p8023.c | 2 | ||||
-rw-r--r-- | net/8021q/vlan_dev.c | 14 | ||||
-rw-r--r-- | net/core/neighbour.c | 17 | ||||
-rw-r--r-- | net/core/netpoll.c | 8 | ||||
-rw-r--r-- | net/decnet/dn_neigh.c | 3 | ||||
-rw-r--r-- | net/econet/af_econet.c | 14 | ||||
-rw-r--r-- | net/ethernet/pe2.c | 4 | ||||
-rw-r--r-- | net/ipv4/arp.c | 3 | ||||
-rw-r--r-- | net/ipv4/ipconfig.c | 4 | ||||
-rw-r--r-- | net/ipv6/mcast.c | 15 | ||||
-rw-r--r-- | net/packet/af_packet.c | 14 | ||||
-rw-r--r-- | net/sched/sch_teql.c | 5 | ||||
-rw-r--r-- | net/tipc/eth_media.c | 2 |
13 files changed, 45 insertions, 60 deletions
diff --git a/net/802/p8023.c b/net/802/p8023.c index 53cf05709283..6ab1835041a7 100644 --- a/net/802/p8023.c +++ b/net/802/p8023.c | |||
@@ -31,7 +31,7 @@ static int p8023_request(struct datalink_proto *dl, | |||
31 | { | 31 | { |
32 | struct net_device *dev = skb->dev; | 32 | struct net_device *dev = skb->dev; |
33 | 33 | ||
34 | dev->hard_header(skb, dev, ETH_P_802_3, dest_node, NULL, skb->len); | 34 | dev_hard_header(skb, dev, ETH_P_802_3, dest_node, NULL, skb->len); |
35 | return dev_queue_xmit(skb); | 35 | return dev_queue_xmit(skb); |
36 | } | 36 | } |
37 | 37 | ||
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index 6644e8f5f199..ca8090fdabbb 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c | |||
@@ -434,21 +434,19 @@ int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev, | |||
434 | 434 | ||
435 | if (build_vlan_header) { | 435 | if (build_vlan_header) { |
436 | /* Now make the underlying real hard header */ | 436 | /* Now make the underlying real hard header */ |
437 | rc = dev->hard_header(skb, dev, ETH_P_8021Q, daddr, saddr, len + VLAN_HLEN); | 437 | rc = dev_hard_header(skb, dev, ETH_P_8021Q, daddr, saddr, |
438 | 438 | len + VLAN_HLEN); | |
439 | if (rc > 0) { | 439 | if (rc > 0) |
440 | rc += VLAN_HLEN; | 440 | rc += VLAN_HLEN; |
441 | } else if (rc < 0) { | 441 | else if (rc < 0) |
442 | rc -= VLAN_HLEN; | 442 | rc -= VLAN_HLEN; |
443 | } | 443 | } else |
444 | } else { | ||
445 | /* If here, then we'll just make a normal looking ethernet frame, | 444 | /* If here, then we'll just make a normal looking ethernet frame, |
446 | * but, the hard_start_xmit method will insert the tag (it has to | 445 | * but, the hard_start_xmit method will insert the tag (it has to |
447 | * be able to do this for bridged and other skbs that don't come | 446 | * be able to do this for bridged and other skbs that don't come |
448 | * down the protocol stack in an orderly manner. | 447 | * down the protocol stack in an orderly manner. |
449 | */ | 448 | */ |
450 | rc = dev->hard_header(skb, dev, type, daddr, saddr, len); | 449 | rc = dev_hard_header(skb, dev, type, daddr, saddr, len); |
451 | } | ||
452 | 450 | ||
453 | return rc; | 451 | return rc; |
454 | } | 452 | } |
diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 2c6577c1eedd..10bcb9f8da5c 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c | |||
@@ -1125,9 +1125,8 @@ int neigh_compat_output(struct sk_buff *skb) | |||
1125 | 1125 | ||
1126 | __skb_pull(skb, skb_network_offset(skb)); | 1126 | __skb_pull(skb, skb_network_offset(skb)); |
1127 | 1127 | ||
1128 | if (dev->hard_header && | 1128 | if (dev_hard_header(skb, dev, ntohs(skb->protocol), NULL, NULL, |
1129 | dev->hard_header(skb, dev, ntohs(skb->protocol), NULL, NULL, | 1129 | skb->len) < 0 && |
1130 | skb->len) < 0 && | ||
1131 | dev->rebuild_header(skb)) | 1130 | dev->rebuild_header(skb)) |
1132 | return 0; | 1131 | return 0; |
1133 | 1132 | ||
@@ -1154,13 +1153,13 @@ int neigh_resolve_output(struct sk_buff *skb) | |||
1154 | write_lock_bh(&neigh->lock); | 1153 | write_lock_bh(&neigh->lock); |
1155 | if (!dst->hh) | 1154 | if (!dst->hh) |
1156 | neigh_hh_init(neigh, dst, dst->ops->protocol); | 1155 | neigh_hh_init(neigh, dst, dst->ops->protocol); |
1157 | err = dev->hard_header(skb, dev, ntohs(skb->protocol), | 1156 | err = dev_hard_header(skb, dev, ntohs(skb->protocol), |
1158 | neigh->ha, NULL, skb->len); | 1157 | neigh->ha, NULL, skb->len); |
1159 | write_unlock_bh(&neigh->lock); | 1158 | write_unlock_bh(&neigh->lock); |
1160 | } else { | 1159 | } else { |
1161 | read_lock_bh(&neigh->lock); | 1160 | read_lock_bh(&neigh->lock); |
1162 | err = dev->hard_header(skb, dev, ntohs(skb->protocol), | 1161 | err = dev_hard_header(skb, dev, ntohs(skb->protocol), |
1163 | neigh->ha, NULL, skb->len); | 1162 | neigh->ha, NULL, skb->len); |
1164 | read_unlock_bh(&neigh->lock); | 1163 | read_unlock_bh(&neigh->lock); |
1165 | } | 1164 | } |
1166 | if (err >= 0) | 1165 | if (err >= 0) |
@@ -1191,8 +1190,8 @@ int neigh_connected_output(struct sk_buff *skb) | |||
1191 | __skb_pull(skb, skb_network_offset(skb)); | 1190 | __skb_pull(skb, skb_network_offset(skb)); |
1192 | 1191 | ||
1193 | read_lock_bh(&neigh->lock); | 1192 | read_lock_bh(&neigh->lock); |
1194 | err = dev->hard_header(skb, dev, ntohs(skb->protocol), | 1193 | err = dev_hard_header(skb, dev, ntohs(skb->protocol), |
1195 | neigh->ha, NULL, skb->len); | 1194 | neigh->ha, NULL, skb->len); |
1196 | read_unlock_bh(&neigh->lock); | 1195 | read_unlock_bh(&neigh->lock); |
1197 | if (err >= 0) | 1196 | if (err >= 0) |
1198 | err = neigh->ops->queue_xmit(skb); | 1197 | err = neigh->ops->queue_xmit(skb); |
diff --git a/net/core/netpoll.c b/net/core/netpoll.c index e13602d8154d..95daba624967 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c | |||
@@ -415,11 +415,9 @@ static void arp_reply(struct sk_buff *skb) | |||
415 | send_skb->protocol = htons(ETH_P_ARP); | 415 | send_skb->protocol = htons(ETH_P_ARP); |
416 | 416 | ||
417 | /* Fill the device header for the ARP frame */ | 417 | /* Fill the device header for the ARP frame */ |
418 | 418 | if (dev_hard_header(send_skb, skb->dev, ptype, | |
419 | if (np->dev->hard_header && | 419 | sha, np->local_mac, |
420 | np->dev->hard_header(send_skb, skb->dev, ptype, | 420 | send_skb->len) < 0) { |
421 | sha, np->local_mac, | ||
422 | send_skb->len) < 0) { | ||
423 | kfree_skb(send_skb); | 421 | kfree_skb(send_skb); |
424 | return; | 422 | return; |
425 | } | 423 | } |
diff --git a/net/decnet/dn_neigh.c b/net/decnet/dn_neigh.c index a424a8ddbaf7..b66e3be3eb84 100644 --- a/net/decnet/dn_neigh.c +++ b/net/decnet/dn_neigh.c | |||
@@ -211,7 +211,8 @@ static int dn_neigh_output_packet(struct sk_buff *skb) | |||
211 | char mac_addr[ETH_ALEN]; | 211 | char mac_addr[ETH_ALEN]; |
212 | 212 | ||
213 | dn_dn2eth(mac_addr, rt->rt_local_src); | 213 | dn_dn2eth(mac_addr, rt->rt_local_src); |
214 | if (!dev->hard_header || dev->hard_header(skb, dev, ntohs(skb->protocol), neigh->ha, mac_addr, skb->len) >= 0) | 214 | if (dev_hard_header(skb, dev, ntohs(skb->protocol), neigh->ha, |
215 | mac_addr, skb->len) >= 0) | ||
215 | return neigh->ops->queue_xmit(skb); | 216 | return neigh->ops->queue_xmit(skb); |
216 | 217 | ||
217 | if (net_ratelimit()) | 218 | if (net_ratelimit()) |
diff --git a/net/econet/af_econet.c b/net/econet/af_econet.c index 9938e76a8ff6..9cae16b4e0b7 100644 --- a/net/econet/af_econet.c +++ b/net/econet/af_econet.c | |||
@@ -336,6 +336,7 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
336 | /* Real hardware Econet. We're not worthy etc. */ | 336 | /* Real hardware Econet. We're not worthy etc. */ |
337 | #ifdef CONFIG_ECONET_NATIVE | 337 | #ifdef CONFIG_ECONET_NATIVE |
338 | unsigned short proto = 0; | 338 | unsigned short proto = 0; |
339 | int res; | ||
339 | 340 | ||
340 | dev_hold(dev); | 341 | dev_hold(dev); |
341 | 342 | ||
@@ -354,12 +355,12 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
354 | eb->sec = *saddr; | 355 | eb->sec = *saddr; |
355 | eb->sent = ec_tx_done; | 356 | eb->sent = ec_tx_done; |
356 | 357 | ||
357 | if (dev->hard_header) { | 358 | err = -EINVAL; |
358 | int res; | 359 | res = dev_hard_header(skb, dev, ntohs(proto), &addr, NULL, len); |
360 | if (res < 0) | ||
361 | goto out_free; | ||
362 | if (res > 0) { | ||
359 | struct ec_framehdr *fh; | 363 | struct ec_framehdr *fh; |
360 | err = -EINVAL; | ||
361 | res = dev->hard_header(skb, dev, ntohs(proto), | ||
362 | &addr, NULL, len); | ||
363 | /* Poke in our control byte and | 364 | /* Poke in our control byte and |
364 | port number. Hack, hack. */ | 365 | port number. Hack, hack. */ |
365 | fh = (struct ec_framehdr *)(skb->data); | 366 | fh = (struct ec_framehdr *)(skb->data); |
@@ -368,8 +369,7 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
368 | if (sock->type != SOCK_DGRAM) { | 369 | if (sock->type != SOCK_DGRAM) { |
369 | skb_reset_tail_pointer(skb); | 370 | skb_reset_tail_pointer(skb); |
370 | skb->len = 0; | 371 | skb->len = 0; |
371 | } else if (res < 0) | 372 | } |
372 | goto out_free; | ||
373 | } | 373 | } |
374 | 374 | ||
375 | /* Copy the data. Returns -EFAULT on error */ | 375 | /* Copy the data. Returns -EFAULT on error */ |
diff --git a/net/ethernet/pe2.c b/net/ethernet/pe2.c index 9d57b4fb6440..d60e15d9365e 100644 --- a/net/ethernet/pe2.c +++ b/net/ethernet/pe2.c | |||
@@ -12,9 +12,7 @@ static int pEII_request(struct datalink_proto *dl, | |||
12 | struct net_device *dev = skb->dev; | 12 | struct net_device *dev = skb->dev; |
13 | 13 | ||
14 | skb->protocol = htons(ETH_P_IPX); | 14 | skb->protocol = htons(ETH_P_IPX); |
15 | if (dev->hard_header) | 15 | dev_hard_header(skb, dev, ETH_P_IPX, dest_node, NULL, skb->len); |
16 | dev->hard_header(skb, dev, ETH_P_IPX, | ||
17 | dest_node, NULL, skb->len); | ||
18 | return dev_queue_xmit(skb); | 16 | return dev_queue_xmit(skb); |
19 | } | 17 | } |
20 | 18 | ||
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index 3a683006d761..5b24c65b13c6 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c | |||
@@ -591,8 +591,7 @@ struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip, | |||
591 | /* | 591 | /* |
592 | * Fill the device header for the ARP frame | 592 | * Fill the device header for the ARP frame |
593 | */ | 593 | */ |
594 | if (dev->hard_header && | 594 | if (dev_hard_header(skb, dev, ptype, dest_hw, src_hw, skb->len) < 0) |
595 | dev->hard_header(skb,dev,ptype,dest_hw,src_hw,skb->len) < 0) | ||
596 | goto out; | 595 | goto out; |
597 | 596 | ||
598 | /* | 597 | /* |
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index af5d5b39fc13..c5c107a01823 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c | |||
@@ -757,8 +757,8 @@ static void __init ic_bootp_send_if(struct ic_device *d, unsigned long jiffies_d | |||
757 | /* Chain packet down the line... */ | 757 | /* Chain packet down the line... */ |
758 | skb->dev = dev; | 758 | skb->dev = dev; |
759 | skb->protocol = htons(ETH_P_IP); | 759 | skb->protocol = htons(ETH_P_IP); |
760 | if ((dev->hard_header && | 760 | if (dev_hard_header(skb, dev, ntohs(skb->protocol), |
761 | dev->hard_header(skb, dev, ntohs(skb->protocol), dev->broadcast, dev->dev_addr, skb->len) < 0) || | 761 | dev->broadcast, dev->dev_addr, skb->len) < 0 || |
762 | dev_queue_xmit(skb) < 0) | 762 | dev_queue_xmit(skb) < 0) |
763 | printk("E"); | 763 | printk("E"); |
764 | } | 764 | } |
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c index 86d908b1caea..8668ab3af32e 100644 --- a/net/ipv6/mcast.c +++ b/net/ipv6/mcast.c | |||
@@ -1438,17 +1438,12 @@ static struct sk_buff *mld_newpack(struct net_device *dev, int size) | |||
1438 | static inline int mld_dev_queue_xmit2(struct sk_buff *skb) | 1438 | static inline int mld_dev_queue_xmit2(struct sk_buff *skb) |
1439 | { | 1439 | { |
1440 | struct net_device *dev = skb->dev; | 1440 | struct net_device *dev = skb->dev; |
1441 | unsigned char ha[MAX_ADDR_LEN]; | ||
1441 | 1442 | ||
1442 | if (dev->hard_header) { | 1443 | ndisc_mc_map(&ipv6_hdr(skb)->daddr, ha, dev, 1); |
1443 | unsigned char ha[MAX_ADDR_LEN]; | 1444 | if (dev_hard_header(skb, dev, ETH_P_IPV6, ha, NULL, skb->len) < 0) { |
1444 | int err; | 1445 | kfree_skb(skb); |
1445 | 1446 | return -EINVAL; | |
1446 | ndisc_mc_map(&ipv6_hdr(skb)->daddr, ha, dev, 1); | ||
1447 | err = dev->hard_header(skb, dev, ETH_P_IPV6, ha, NULL, skb->len); | ||
1448 | if (err < 0) { | ||
1449 | kfree_skb(skb); | ||
1450 | return err; | ||
1451 | } | ||
1452 | } | 1447 | } |
1453 | return dev_queue_xmit(skb); | 1448 | return dev_queue_xmit(skb); |
1454 | } | 1449 | } |
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 745e2cb87c96..c5244b309640 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -765,16 +765,10 @@ static int packet_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
765 | skb_reserve(skb, LL_RESERVED_SPACE(dev)); | 765 | skb_reserve(skb, LL_RESERVED_SPACE(dev)); |
766 | skb_reset_network_header(skb); | 766 | skb_reset_network_header(skb); |
767 | 767 | ||
768 | if (dev->hard_header) { | 768 | err = -EINVAL; |
769 | int res; | 769 | if (sock->type == SOCK_DGRAM && |
770 | err = -EINVAL; | 770 | dev_hard_header(skb, dev, ntohs(proto), addr, NULL, len) < 0) |
771 | res = dev->hard_header(skb, dev, ntohs(proto), addr, NULL, len); | 771 | goto out_free; |
772 | if (sock->type != SOCK_DGRAM) { | ||
773 | skb_reset_tail_pointer(skb); | ||
774 | skb->len = 0; | ||
775 | } else if (res < 0) | ||
776 | goto out_free; | ||
777 | } | ||
778 | 772 | ||
779 | /* Returns -EFAULT on error */ | 773 | /* Returns -EFAULT on error */ |
780 | err = memcpy_fromiovec(skb_put(skb,len), msg->msg_iov, len); | 774 | err = memcpy_fromiovec(skb_put(skb,len), msg->msg_iov, len); |
diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c index 146f453d7378..d13970f3c7b1 100644 --- a/net/sched/sch_teql.c +++ b/net/sched/sch_teql.c | |||
@@ -232,9 +232,12 @@ __teql_resolve(struct sk_buff *skb, struct sk_buff *skb_res, struct net_device * | |||
232 | } | 232 | } |
233 | if (neigh_event_send(n, skb_res) == 0) { | 233 | if (neigh_event_send(n, skb_res) == 0) { |
234 | int err; | 234 | int err; |
235 | |||
235 | read_lock(&n->lock); | 236 | read_lock(&n->lock); |
236 | err = dev->hard_header(skb, dev, ntohs(skb->protocol), n->ha, NULL, skb->len); | 237 | err = dev_hard_header(skb, dev, ntohs(skb->protocol), |
238 | n->ha, NULL, skb->len); | ||
237 | read_unlock(&n->lock); | 239 | read_unlock(&n->lock); |
240 | |||
238 | if (err < 0) { | 241 | if (err < 0) { |
239 | neigh_release(n); | 242 | neigh_release(n); |
240 | return -EINVAL; | 243 | return -EINVAL; |
diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c index 1a99e2947145..3bbef2ab22ae 100644 --- a/net/tipc/eth_media.c +++ b/net/tipc/eth_media.c | |||
@@ -77,7 +77,7 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr, | |||
77 | skb_reset_network_header(clone); | 77 | skb_reset_network_header(clone); |
78 | dev = ((struct eth_bearer *)(tb_ptr->usr_handle))->dev; | 78 | dev = ((struct eth_bearer *)(tb_ptr->usr_handle))->dev; |
79 | clone->dev = dev; | 79 | clone->dev = dev; |
80 | dev->hard_header(clone, dev, ETH_P_TIPC, | 80 | dev_hard_header(clone, dev, ETH_P_TIPC, |
81 | &dest->dev_addr.eth_addr, | 81 | &dest->dev_addr.eth_addr, |
82 | dev->dev_addr, clone->len); | 82 | dev->dev_addr, clone->len); |
83 | dev_queue_xmit(clone); | 83 | dev_queue_xmit(clone); |