Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6

* master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6:
[EBTABLES]: Clean up vmalloc usage in net/bridge/netfilter/ebtables.c
[NET]: Add skb->truesize assertion checking.
[TCP]: Account skb overhead in tcp_fragment
[SUNGEM]: Marvell PHY suspend.
[LLC]: Use pskb_trim_rcsum() in llc_fixup_skb().
[NET]: sockfd_lookup_light() returns random error for -EBADFD

+40 -22
+6 -5
drivers/net/sungem_phy.c
··· 275 275 return 0; 276 276 } 277 277 278 - static int bcm5411_suspend(struct mii_phy* phy) 278 + static int generic_suspend(struct mii_phy* phy) 279 279 { 280 280 phy_write(phy, MII_BMCR, BMCR_PDOWN); 281 281 ··· 738 738 /* Broadcom BCM 5411 */ 739 739 static struct mii_phy_ops bcm5411_phy_ops = { 740 740 .init = bcm5411_init, 741 - .suspend = bcm5411_suspend, 741 + .suspend = generic_suspend, 742 742 .setup_aneg = bcm54xx_setup_aneg, 743 743 .setup_forced = bcm54xx_setup_forced, 744 744 .poll_link = genmii_poll_link, ··· 757 757 /* Broadcom BCM 5421 */ 758 758 static struct mii_phy_ops bcm5421_phy_ops = { 759 759 .init = bcm5421_init, 760 - .suspend = bcm5411_suspend, 760 + .suspend = generic_suspend, 761 761 .setup_aneg = bcm54xx_setup_aneg, 762 762 .setup_forced = bcm54xx_setup_forced, 763 763 .poll_link = genmii_poll_link, ··· 776 776 /* Broadcom BCM 5421 built-in K2 */ 777 777 static struct mii_phy_ops bcm5421k2_phy_ops = { 778 778 .init = bcm5421_init, 779 - .suspend = bcm5411_suspend, 779 + .suspend = generic_suspend, 780 780 .setup_aneg = bcm54xx_setup_aneg, 781 781 .setup_forced = bcm54xx_setup_forced, 782 782 .poll_link = genmii_poll_link, ··· 795 795 /* Broadcom BCM 5462 built-in Vesta */ 796 796 static struct mii_phy_ops bcm5462V_phy_ops = { 797 797 .init = bcm5421_init, 798 - .suspend = bcm5411_suspend, 798 + .suspend = generic_suspend, 799 799 .setup_aneg = bcm54xx_setup_aneg, 800 800 .setup_forced = bcm54xx_setup_forced, 801 801 .poll_link = genmii_poll_link, ··· 816 816 * would be useful here) --BenH. 817 817 */ 818 818 static struct mii_phy_ops marvell_phy_ops = { 819 + .suspend = generic_suspend, 819 820 .setup_aneg = marvell_setup_aneg, 820 821 .setup_forced = marvell_setup_forced, 821 822 .poll_link = genmii_poll_link,
+7
include/linux/skbuff.h
··· 344 344 void *here); 345 345 extern void skb_under_panic(struct sk_buff *skb, int len, 346 346 void *here); 347 + extern void skb_truesize_bug(struct sk_buff *skb); 348 + 349 + static inline void skb_truesize_check(struct sk_buff *skb) 350 + { 351 + if (unlikely((int)skb->truesize < sizeof(struct sk_buff) + skb->len)) 352 + skb_truesize_bug(skb); 353 + } 347 354 348 355 extern int skb_append_datato_frags(struct sock *sk, struct sk_buff *skb, 349 356 int getfrag(void *from, char *to, int offset,
+1
include/net/sock.h
··· 454 454 455 455 static inline void sk_stream_free_skb(struct sock *sk, struct sk_buff *skb) 456 456 { 457 + skb_truesize_check(skb); 457 458 sock_set_flag(sk, SOCK_QUEUE_SHRUNK); 458 459 sk->sk_wmem_queued -= skb->truesize; 459 460 sk->sk_forward_alloc += skb->truesize;
+7 -13
net/bridge/netfilter/ebtables.c
··· 831 831 return -ENOMEM; 832 832 for_each_possible_cpu(i) { 833 833 newinfo->chainstack[i] = 834 - vmalloc(udc_cnt * sizeof(struct ebt_chainstack)); 834 + vmalloc(udc_cnt * sizeof(*(newinfo->chainstack[0]))); 835 835 if (!newinfo->chainstack[i]) { 836 836 while (i) 837 837 vfree(newinfo->chainstack[--i]); ··· 841 841 } 842 842 } 843 843 844 - cl_s = (struct ebt_cl_stack *) 845 - vmalloc(udc_cnt * sizeof(struct ebt_cl_stack)); 844 + cl_s = vmalloc(udc_cnt * sizeof(*cl_s)); 846 845 if (!cl_s) 847 846 return -ENOMEM; 848 847 i = 0; /* the i'th udc */ ··· 943 944 944 945 countersize = COUNTER_OFFSET(tmp.nentries) * 945 946 (highest_possible_processor_id()+1); 946 - newinfo = (struct ebt_table_info *) 947 - vmalloc(sizeof(struct ebt_table_info) + countersize); 947 + newinfo = vmalloc(sizeof(*newinfo) + countersize); 948 948 if (!newinfo) 949 949 return -ENOMEM; 950 950 ··· 965 967 /* the user wants counters back 966 968 the check on the size is done later, when we have the lock */ 967 969 if (tmp.num_counters) { 968 - counterstmp = (struct ebt_counter *) 969 - vmalloc(tmp.num_counters * sizeof(struct ebt_counter)); 970 + counterstmp = vmalloc(tmp.num_counters * sizeof(*counterstmp)); 970 971 if (!counterstmp) { 971 972 ret = -ENOMEM; 972 973 goto free_entries; ··· 1145 1148 1146 1149 countersize = COUNTER_OFFSET(table->table->nentries) * 1147 1150 (highest_possible_processor_id()+1); 1148 - newinfo = (struct ebt_table_info *) 1149 - vmalloc(sizeof(struct ebt_table_info) + countersize); 1151 + newinfo = vmalloc(sizeof(*newinfo) + countersize); 1150 1152 ret = -ENOMEM; 1151 1153 if (!newinfo) 1152 1154 return -ENOMEM; ··· 1243 1247 if (hlp.num_counters == 0) 1244 1248 return -EINVAL; 1245 1249 1246 - if ( !(tmp = (struct ebt_counter *) 1247 - vmalloc(hlp.num_counters * sizeof(struct ebt_counter))) ){ 1250 + if (!(tmp = vmalloc(hlp.num_counters * sizeof(*tmp)))) { 1248 1251 MEMPRINT("Update_counters && nomemory\n"); 1249 1252 return -ENOMEM; 1250 1253 } ··· 1372 1377 BUGPRINT("Num_counters wrong\n"); 1373 1378 return -EINVAL; 1374 1379 } 1375 - counterstmp = (struct ebt_counter *) 1376 - vmalloc(nentries * sizeof(struct ebt_counter)); 1380 + counterstmp = vmalloc(nentries * sizeof(*counterstmp)); 1377 1381 if (!counterstmp) { 1378 1382 MEMPRINT("Couldn't copy counters, out of memory\n"); 1379 1383 return -ENOMEM;
+8
net/core/skbuff.c
··· 112 112 BUG(); 113 113 } 114 114 115 + void skb_truesize_bug(struct sk_buff *skb) 116 + { 117 + printk(KERN_ERR "SKB BUG: Invalid truesize (%u) " 118 + "len=%u, sizeof(sk_buff)=%Zd\n", 119 + skb->truesize, skb->len, sizeof(struct sk_buff)); 120 + } 121 + EXPORT_SYMBOL(skb_truesize_bug); 122 + 115 123 /* Allocate a new skbuff. We do this ourselves so we can fill in a few 116 124 * 'private' fields and also do memory statistics to find all the 117 125 * [BEEP] leaks.
+1
net/core/stream.c
··· 176 176 { 177 177 struct sock *sk = skb->sk; 178 178 179 + skb_truesize_check(skb); 179 180 atomic_sub(skb->truesize, &sk->sk_rmem_alloc); 180 181 sk->sk_forward_alloc += skb->truesize; 181 182 }
+7 -3
net/ipv4/tcp_output.c
··· 533 533 struct tcp_sock *tp = tcp_sk(sk); 534 534 struct sk_buff *buff; 535 535 int nsize, old_factor; 536 + int nlen; 536 537 u16 flags; 537 538 538 539 BUG_ON(len > skb->len); ··· 553 552 if (buff == NULL) 554 553 return -ENOMEM; /* We'll just try again later. */ 555 554 556 - buff->truesize = skb->len - len; 557 - skb->truesize -= buff->truesize; 555 + sk_charge_skb(sk, buff); 556 + nlen = skb->len - len - nsize; 557 + buff->truesize += nlen; 558 + skb->truesize -= nlen; 558 559 559 560 /* Correct the sequence numbers. */ 560 561 TCP_SKB_CB(buff)->seq = TCP_SKB_CB(skb)->seq + len; ··· 1042 1039 if (unlikely(buff == NULL)) 1043 1040 return -ENOMEM; 1044 1041 1045 - buff->truesize = nlen; 1042 + sk_charge_skb(sk, buff); 1043 + buff->truesize += nlen; 1046 1044 skb->truesize -= nlen; 1047 1045 1048 1046 /* Correct the sequence numbers. */
+2 -1
net/llc/llc_input.c
··· 118 118 u16 pdulen = eth_hdr(skb)->h_proto, 119 119 data_size = ntohs(pdulen) - llc_len; 120 120 121 - skb_trim(skb, data_size); 121 + if (unlikely(pskb_trim_rcsum(skb, data_size))) 122 + return 0; 122 123 } 123 124 return 1; 124 125 }
+1
net/socket.c
··· 490 490 struct file *file; 491 491 struct socket *sock; 492 492 493 + *err = -EBADF; 493 494 file = fget_light(fd, fput_needed); 494 495 if (file) { 495 496 sock = sock_from_file(file, err);