diff options
author | Paul Mackerras <paulus@samba.org> | 2007-09-19 20:09:27 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2007-09-19 20:09:27 -0400 |
commit | 0ce49a3945474fc942ec37c0c0efece60f592f80 (patch) | |
tree | f42b821b2d9e2d8775bc22f56d444c2cc7b7b7dd /drivers/net/pppoe.c | |
parent | 9e4859ef5462193643fd2b3c8ffb298e5a4a4319 (diff) | |
parent | a88a8eff1e6e32d3288986a9d36c6a449c032d3a (diff) |
Merge branch 'linux-2.6'
Diffstat (limited to 'drivers/net/pppoe.c')
-rw-r--r-- | drivers/net/pppoe.c | 70 |
1 files changed, 22 insertions, 48 deletions
diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c index 68631a5721ac..0d7f570b9a54 100644 --- a/drivers/net/pppoe.c +++ b/drivers/net/pppoe.c | |||
@@ -385,12 +385,12 @@ static int pppoe_rcv(struct sk_buff *skb, | |||
385 | struct pppoe_hdr *ph; | 385 | struct pppoe_hdr *ph; |
386 | struct pppox_sock *po; | 386 | struct pppox_sock *po; |
387 | 387 | ||
388 | if (!pskb_may_pull(skb, sizeof(struct pppoe_hdr))) | ||
389 | goto drop; | ||
390 | |||
391 | if (!(skb = skb_share_check(skb, GFP_ATOMIC))) | 388 | if (!(skb = skb_share_check(skb, GFP_ATOMIC))) |
392 | goto out; | 389 | goto out; |
393 | 390 | ||
391 | if (!pskb_may_pull(skb, sizeof(struct pppoe_hdr))) | ||
392 | goto drop; | ||
393 | |||
394 | ph = pppoe_hdr(skb); | 394 | ph = pppoe_hdr(skb); |
395 | 395 | ||
396 | po = get_item((unsigned long) ph->sid, eth_hdr(skb)->h_source, dev->ifindex); | 396 | po = get_item((unsigned long) ph->sid, eth_hdr(skb)->h_source, dev->ifindex); |
@@ -848,71 +848,45 @@ static int __pppoe_xmit(struct sock *sk, struct sk_buff *skb) | |||
848 | { | 848 | { |
849 | struct pppox_sock *po = pppox_sk(sk); | 849 | struct pppox_sock *po = pppox_sk(sk); |
850 | struct net_device *dev = po->pppoe_dev; | 850 | struct net_device *dev = po->pppoe_dev; |
851 | struct pppoe_hdr hdr; | ||
852 | struct pppoe_hdr *ph; | 851 | struct pppoe_hdr *ph; |
853 | int headroom = skb_headroom(skb); | ||
854 | int data_len = skb->len; | 852 | int data_len = skb->len; |
855 | struct sk_buff *skb2; | ||
856 | 853 | ||
857 | if (sock_flag(sk, SOCK_DEAD) || !(sk->sk_state & PPPOX_CONNECTED)) | 854 | if (sock_flag(sk, SOCK_DEAD) || !(sk->sk_state & PPPOX_CONNECTED)) |
858 | goto abort; | 855 | goto abort; |
859 | 856 | ||
860 | hdr.ver = 1; | ||
861 | hdr.type = 1; | ||
862 | hdr.code = 0; | ||
863 | hdr.sid = po->num; | ||
864 | hdr.length = htons(skb->len); | ||
865 | |||
866 | if (!dev) | 857 | if (!dev) |
867 | goto abort; | 858 | goto abort; |
868 | 859 | ||
869 | /* Copy the skb if there is no space for the header. */ | 860 | /* Copy the data if there is no space for the header or if it's |
870 | if (headroom < (sizeof(struct pppoe_hdr) + dev->hard_header_len)) { | 861 | * read-only. |
871 | skb2 = dev_alloc_skb(32+skb->len + | 862 | */ |
872 | sizeof(struct pppoe_hdr) + | 863 | if (skb_cow_head(skb, sizeof(*ph) + dev->hard_header_len)) |
873 | dev->hard_header_len); | 864 | goto abort; |
874 | |||
875 | if (skb2 == NULL) | ||
876 | goto abort; | ||
877 | |||
878 | skb_reserve(skb2, dev->hard_header_len + sizeof(struct pppoe_hdr)); | ||
879 | skb_copy_from_linear_data(skb, skb_put(skb2, skb->len), | ||
880 | skb->len); | ||
881 | } else { | ||
882 | /* Make a clone so as to not disturb the original skb, | ||
883 | * give dev_queue_xmit something it can free. | ||
884 | */ | ||
885 | skb2 = skb_clone(skb, GFP_ATOMIC); | ||
886 | |||
887 | if (skb2 == NULL) | ||
888 | goto abort; | ||
889 | } | ||
890 | 865 | ||
891 | ph = (struct pppoe_hdr *) skb_push(skb2, sizeof(struct pppoe_hdr)); | 866 | __skb_push(skb, sizeof(*ph)); |
892 | memcpy(ph, &hdr, sizeof(struct pppoe_hdr)); | 867 | skb_reset_network_header(skb); |
893 | skb2->protocol = __constant_htons(ETH_P_PPP_SES); | ||
894 | 868 | ||
895 | skb_reset_network_header(skb2); | 869 | ph = pppoe_hdr(skb); |
870 | ph->ver = 1; | ||
871 | ph->type = 1; | ||
872 | ph->code = 0; | ||
873 | ph->sid = po->num; | ||
874 | ph->length = htons(data_len); | ||
896 | 875 | ||
897 | skb2->dev = dev; | 876 | skb->protocol = __constant_htons(ETH_P_PPP_SES); |
877 | skb->dev = dev; | ||
898 | 878 | ||
899 | dev->hard_header(skb2, dev, ETH_P_PPP_SES, | 879 | dev->hard_header(skb, dev, ETH_P_PPP_SES, |
900 | po->pppoe_pa.remote, NULL, data_len); | 880 | po->pppoe_pa.remote, NULL, data_len); |
901 | 881 | ||
902 | /* We're transmitting skb2, and assuming that dev_queue_xmit | 882 | if (dev_queue_xmit(skb) < 0) |
903 | * will free it. The generic ppp layer however, is expecting | ||
904 | * that we give back 'skb' (not 'skb2') in case of failure, | ||
905 | * but free it in case of success. | ||
906 | */ | ||
907 | |||
908 | if (dev_queue_xmit(skb2) < 0) | ||
909 | goto abort; | 883 | goto abort; |
910 | 884 | ||
911 | kfree_skb(skb); | ||
912 | return 1; | 885 | return 1; |
913 | 886 | ||
914 | abort: | 887 | abort: |
915 | return 0; | 888 | kfree_skb(skb); |
889 | return 1; | ||
916 | } | 890 | } |
917 | 891 | ||
918 | 892 | ||