diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-07-28 10:26:31 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-07-28 10:26:31 -0400 |
commit | b7d0b6784565b846f3562608dfb3cf8516718724 (patch) | |
tree | 50a4931ce7e62e78b664bb8f43da2f4508c319f9 /net | |
parent | cdcf772ed163651cacac8098b4974aba7f9e1c73 (diff) | |
parent | c9272c4f9fbe2087beb3392f526dc5b19efaa56b (diff) |
Merge branch 'linus' into x86/cpu
Conflicts:
arch/x86/kernel/cpu/intel_cacheinfo.c
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'net')
94 files changed, 1004 insertions, 993 deletions
diff --git a/net/802/psnap.c b/net/802/psnap.c index ea4643931446..b3cfe5a14fca 100644 --- a/net/802/psnap.c +++ b/net/802/psnap.c | |||
@@ -31,11 +31,9 @@ static struct llc_sap *snap_sap; | |||
31 | */ | 31 | */ |
32 | static struct datalink_proto *find_snap_client(unsigned char *desc) | 32 | static struct datalink_proto *find_snap_client(unsigned char *desc) |
33 | { | 33 | { |
34 | struct list_head *entry; | ||
35 | struct datalink_proto *proto = NULL, *p; | 34 | struct datalink_proto *proto = NULL, *p; |
36 | 35 | ||
37 | list_for_each_rcu(entry, &snap_list) { | 36 | list_for_each_entry_rcu(p, &snap_list, node) { |
38 | p = list_entry(entry, struct datalink_proto, node); | ||
39 | if (!memcmp(p->type, desc, 5)) { | 37 | if (!memcmp(p->type, desc, 5)) { |
40 | proto = p; | 38 | proto = p; |
41 | break; | 39 | break; |
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index f42bc2b26b85..4bf014e51f8c 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c | |||
@@ -569,6 +569,7 @@ static void vlan_dev_set_rx_mode(struct net_device *vlan_dev) | |||
569 | * separate class since they always nest. | 569 | * separate class since they always nest. |
570 | */ | 570 | */ |
571 | static struct lock_class_key vlan_netdev_xmit_lock_key; | 571 | static struct lock_class_key vlan_netdev_xmit_lock_key; |
572 | static struct lock_class_key vlan_netdev_addr_lock_key; | ||
572 | 573 | ||
573 | static void vlan_dev_set_lockdep_one(struct net_device *dev, | 574 | static void vlan_dev_set_lockdep_one(struct net_device *dev, |
574 | struct netdev_queue *txq, | 575 | struct netdev_queue *txq, |
@@ -581,6 +582,9 @@ static void vlan_dev_set_lockdep_one(struct net_device *dev, | |||
581 | 582 | ||
582 | static void vlan_dev_set_lockdep_class(struct net_device *dev, int subclass) | 583 | static void vlan_dev_set_lockdep_class(struct net_device *dev, int subclass) |
583 | { | 584 | { |
585 | lockdep_set_class_and_subclass(&dev->addr_list_lock, | ||
586 | &vlan_netdev_addr_lock_key, | ||
587 | subclass); | ||
584 | netdev_for_each_tx_queue(dev, vlan_dev_set_lockdep_one, &subclass); | 588 | netdev_for_each_tx_queue(dev, vlan_dev_set_lockdep_one, &subclass); |
585 | } | 589 | } |
586 | 590 | ||
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c index 4507f744f44e..cdf137af7adc 100644 --- a/net/9p/trans_fd.c +++ b/net/9p/trans_fd.c | |||
@@ -1285,7 +1285,7 @@ static int p9_socket_open(struct p9_trans *trans, struct socket *csocket) | |||
1285 | int fd, ret; | 1285 | int fd, ret; |
1286 | 1286 | ||
1287 | csocket->sk->sk_allocation = GFP_NOIO; | 1287 | csocket->sk->sk_allocation = GFP_NOIO; |
1288 | fd = sock_map_fd(csocket); | 1288 | fd = sock_map_fd(csocket, 0); |
1289 | if (fd < 0) { | 1289 | if (fd < 0) { |
1290 | P9_EPRINTK(KERN_ERR, "p9_socket_open: failed to map fd\n"); | 1290 | P9_EPRINTK(KERN_ERR, "p9_socket_open: failed to map fd\n"); |
1291 | return fd; | 1291 | return fd; |
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c index 07b5b82c5eab..0c850427a85b 100644 --- a/net/appletalk/ddp.c +++ b/net/appletalk/ddp.c | |||
@@ -959,7 +959,7 @@ static unsigned long atalk_sum_skb(const struct sk_buff *skb, int offset, | |||
959 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { | 959 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { |
960 | int end; | 960 | int end; |
961 | 961 | ||
962 | BUG_TRAP(start <= offset + len); | 962 | WARN_ON(start > offset + len); |
963 | 963 | ||
964 | end = start + skb_shinfo(skb)->frags[i].size; | 964 | end = start + skb_shinfo(skb)->frags[i].size; |
965 | if ((copy = end - offset) > 0) { | 965 | if ((copy = end - offset) > 0) { |
@@ -986,7 +986,7 @@ static unsigned long atalk_sum_skb(const struct sk_buff *skb, int offset, | |||
986 | for (; list; list = list->next) { | 986 | for (; list; list = list->next) { |
987 | int end; | 987 | int end; |
988 | 988 | ||
989 | BUG_TRAP(start <= offset + len); | 989 | WARN_ON(start > offset + len); |
990 | 990 | ||
991 | end = start + list->len; | 991 | end = start + list->len; |
992 | if ((copy = end - offset) > 0) { | 992 | if ((copy = end - offset) > 0) { |
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c index 844ca5f1b2d4..c85bf8f678dc 100644 --- a/net/bluetooth/hci_sysfs.c +++ b/net/bluetooth/hci_sysfs.c | |||
@@ -398,10 +398,6 @@ int hci_register_sysfs(struct hci_dev *hdev) | |||
398 | if (device_create_file(dev, bt_attrs[i]) < 0) | 398 | if (device_create_file(dev, bt_attrs[i]) < 0) |
399 | BT_ERR("Failed to create device attribute"); | 399 | BT_ERR("Failed to create device attribute"); |
400 | 400 | ||
401 | if (sysfs_create_link(&bt_class->subsys.kobj, | ||
402 | &dev->kobj, kobject_name(&dev->kobj)) < 0) | ||
403 | BT_ERR("Failed to create class symlink"); | ||
404 | |||
405 | return 0; | 401 | return 0; |
406 | } | 402 | } |
407 | 403 | ||
@@ -409,9 +405,6 @@ void hci_unregister_sysfs(struct hci_dev *hdev) | |||
409 | { | 405 | { |
410 | BT_DBG("%p name %s type %d", hdev, hdev->name, hdev->type); | 406 | BT_DBG("%p name %s type %d", hdev, hdev->name, hdev->type); |
411 | 407 | ||
412 | sysfs_remove_link(&bt_class->subsys.kobj, | ||
413 | kobject_name(&hdev->dev.kobj)); | ||
414 | |||
415 | device_del(&hdev->dev); | 408 | device_del(&hdev->dev); |
416 | } | 409 | } |
417 | 410 | ||
diff --git a/net/bridge/netfilter/ebtable_filter.c b/net/bridge/netfilter/ebtable_filter.c index 690bc3ab186c..1a58af51a2e2 100644 --- a/net/bridge/netfilter/ebtable_filter.c +++ b/net/bridge/netfilter/ebtable_filter.c | |||
@@ -93,28 +93,20 @@ static struct nf_hook_ops ebt_ops_filter[] __read_mostly = { | |||
93 | 93 | ||
94 | static int __init ebtable_filter_init(void) | 94 | static int __init ebtable_filter_init(void) |
95 | { | 95 | { |
96 | int i, j, ret; | 96 | int ret; |
97 | 97 | ||
98 | ret = ebt_register_table(&frame_filter); | 98 | ret = ebt_register_table(&frame_filter); |
99 | if (ret < 0) | 99 | if (ret < 0) |
100 | return ret; | 100 | return ret; |
101 | for (i = 0; i < ARRAY_SIZE(ebt_ops_filter); i++) | 101 | ret = nf_register_hooks(ebt_ops_filter, ARRAY_SIZE(ebt_ops_filter)); |
102 | if ((ret = nf_register_hook(&ebt_ops_filter[i])) < 0) | 102 | if (ret < 0) |
103 | goto cleanup; | 103 | ebt_unregister_table(&frame_filter); |
104 | return ret; | ||
105 | cleanup: | ||
106 | for (j = 0; j < i; j++) | ||
107 | nf_unregister_hook(&ebt_ops_filter[j]); | ||
108 | ebt_unregister_table(&frame_filter); | ||
109 | return ret; | 104 | return ret; |
110 | } | 105 | } |
111 | 106 | ||
112 | static void __exit ebtable_filter_fini(void) | 107 | static void __exit ebtable_filter_fini(void) |
113 | { | 108 | { |
114 | int i; | 109 | nf_unregister_hooks(ebt_ops_filter, ARRAY_SIZE(ebt_ops_filter)); |
115 | |||
116 | for (i = 0; i < ARRAY_SIZE(ebt_ops_filter); i++) | ||
117 | nf_unregister_hook(&ebt_ops_filter[i]); | ||
118 | ebt_unregister_table(&frame_filter); | 110 | ebt_unregister_table(&frame_filter); |
119 | } | 111 | } |
120 | 112 | ||
diff --git a/net/bridge/netfilter/ebtable_nat.c b/net/bridge/netfilter/ebtable_nat.c index 5b495fe2d0b6..f60c1e78e575 100644 --- a/net/bridge/netfilter/ebtable_nat.c +++ b/net/bridge/netfilter/ebtable_nat.c | |||
@@ -100,28 +100,20 @@ static struct nf_hook_ops ebt_ops_nat[] __read_mostly = { | |||
100 | 100 | ||
101 | static int __init ebtable_nat_init(void) | 101 | static int __init ebtable_nat_init(void) |
102 | { | 102 | { |
103 | int i, ret, j; | 103 | int ret; |
104 | 104 | ||
105 | ret = ebt_register_table(&frame_nat); | 105 | ret = ebt_register_table(&frame_nat); |
106 | if (ret < 0) | 106 | if (ret < 0) |
107 | return ret; | 107 | return ret; |
108 | for (i = 0; i < ARRAY_SIZE(ebt_ops_nat); i++) | 108 | ret = nf_register_hooks(ebt_ops_nat, ARRAY_SIZE(ebt_ops_nat)); |
109 | if ((ret = nf_register_hook(&ebt_ops_nat[i])) < 0) | 109 | if (ret < 0) |
110 | goto cleanup; | 110 | ebt_unregister_table(&frame_nat); |
111 | return ret; | ||
112 | cleanup: | ||
113 | for (j = 0; j < i; j++) | ||
114 | nf_unregister_hook(&ebt_ops_nat[j]); | ||
115 | ebt_unregister_table(&frame_nat); | ||
116 | return ret; | 111 | return ret; |
117 | } | 112 | } |
118 | 113 | ||
119 | static void __exit ebtable_nat_fini(void) | 114 | static void __exit ebtable_nat_fini(void) |
120 | { | 115 | { |
121 | int i; | 116 | nf_unregister_hooks(ebt_ops_nat, ARRAY_SIZE(ebt_ops_nat)); |
122 | |||
123 | for (i = 0; i < ARRAY_SIZE(ebt_ops_nat); i++) | ||
124 | nf_unregister_hook(&ebt_ops_nat[i]); | ||
125 | ebt_unregister_table(&frame_nat); | 117 | ebt_unregister_table(&frame_nat); |
126 | } | 118 | } |
127 | 119 | ||
diff --git a/net/compat.c b/net/compat.c index 6e1b03b51933..67fb6a3834a3 100644 --- a/net/compat.c +++ b/net/compat.c | |||
@@ -722,9 +722,10 @@ EXPORT_SYMBOL(compat_mc_getsockopt); | |||
722 | 722 | ||
723 | /* Argument list sizes for compat_sys_socketcall */ | 723 | /* Argument list sizes for compat_sys_socketcall */ |
724 | #define AL(x) ((x) * sizeof(u32)) | 724 | #define AL(x) ((x) * sizeof(u32)) |
725 | static unsigned char nas[18]={AL(0),AL(3),AL(3),AL(3),AL(2),AL(3), | 725 | static unsigned char nas[19]={AL(0),AL(3),AL(3),AL(3),AL(2),AL(3), |
726 | AL(3),AL(3),AL(4),AL(4),AL(4),AL(6), | 726 | AL(3),AL(3),AL(4),AL(4),AL(4),AL(6), |
727 | AL(6),AL(2),AL(5),AL(5),AL(3),AL(3)}; | 727 | AL(6),AL(2),AL(5),AL(5),AL(3),AL(3), |
728 | AL(6)}; | ||
728 | #undef AL | 729 | #undef AL |
729 | 730 | ||
730 | asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg, unsigned flags) | 731 | asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg, unsigned flags) |
@@ -737,13 +738,52 @@ asmlinkage long compat_sys_recvmsg(int fd, struct compat_msghdr __user *msg, uns | |||
737 | return sys_recvmsg(fd, (struct msghdr __user *)msg, flags | MSG_CMSG_COMPAT); | 738 | return sys_recvmsg(fd, (struct msghdr __user *)msg, flags | MSG_CMSG_COMPAT); |
738 | } | 739 | } |
739 | 740 | ||
741 | asmlinkage long compat_sys_paccept(int fd, struct sockaddr __user *upeer_sockaddr, | ||
742 | int __user *upeer_addrlen, | ||
743 | const compat_sigset_t __user *sigmask, | ||
744 | compat_size_t sigsetsize, int flags) | ||
745 | { | ||
746 | compat_sigset_t ss32; | ||
747 | sigset_t ksigmask, sigsaved; | ||
748 | int ret; | ||
749 | |||
750 | if (sigmask) { | ||
751 | if (sigsetsize != sizeof(compat_sigset_t)) | ||
752 | return -EINVAL; | ||
753 | if (copy_from_user(&ss32, sigmask, sizeof(ss32))) | ||
754 | return -EFAULT; | ||
755 | sigset_from_compat(&ksigmask, &ss32); | ||
756 | |||
757 | sigdelsetmask(&ksigmask, sigmask(SIGKILL)|sigmask(SIGSTOP)); | ||
758 | sigprocmask(SIG_SETMASK, &ksigmask, &sigsaved); | ||
759 | } | ||
760 | |||
761 | ret = do_accept(fd, upeer_sockaddr, upeer_addrlen, flags); | ||
762 | |||
763 | if (ret == -ERESTARTNOHAND) { | ||
764 | /* | ||
765 | * Don't restore the signal mask yet. Let do_signal() deliver | ||
766 | * the signal on the way back to userspace, before the signal | ||
767 | * mask is restored. | ||
768 | */ | ||
769 | if (sigmask) { | ||
770 | memcpy(¤t->saved_sigmask, &sigsaved, | ||
771 | sizeof(sigsaved)); | ||
772 | set_restore_sigmask(); | ||
773 | } | ||
774 | } else if (sigmask) | ||
775 | sigprocmask(SIG_SETMASK, &sigsaved, NULL); | ||
776 | |||
777 | return ret; | ||
778 | } | ||
779 | |||
740 | asmlinkage long compat_sys_socketcall(int call, u32 __user *args) | 780 | asmlinkage long compat_sys_socketcall(int call, u32 __user *args) |
741 | { | 781 | { |
742 | int ret; | 782 | int ret; |
743 | u32 a[6]; | 783 | u32 a[6]; |
744 | u32 a0, a1; | 784 | u32 a0, a1; |
745 | 785 | ||
746 | if (call < SYS_SOCKET || call > SYS_RECVMSG) | 786 | if (call < SYS_SOCKET || call > SYS_PACCEPT) |
747 | return -EINVAL; | 787 | return -EINVAL; |
748 | if (copy_from_user(a, args, nas[call])) | 788 | if (copy_from_user(a, args, nas[call])) |
749 | return -EFAULT; | 789 | return -EFAULT; |
@@ -764,7 +804,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args) | |||
764 | ret = sys_listen(a0, a1); | 804 | ret = sys_listen(a0, a1); |
765 | break; | 805 | break; |
766 | case SYS_ACCEPT: | 806 | case SYS_ACCEPT: |
767 | ret = sys_accept(a0, compat_ptr(a1), compat_ptr(a[2])); | 807 | ret = do_accept(a0, compat_ptr(a1), compat_ptr(a[2]), 0); |
768 | break; | 808 | break; |
769 | case SYS_GETSOCKNAME: | 809 | case SYS_GETSOCKNAME: |
770 | ret = sys_getsockname(a0, compat_ptr(a1), compat_ptr(a[2])); | 810 | ret = sys_getsockname(a0, compat_ptr(a1), compat_ptr(a[2])); |
@@ -804,6 +844,10 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args) | |||
804 | case SYS_RECVMSG: | 844 | case SYS_RECVMSG: |
805 | ret = compat_sys_recvmsg(a0, compat_ptr(a1), a[2]); | 845 | ret = compat_sys_recvmsg(a0, compat_ptr(a1), a[2]); |
806 | break; | 846 | break; |
847 | case SYS_PACCEPT: | ||
848 | ret = compat_sys_paccept(a0, compat_ptr(a1), compat_ptr(a[2]), | ||
849 | compat_ptr(a[3]), a[4], a[5]); | ||
850 | break; | ||
807 | default: | 851 | default: |
808 | ret = -EINVAL; | 852 | ret = -EINVAL; |
809 | break; | 853 | break; |
diff --git a/net/core/datagram.c b/net/core/datagram.c index 8a28fc93b724..dd61dcad6019 100644 --- a/net/core/datagram.c +++ b/net/core/datagram.c | |||
@@ -285,7 +285,7 @@ int skb_copy_datagram_iovec(const struct sk_buff *skb, int offset, | |||
285 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { | 285 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { |
286 | int end; | 286 | int end; |
287 | 287 | ||
288 | BUG_TRAP(start <= offset + len); | 288 | WARN_ON(start > offset + len); |
289 | 289 | ||
290 | end = start + skb_shinfo(skb)->frags[i].size; | 290 | end = start + skb_shinfo(skb)->frags[i].size; |
291 | if ((copy = end - offset) > 0) { | 291 | if ((copy = end - offset) > 0) { |
@@ -315,7 +315,7 @@ int skb_copy_datagram_iovec(const struct sk_buff *skb, int offset, | |||
315 | for (; list; list = list->next) { | 315 | for (; list; list = list->next) { |
316 | int end; | 316 | int end; |
317 | 317 | ||
318 | BUG_TRAP(start <= offset + len); | 318 | WARN_ON(start > offset + len); |
319 | 319 | ||
320 | end = start + list->len; | 320 | end = start + list->len; |
321 | if ((copy = end - offset) > 0) { | 321 | if ((copy = end - offset) > 0) { |
@@ -366,7 +366,7 @@ static int skb_copy_and_csum_datagram(const struct sk_buff *skb, int offset, | |||
366 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { | 366 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { |
367 | int end; | 367 | int end; |
368 | 368 | ||
369 | BUG_TRAP(start <= offset + len); | 369 | WARN_ON(start > offset + len); |
370 | 370 | ||
371 | end = start + skb_shinfo(skb)->frags[i].size; | 371 | end = start + skb_shinfo(skb)->frags[i].size; |
372 | if ((copy = end - offset) > 0) { | 372 | if ((copy = end - offset) > 0) { |
@@ -402,7 +402,7 @@ static int skb_copy_and_csum_datagram(const struct sk_buff *skb, int offset, | |||
402 | for (; list; list=list->next) { | 402 | for (; list; list=list->next) { |
403 | int end; | 403 | int end; |
404 | 404 | ||
405 | BUG_TRAP(start <= offset + len); | 405 | WARN_ON(start > offset + len); |
406 | 406 | ||
407 | end = start + list->len; | 407 | end = start + list->len; |
408 | if ((copy = end - offset) > 0) { | 408 | if ((copy = end - offset) > 0) { |
diff --git a/net/core/dev.c b/net/core/dev.c index cbc34c0db376..8d13a9b9f1df 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -261,7 +261,7 @@ static RAW_NOTIFIER_HEAD(netdev_chain); | |||
261 | 261 | ||
262 | DEFINE_PER_CPU(struct softnet_data, softnet_data); | 262 | DEFINE_PER_CPU(struct softnet_data, softnet_data); |
263 | 263 | ||
264 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | 264 | #ifdef CONFIG_LOCKDEP |
265 | /* | 265 | /* |
266 | * register_netdevice() inits txq->_xmit_lock and sets lockdep class | 266 | * register_netdevice() inits txq->_xmit_lock and sets lockdep class |
267 | * according to dev->type | 267 | * according to dev->type |
@@ -301,6 +301,7 @@ static const char *netdev_lock_name[] = | |||
301 | "_xmit_NONE"}; | 301 | "_xmit_NONE"}; |
302 | 302 | ||
303 | static struct lock_class_key netdev_xmit_lock_key[ARRAY_SIZE(netdev_lock_type)]; | 303 | static struct lock_class_key netdev_xmit_lock_key[ARRAY_SIZE(netdev_lock_type)]; |
304 | static struct lock_class_key netdev_addr_lock_key[ARRAY_SIZE(netdev_lock_type)]; | ||
304 | 305 | ||
305 | static inline unsigned short netdev_lock_pos(unsigned short dev_type) | 306 | static inline unsigned short netdev_lock_pos(unsigned short dev_type) |
306 | { | 307 | { |
@@ -313,8 +314,8 @@ static inline unsigned short netdev_lock_pos(unsigned short dev_type) | |||
313 | return ARRAY_SIZE(netdev_lock_type) - 1; | 314 | return ARRAY_SIZE(netdev_lock_type) - 1; |
314 | } | 315 | } |
315 | 316 | ||
316 | static inline void netdev_set_lockdep_class(spinlock_t *lock, | 317 | static inline void netdev_set_xmit_lockdep_class(spinlock_t *lock, |
317 | unsigned short dev_type) | 318 | unsigned short dev_type) |
318 | { | 319 | { |
319 | int i; | 320 | int i; |
320 | 321 | ||
@@ -322,9 +323,22 @@ static inline void netdev_set_lockdep_class(spinlock_t *lock, | |||
322 | lockdep_set_class_and_name(lock, &netdev_xmit_lock_key[i], | 323 | lockdep_set_class_and_name(lock, &netdev_xmit_lock_key[i], |
323 | netdev_lock_name[i]); | 324 | netdev_lock_name[i]); |
324 | } | 325 | } |
326 | |||
327 | static inline void netdev_set_addr_lockdep_class(struct net_device *dev) | ||
328 | { | ||
329 | int i; | ||
330 | |||
331 | i = netdev_lock_pos(dev->type); | ||
332 | lockdep_set_class_and_name(&dev->addr_list_lock, | ||
333 | &netdev_addr_lock_key[i], | ||
334 | netdev_lock_name[i]); | ||
335 | } | ||
325 | #else | 336 | #else |
326 | static inline void netdev_set_lockdep_class(spinlock_t *lock, | 337 | static inline void netdev_set_xmit_lockdep_class(spinlock_t *lock, |
327 | unsigned short dev_type) | 338 | unsigned short dev_type) |
339 | { | ||
340 | } | ||
341 | static inline void netdev_set_addr_lockdep_class(struct net_device *dev) | ||
328 | { | 342 | { |
329 | } | 343 | } |
330 | #endif | 344 | #endif |
@@ -1327,9 +1341,6 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev) | |||
1327 | 1341 | ||
1328 | void __netif_schedule(struct Qdisc *q) | 1342 | void __netif_schedule(struct Qdisc *q) |
1329 | { | 1343 | { |
1330 | if (WARN_ON_ONCE(q == &noop_qdisc)) | ||
1331 | return; | ||
1332 | |||
1333 | if (!test_and_set_bit(__QDISC_STATE_SCHED, &q->state)) { | 1344 | if (!test_and_set_bit(__QDISC_STATE_SCHED, &q->state)) { |
1334 | struct softnet_data *sd; | 1345 | struct softnet_data *sd; |
1335 | unsigned long flags; | 1346 | unsigned long flags; |
@@ -1645,32 +1656,6 @@ out_kfree_skb: | |||
1645 | return 0; | 1656 | return 0; |
1646 | } | 1657 | } |
1647 | 1658 | ||
1648 | /** | ||
1649 | * dev_queue_xmit - transmit a buffer | ||
1650 | * @skb: buffer to transmit | ||
1651 | * | ||
1652 | * Queue a buffer for transmission to a network device. The caller must | ||
1653 | * have set the device and priority and built the buffer before calling | ||
1654 | * this function. The function can be called from an interrupt. | ||
1655 | * | ||
1656 | * A negative errno code is returned on a failure. A success does not | ||
1657 | * guarantee the frame will be transmitted as it may be dropped due | ||
1658 | * to congestion or traffic shaping. | ||
1659 | * | ||
1660 | * ----------------------------------------------------------------------------------- | ||
1661 | * I notice this method can also return errors from the queue disciplines, | ||
1662 | * including NET_XMIT_DROP, which is a positive value. So, errors can also | ||
1663 | * be positive. | ||
1664 | * | ||
1665 | * Regardless of the return value, the skb is consumed, so it is currently | ||
1666 | * difficult to retry a send to this method. (You can bump the ref count | ||
1667 | * before sending to hold a reference for retry if you are careful.) | ||
1668 | * | ||
1669 | * When calling this method, interrupts MUST be enabled. This is because | ||
1670 | * the BH enable code must have IRQs enabled so that it will not deadlock. | ||
1671 | * --BLG | ||
1672 | */ | ||
1673 | |||
1674 | static u32 simple_tx_hashrnd; | 1659 | static u32 simple_tx_hashrnd; |
1675 | static int simple_tx_hashrnd_initialized = 0; | 1660 | static int simple_tx_hashrnd_initialized = 0; |
1676 | 1661 | ||
@@ -1738,6 +1723,31 @@ static struct netdev_queue *dev_pick_tx(struct net_device *dev, | |||
1738 | return netdev_get_tx_queue(dev, queue_index); | 1723 | return netdev_get_tx_queue(dev, queue_index); |
1739 | } | 1724 | } |
1740 | 1725 | ||
1726 | /** | ||
1727 | * dev_queue_xmit - transmit a buffer | ||
1728 | * @skb: buffer to transmit | ||
1729 | * | ||
1730 | * Queue a buffer for transmission to a network device. The caller must | ||
1731 | * have set the device and priority and built the buffer before calling | ||
1732 | * this function. The function can be called from an interrupt. | ||
1733 | * | ||
1734 | * A negative errno code is returned on a failure. A success does not | ||
1735 | * guarantee the frame will be transmitted as it may be dropped due | ||
1736 | * to congestion or traffic shaping. | ||
1737 | * | ||
1738 | * ----------------------------------------------------------------------------------- | ||
1739 | * I notice this method can also return errors from the queue disciplines, | ||
1740 | * including NET_XMIT_DROP, which is a positive value. So, errors can also | ||
1741 | * be positive. | ||
1742 | * | ||
1743 | * Regardless of the return value, the skb is consumed, so it is currently | ||
1744 | * difficult to retry a send to this method. (You can bump the ref count | ||
1745 | * before sending to hold a reference for retry if you are careful.) | ||
1746 | * | ||
1747 | * When calling this method, interrupts MUST be enabled. This is because | ||
1748 | * the BH enable code must have IRQs enabled so that it will not deadlock. | ||
1749 | * --BLG | ||
1750 | */ | ||
1741 | int dev_queue_xmit(struct sk_buff *skb) | 1751 | int dev_queue_xmit(struct sk_buff *skb) |
1742 | { | 1752 | { |
1743 | struct net_device *dev = skb->dev; | 1753 | struct net_device *dev = skb->dev; |
@@ -1963,7 +1973,7 @@ static void net_tx_action(struct softirq_action *h) | |||
1963 | struct sk_buff *skb = clist; | 1973 | struct sk_buff *skb = clist; |
1964 | clist = clist->next; | 1974 | clist = clist->next; |
1965 | 1975 | ||
1966 | BUG_TRAP(!atomic_read(&skb->users)); | 1976 | WARN_ON(atomic_read(&skb->users)); |
1967 | __kfree_skb(skb); | 1977 | __kfree_skb(skb); |
1968 | } | 1978 | } |
1969 | } | 1979 | } |
@@ -2385,7 +2395,7 @@ out: | |||
2385 | */ | 2395 | */ |
2386 | if (!cpus_empty(net_dma.channel_mask)) { | 2396 | if (!cpus_empty(net_dma.channel_mask)) { |
2387 | int chan_idx; | 2397 | int chan_idx; |
2388 | for_each_cpu_mask(chan_idx, net_dma.channel_mask) { | 2398 | for_each_cpu_mask_nr(chan_idx, net_dma.channel_mask) { |
2389 | struct dma_chan *chan = net_dma.channels[chan_idx]; | 2399 | struct dma_chan *chan = net_dma.channels[chan_idx]; |
2390 | if (chan) | 2400 | if (chan) |
2391 | dma_async_memcpy_issue_pending(chan); | 2401 | dma_async_memcpy_issue_pending(chan); |
@@ -3837,7 +3847,7 @@ static void rollback_registered(struct net_device *dev) | |||
3837 | dev->uninit(dev); | 3847 | dev->uninit(dev); |
3838 | 3848 | ||
3839 | /* Notifier chain MUST detach us from master device. */ | 3849 | /* Notifier chain MUST detach us from master device. */ |
3840 | BUG_TRAP(!dev->master); | 3850 | WARN_ON(dev->master); |
3841 | 3851 | ||
3842 | /* Remove entries from kobject tree */ | 3852 | /* Remove entries from kobject tree */ |
3843 | netdev_unregister_kobject(dev); | 3853 | netdev_unregister_kobject(dev); |
@@ -3852,7 +3862,7 @@ static void __netdev_init_queue_locks_one(struct net_device *dev, | |||
3852 | void *_unused) | 3862 | void *_unused) |
3853 | { | 3863 | { |
3854 | spin_lock_init(&dev_queue->_xmit_lock); | 3864 | spin_lock_init(&dev_queue->_xmit_lock); |
3855 | netdev_set_lockdep_class(&dev_queue->_xmit_lock, dev->type); | 3865 | netdev_set_xmit_lockdep_class(&dev_queue->_xmit_lock, dev->type); |
3856 | dev_queue->xmit_lock_owner = -1; | 3866 | dev_queue->xmit_lock_owner = -1; |
3857 | } | 3867 | } |
3858 | 3868 | ||
@@ -3897,6 +3907,7 @@ int register_netdevice(struct net_device *dev) | |||
3897 | net = dev_net(dev); | 3907 | net = dev_net(dev); |
3898 | 3908 | ||
3899 | spin_lock_init(&dev->addr_list_lock); | 3909 | spin_lock_init(&dev->addr_list_lock); |
3910 | netdev_set_addr_lockdep_class(dev); | ||
3900 | netdev_init_queue_locks(dev); | 3911 | netdev_init_queue_locks(dev); |
3901 | 3912 | ||
3902 | dev->iflink = -1; | 3913 | dev->iflink = -1; |
@@ -4158,9 +4169,9 @@ void netdev_run_todo(void) | |||
4158 | 4169 | ||
4159 | /* paranoia */ | 4170 | /* paranoia */ |
4160 | BUG_ON(atomic_read(&dev->refcnt)); | 4171 | BUG_ON(atomic_read(&dev->refcnt)); |
4161 | BUG_TRAP(!dev->ip_ptr); | 4172 | WARN_ON(dev->ip_ptr); |
4162 | BUG_TRAP(!dev->ip6_ptr); | 4173 | WARN_ON(dev->ip6_ptr); |
4163 | BUG_TRAP(!dev->dn_ptr); | 4174 | WARN_ON(dev->dn_ptr); |
4164 | 4175 | ||
4165 | if (dev->destructor) | 4176 | if (dev->destructor) |
4166 | dev->destructor(dev); | 4177 | dev->destructor(dev); |
@@ -4207,7 +4218,7 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name, | |||
4207 | { | 4218 | { |
4208 | struct netdev_queue *tx; | 4219 | struct netdev_queue *tx; |
4209 | struct net_device *dev; | 4220 | struct net_device *dev; |
4210 | int alloc_size; | 4221 | size_t alloc_size; |
4211 | void *p; | 4222 | void *p; |
4212 | 4223 | ||
4213 | BUG_ON(strlen(name) >= sizeof(dev->name)); | 4224 | BUG_ON(strlen(name) >= sizeof(dev->name)); |
@@ -4227,7 +4238,7 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name, | |||
4227 | return NULL; | 4238 | return NULL; |
4228 | } | 4239 | } |
4229 | 4240 | ||
4230 | tx = kzalloc(sizeof(struct netdev_queue) * queue_count, GFP_KERNEL); | 4241 | tx = kcalloc(queue_count, sizeof(struct netdev_queue), GFP_KERNEL); |
4231 | if (!tx) { | 4242 | if (!tx) { |
4232 | printk(KERN_ERR "alloc_netdev: Unable to allocate " | 4243 | printk(KERN_ERR "alloc_netdev: Unable to allocate " |
4233 | "tx qdiscs.\n"); | 4244 | "tx qdiscs.\n"); |
@@ -4519,7 +4530,7 @@ static void net_dma_rebalance(struct net_dma *net_dma) | |||
4519 | i = 0; | 4530 | i = 0; |
4520 | cpu = first_cpu(cpu_online_map); | 4531 | cpu = first_cpu(cpu_online_map); |
4521 | 4532 | ||
4522 | for_each_cpu_mask(chan_idx, net_dma->channel_mask) { | 4533 | for_each_cpu_mask_nr(chan_idx, net_dma->channel_mask) { |
4523 | chan = net_dma->channels[chan_idx]; | 4534 | chan = net_dma->channels[chan_idx]; |
4524 | 4535 | ||
4525 | n = ((num_online_cpus() / cpus_weight(net_dma->channel_mask)) | 4536 | n = ((num_online_cpus() / cpus_weight(net_dma->channel_mask)) |
@@ -4686,6 +4697,26 @@ err_name: | |||
4686 | return -ENOMEM; | 4697 | return -ENOMEM; |
4687 | } | 4698 | } |
4688 | 4699 | ||
4700 | char *netdev_drivername(struct net_device *dev, char *buffer, int len) | ||
4701 | { | ||
4702 | struct device_driver *driver; | ||
4703 | struct device *parent; | ||
4704 | |||
4705 | if (len <= 0 || !buffer) | ||
4706 | return buffer; | ||
4707 | buffer[0] = 0; | ||
4708 | |||
4709 | parent = dev->dev.parent; | ||
4710 | |||
4711 | if (!parent) | ||
4712 | return buffer; | ||
4713 | |||
4714 | driver = parent->driver; | ||
4715 | if (driver && driver->name) | ||
4716 | strlcpy(buffer, driver->name, len); | ||
4717 | return buffer; | ||
4718 | } | ||
4719 | |||
4689 | static void __net_exit netdev_exit(struct net *net) | 4720 | static void __net_exit netdev_exit(struct net *net) |
4690 | { | 4721 | { |
4691 | kfree(net->dev_name_head); | 4722 | kfree(net->dev_name_head); |
diff --git a/net/core/request_sock.c b/net/core/request_sock.c index 2d3035d3abd7..7552495aff7a 100644 --- a/net/core/request_sock.c +++ b/net/core/request_sock.c | |||
@@ -123,7 +123,7 @@ void reqsk_queue_destroy(struct request_sock_queue *queue) | |||
123 | } | 123 | } |
124 | } | 124 | } |
125 | 125 | ||
126 | BUG_TRAP(lopt->qlen == 0); | 126 | WARN_ON(lopt->qlen != 0); |
127 | if (lopt_size > PAGE_SIZE) | 127 | if (lopt_size > PAGE_SIZE) |
128 | vfree(lopt); | 128 | vfree(lopt); |
129 | else | 129 | else |
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index e4115672b6cf..4e0c92274189 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c | |||
@@ -1200,7 +1200,7 @@ int skb_copy_bits(const struct sk_buff *skb, int offset, void *to, int len) | |||
1200 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { | 1200 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { |
1201 | int end; | 1201 | int end; |
1202 | 1202 | ||
1203 | BUG_TRAP(start <= offset + len); | 1203 | WARN_ON(start > offset + len); |
1204 | 1204 | ||
1205 | end = start + skb_shinfo(skb)->frags[i].size; | 1205 | end = start + skb_shinfo(skb)->frags[i].size; |
1206 | if ((copy = end - offset) > 0) { | 1206 | if ((copy = end - offset) > 0) { |
@@ -1229,7 +1229,7 @@ int skb_copy_bits(const struct sk_buff *skb, int offset, void *to, int len) | |||
1229 | for (; list; list = list->next) { | 1229 | for (; list; list = list->next) { |
1230 | int end; | 1230 | int end; |
1231 | 1231 | ||
1232 | BUG_TRAP(start <= offset + len); | 1232 | WARN_ON(start > offset + len); |
1233 | 1233 | ||
1234 | end = start + list->len; | 1234 | end = start + list->len; |
1235 | if ((copy = end - offset) > 0) { | 1235 | if ((copy = end - offset) > 0) { |
@@ -1475,7 +1475,7 @@ int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len) | |||
1475 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; | 1475 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; |
1476 | int end; | 1476 | int end; |
1477 | 1477 | ||
1478 | BUG_TRAP(start <= offset + len); | 1478 | WARN_ON(start > offset + len); |
1479 | 1479 | ||
1480 | end = start + frag->size; | 1480 | end = start + frag->size; |
1481 | if ((copy = end - offset) > 0) { | 1481 | if ((copy = end - offset) > 0) { |
@@ -1503,7 +1503,7 @@ int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len) | |||
1503 | for (; list; list = list->next) { | 1503 | for (; list; list = list->next) { |
1504 | int end; | 1504 | int end; |
1505 | 1505 | ||
1506 | BUG_TRAP(start <= offset + len); | 1506 | WARN_ON(start > offset + len); |
1507 | 1507 | ||
1508 | end = start + list->len; | 1508 | end = start + list->len; |
1509 | if ((copy = end - offset) > 0) { | 1509 | if ((copy = end - offset) > 0) { |
@@ -1552,7 +1552,7 @@ __wsum skb_checksum(const struct sk_buff *skb, int offset, | |||
1552 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { | 1552 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { |
1553 | int end; | 1553 | int end; |
1554 | 1554 | ||
1555 | BUG_TRAP(start <= offset + len); | 1555 | WARN_ON(start > offset + len); |
1556 | 1556 | ||
1557 | end = start + skb_shinfo(skb)->frags[i].size; | 1557 | end = start + skb_shinfo(skb)->frags[i].size; |
1558 | if ((copy = end - offset) > 0) { | 1558 | if ((copy = end - offset) > 0) { |
@@ -1581,7 +1581,7 @@ __wsum skb_checksum(const struct sk_buff *skb, int offset, | |||
1581 | for (; list; list = list->next) { | 1581 | for (; list; list = list->next) { |
1582 | int end; | 1582 | int end; |
1583 | 1583 | ||
1584 | BUG_TRAP(start <= offset + len); | 1584 | WARN_ON(start > offset + len); |
1585 | 1585 | ||
1586 | end = start + list->len; | 1586 | end = start + list->len; |
1587 | if ((copy = end - offset) > 0) { | 1587 | if ((copy = end - offset) > 0) { |
@@ -1629,7 +1629,7 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, | |||
1629 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { | 1629 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { |
1630 | int end; | 1630 | int end; |
1631 | 1631 | ||
1632 | BUG_TRAP(start <= offset + len); | 1632 | WARN_ON(start > offset + len); |
1633 | 1633 | ||
1634 | end = start + skb_shinfo(skb)->frags[i].size; | 1634 | end = start + skb_shinfo(skb)->frags[i].size; |
1635 | if ((copy = end - offset) > 0) { | 1635 | if ((copy = end - offset) > 0) { |
@@ -1662,7 +1662,7 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, | |||
1662 | __wsum csum2; | 1662 | __wsum csum2; |
1663 | int end; | 1663 | int end; |
1664 | 1664 | ||
1665 | BUG_TRAP(start <= offset + len); | 1665 | WARN_ON(start > offset + len); |
1666 | 1666 | ||
1667 | end = start + list->len; | 1667 | end = start + list->len; |
1668 | if ((copy = end - offset) > 0) { | 1668 | if ((copy = end - offset) > 0) { |
@@ -2373,7 +2373,7 @@ __skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len) | |||
2373 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { | 2373 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { |
2374 | int end; | 2374 | int end; |
2375 | 2375 | ||
2376 | BUG_TRAP(start <= offset + len); | 2376 | WARN_ON(start > offset + len); |
2377 | 2377 | ||
2378 | end = start + skb_shinfo(skb)->frags[i].size; | 2378 | end = start + skb_shinfo(skb)->frags[i].size; |
2379 | if ((copy = end - offset) > 0) { | 2379 | if ((copy = end - offset) > 0) { |
@@ -2397,7 +2397,7 @@ __skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len) | |||
2397 | for (; list; list = list->next) { | 2397 | for (; list; list = list->next) { |
2398 | int end; | 2398 | int end; |
2399 | 2399 | ||
2400 | BUG_TRAP(start <= offset + len); | 2400 | WARN_ON(start > offset + len); |
2401 | 2401 | ||
2402 | end = start + list->len; | 2402 | end = start + list->len; |
2403 | if ((copy = end - offset) > 0) { | 2403 | if ((copy = end - offset) > 0) { |
diff --git a/net/core/sock.c b/net/core/sock.c index 10a64d57078c..91f8bbc93526 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -180,7 +180,7 @@ static const char *af_family_clock_key_strings[AF_MAX+1] = { | |||
180 | "clock-AF_ASH" , "clock-AF_ECONET" , "clock-AF_ATMSVC" , | 180 | "clock-AF_ASH" , "clock-AF_ECONET" , "clock-AF_ATMSVC" , |
181 | "clock-21" , "clock-AF_SNA" , "clock-AF_IRDA" , | 181 | "clock-21" , "clock-AF_SNA" , "clock-AF_IRDA" , |
182 | "clock-AF_PPPOX" , "clock-AF_WANPIPE" , "clock-AF_LLC" , | 182 | "clock-AF_PPPOX" , "clock-AF_WANPIPE" , "clock-AF_LLC" , |
183 | "clock-27" , "clock-28" , "clock-29" , | 183 | "clock-27" , "clock-28" , "clock-AF_CAN" , |
184 | "clock-AF_TIPC" , "clock-AF_BLUETOOTH", "clock-AF_IUCV" , | 184 | "clock-AF_TIPC" , "clock-AF_BLUETOOTH", "clock-AF_IUCV" , |
185 | "clock-AF_RXRPC" , "clock-AF_MAX" | 185 | "clock-AF_RXRPC" , "clock-AF_MAX" |
186 | }; | 186 | }; |
diff --git a/net/core/stream.c b/net/core/stream.c index 4a0ad152c9c4..a6b3437ff082 100644 --- a/net/core/stream.c +++ b/net/core/stream.c | |||
@@ -192,13 +192,13 @@ void sk_stream_kill_queues(struct sock *sk) | |||
192 | __skb_queue_purge(&sk->sk_error_queue); | 192 | __skb_queue_purge(&sk->sk_error_queue); |
193 | 193 | ||
194 | /* Next, the write queue. */ | 194 | /* Next, the write queue. */ |
195 | BUG_TRAP(skb_queue_empty(&sk->sk_write_queue)); | 195 | WARN_ON(!skb_queue_empty(&sk->sk_write_queue)); |
196 | 196 | ||
197 | /* Account for returned memory. */ | 197 | /* Account for returned memory. */ |
198 | sk_mem_reclaim(sk); | 198 | sk_mem_reclaim(sk); |
199 | 199 | ||
200 | BUG_TRAP(!sk->sk_wmem_queued); | 200 | WARN_ON(sk->sk_wmem_queued); |
201 | BUG_TRAP(!sk->sk_forward_alloc); | 201 | WARN_ON(sk->sk_forward_alloc); |
202 | 202 | ||
203 | /* It is _impossible_ for the backlog to contain anything | 203 | /* It is _impossible_ for the backlog to contain anything |
204 | * when we get here. All user references to this socket | 204 | * when we get here. All user references to this socket |
diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c index a570e2af22cb..f686467ff12b 100644 --- a/net/core/sysctl_net_core.c +++ b/net/core/sysctl_net_core.c | |||
@@ -67,7 +67,7 @@ static struct ctl_table net_core_table[] = { | |||
67 | { | 67 | { |
68 | .ctl_name = NET_CORE_MSG_COST, | 68 | .ctl_name = NET_CORE_MSG_COST, |
69 | .procname = "message_cost", | 69 | .procname = "message_cost", |
70 | .data = &net_msg_cost, | 70 | .data = &net_ratelimit_state.interval, |
71 | .maxlen = sizeof(int), | 71 | .maxlen = sizeof(int), |
72 | .mode = 0644, | 72 | .mode = 0644, |
73 | .proc_handler = &proc_dointvec_jiffies, | 73 | .proc_handler = &proc_dointvec_jiffies, |
@@ -76,7 +76,7 @@ static struct ctl_table net_core_table[] = { | |||
76 | { | 76 | { |
77 | .ctl_name = NET_CORE_MSG_BURST, | 77 | .ctl_name = NET_CORE_MSG_BURST, |
78 | .procname = "message_burst", | 78 | .procname = "message_burst", |
79 | .data = &net_msg_burst, | 79 | .data = &net_ratelimit_state.burst, |
80 | .maxlen = sizeof(int), | 80 | .maxlen = sizeof(int), |
81 | .mode = 0644, | 81 | .mode = 0644, |
82 | .proc_handler = &proc_dointvec, | 82 | .proc_handler = &proc_dointvec, |
diff --git a/net/core/user_dma.c b/net/core/user_dma.c index c77aff9c6eb3..164b090d5ac3 100644 --- a/net/core/user_dma.c +++ b/net/core/user_dma.c | |||
@@ -27,13 +27,13 @@ | |||
27 | 27 | ||
28 | #include <linux/dmaengine.h> | 28 | #include <linux/dmaengine.h> |
29 | #include <linux/socket.h> | 29 | #include <linux/socket.h> |
30 | #include <linux/rtnetlink.h> /* for BUG_TRAP */ | ||
31 | #include <net/tcp.h> | 30 | #include <net/tcp.h> |
32 | #include <net/netdma.h> | 31 | #include <net/netdma.h> |
33 | 32 | ||
34 | #define NET_DMA_DEFAULT_COPYBREAK 4096 | 33 | #define NET_DMA_DEFAULT_COPYBREAK 4096 |
35 | 34 | ||
36 | int sysctl_tcp_dma_copybreak = NET_DMA_DEFAULT_COPYBREAK; | 35 | int sysctl_tcp_dma_copybreak = NET_DMA_DEFAULT_COPYBREAK; |
36 | EXPORT_SYMBOL(sysctl_tcp_dma_copybreak); | ||
37 | 37 | ||
38 | /** | 38 | /** |
39 | * dma_skb_copy_datagram_iovec - Copy a datagram to an iovec. | 39 | * dma_skb_copy_datagram_iovec - Copy a datagram to an iovec. |
@@ -71,7 +71,7 @@ int dma_skb_copy_datagram_iovec(struct dma_chan *chan, | |||
71 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { | 71 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { |
72 | int end; | 72 | int end; |
73 | 73 | ||
74 | BUG_TRAP(start <= offset + len); | 74 | WARN_ON(start > offset + len); |
75 | 75 | ||
76 | end = start + skb_shinfo(skb)->frags[i].size; | 76 | end = start + skb_shinfo(skb)->frags[i].size; |
77 | copy = end - offset; | 77 | copy = end - offset; |
@@ -100,7 +100,7 @@ int dma_skb_copy_datagram_iovec(struct dma_chan *chan, | |||
100 | for (; list; list = list->next) { | 100 | for (; list; list = list->next) { |
101 | int end; | 101 | int end; |
102 | 102 | ||
103 | BUG_TRAP(start <= offset + len); | 103 | WARN_ON(start > offset + len); |
104 | 104 | ||
105 | end = start + list->len; | 105 | end = start + list->len; |
106 | copy = end - offset; | 106 | copy = end - offset; |
diff --git a/net/core/utils.c b/net/core/utils.c index 8031eb59054e..72e0ebe964a0 100644 --- a/net/core/utils.c +++ b/net/core/utils.c | |||
@@ -31,17 +31,16 @@ | |||
31 | #include <asm/system.h> | 31 | #include <asm/system.h> |
32 | #include <asm/uaccess.h> | 32 | #include <asm/uaccess.h> |
33 | 33 | ||
34 | int net_msg_cost __read_mostly = 5*HZ; | ||
35 | int net_msg_burst __read_mostly = 10; | ||
36 | int net_msg_warn __read_mostly = 1; | 34 | int net_msg_warn __read_mostly = 1; |
37 | EXPORT_SYMBOL(net_msg_warn); | 35 | EXPORT_SYMBOL(net_msg_warn); |
38 | 36 | ||
37 | DEFINE_RATELIMIT_STATE(net_ratelimit_state, 5 * HZ, 10); | ||
39 | /* | 38 | /* |
40 | * All net warning printk()s should be guarded by this function. | 39 | * All net warning printk()s should be guarded by this function. |
41 | */ | 40 | */ |
42 | int net_ratelimit(void) | 41 | int net_ratelimit(void) |
43 | { | 42 | { |
44 | return __printk_ratelimit(net_msg_cost, net_msg_burst); | 43 | return __ratelimit(&net_ratelimit_state); |
45 | } | 44 | } |
46 | EXPORT_SYMBOL(net_ratelimit); | 45 | EXPORT_SYMBOL(net_ratelimit); |
47 | 46 | ||
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h index 32617e0576cb..743d85fcd651 100644 --- a/net/dccp/dccp.h +++ b/net/dccp/dccp.h | |||
@@ -164,7 +164,7 @@ static inline bool dccp_loss_free(const u64 s1, const u64 s2, const u64 ndp) | |||
164 | { | 164 | { |
165 | s64 delta = dccp_delta_seqno(s1, s2); | 165 | s64 delta = dccp_delta_seqno(s1, s2); |
166 | 166 | ||
167 | BUG_TRAP(delta >= 0); | 167 | WARN_ON(delta < 0); |
168 | return (u64)delta <= ndp + 1; | 168 | return (u64)delta <= ndp + 1; |
169 | } | 169 | } |
170 | 170 | ||
diff --git a/net/dccp/input.c b/net/dccp/input.c index 08392ed86c25..df2f110df94a 100644 --- a/net/dccp/input.c +++ b/net/dccp/input.c | |||
@@ -413,7 +413,7 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk, | |||
413 | 413 | ||
414 | /* Stop the REQUEST timer */ | 414 | /* Stop the REQUEST timer */ |
415 | inet_csk_clear_xmit_timer(sk, ICSK_TIME_RETRANS); | 415 | inet_csk_clear_xmit_timer(sk, ICSK_TIME_RETRANS); |
416 | BUG_TRAP(sk->sk_send_head != NULL); | 416 | WARN_ON(sk->sk_send_head == NULL); |
417 | __kfree_skb(sk->sk_send_head); | 417 | __kfree_skb(sk->sk_send_head); |
418 | sk->sk_send_head = NULL; | 418 | sk->sk_send_head = NULL; |
419 | 419 | ||
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index 2622ace17c46..a835b88237cb 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c | |||
@@ -283,7 +283,7 @@ static void dccp_v4_err(struct sk_buff *skb, u32 info) | |||
283 | * ICMPs are not backlogged, hence we cannot get an established | 283 | * ICMPs are not backlogged, hence we cannot get an established |
284 | * socket here. | 284 | * socket here. |
285 | */ | 285 | */ |
286 | BUG_TRAP(!req->sk); | 286 | WARN_ON(req->sk); |
287 | 287 | ||
288 | if (seq != dccp_rsk(req)->dreq_iss) { | 288 | if (seq != dccp_rsk(req)->dreq_iss) { |
289 | NET_INC_STATS_BH(net, LINUX_MIB_OUTOFWINDOWICMPS); | 289 | NET_INC_STATS_BH(net, LINUX_MIB_OUTOFWINDOWICMPS); |
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index b74e8b2cbe55..da509127e00c 100644 --- a/net/dccp/ipv6.c +++ b/net/dccp/ipv6.c | |||
@@ -186,7 +186,7 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | |||
186 | * ICMPs are not backlogged, hence we cannot get an established | 186 | * ICMPs are not backlogged, hence we cannot get an established |
187 | * socket here. | 187 | * socket here. |
188 | */ | 188 | */ |
189 | BUG_TRAP(req->sk == NULL); | 189 | WARN_ON(req->sk != NULL); |
190 | 190 | ||
191 | if (seq != dccp_rsk(req)->dreq_iss) { | 191 | if (seq != dccp_rsk(req)->dreq_iss) { |
192 | NET_INC_STATS_BH(net, LINUX_MIB_OUTOFWINDOWICMPS); | 192 | NET_INC_STATS_BH(net, LINUX_MIB_OUTOFWINDOWICMPS); |
diff --git a/net/dccp/proto.c b/net/dccp/proto.c index a0b56009611f..b622d9744856 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c | |||
@@ -327,7 +327,7 @@ int dccp_disconnect(struct sock *sk, int flags) | |||
327 | inet_csk_delack_init(sk); | 327 | inet_csk_delack_init(sk); |
328 | __sk_dst_reset(sk); | 328 | __sk_dst_reset(sk); |
329 | 329 | ||
330 | BUG_TRAP(!inet->num || icsk->icsk_bind_hash); | 330 | WARN_ON(inet->num && !icsk->icsk_bind_hash); |
331 | 331 | ||
332 | sk->sk_error_report(sk); | 332 | sk->sk_error_report(sk); |
333 | return err; | 333 | return err; |
@@ -981,7 +981,7 @@ adjudge_to_death: | |||
981 | */ | 981 | */ |
982 | local_bh_disable(); | 982 | local_bh_disable(); |
983 | bh_lock_sock(sk); | 983 | bh_lock_sock(sk); |
984 | BUG_TRAP(!sock_owned_by_user(sk)); | 984 | WARN_ON(sock_owned_by_user(sk)); |
985 | 985 | ||
986 | /* Have we already been destroyed by a softirq or backlog? */ | 986 | /* Have we already been destroyed by a softirq or backlog? */ |
987 | if (state != DCCP_CLOSED && sk->sk_state == DCCP_CLOSED) | 987 | if (state != DCCP_CLOSED && sk->sk_state == DCCP_CLOSED) |
diff --git a/net/dccp/timer.c b/net/dccp/timer.c index 3608d5342ca2..6a5b961b6f5c 100644 --- a/net/dccp/timer.c +++ b/net/dccp/timer.c | |||
@@ -106,7 +106,7 @@ static void dccp_retransmit_timer(struct sock *sk) | |||
106 | * -- Acks in client-PARTOPEN state (sec. 8.1.5) | 106 | * -- Acks in client-PARTOPEN state (sec. 8.1.5) |
107 | * -- CloseReq in server-CLOSEREQ state (sec. 8.3) | 107 | * -- CloseReq in server-CLOSEREQ state (sec. 8.3) |
108 | * -- Close in node-CLOSING state (sec. 8.3) */ | 108 | * -- Close in node-CLOSING state (sec. 8.3) */ |
109 | BUG_TRAP(sk->sk_send_head != NULL); | 109 | WARN_ON(sk->sk_send_head == NULL); |
110 | 110 | ||
111 | /* | 111 | /* |
112 | * More than than 4MSL (8 minutes) has passed, a RESET(aborted) was | 112 | * More than than 4MSL (8 minutes) has passed, a RESET(aborted) was |
diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig index 4670683b4688..591ea23639ca 100644 --- a/net/ipv4/Kconfig +++ b/net/ipv4/Kconfig | |||
@@ -356,10 +356,8 @@ config INET_ESP | |||
356 | 356 | ||
357 | config INET_IPCOMP | 357 | config INET_IPCOMP |
358 | tristate "IP: IPComp transformation" | 358 | tristate "IP: IPComp transformation" |
359 | select XFRM | ||
360 | select INET_XFRM_TUNNEL | 359 | select INET_XFRM_TUNNEL |
361 | select CRYPTO | 360 | select XFRM_IPCOMP |
362 | select CRYPTO_DEFLATE | ||
363 | ---help--- | 361 | ---help--- |
364 | Support for IP Payload Compression Protocol (IPComp) (RFC3173), | 362 | Support for IP Payload Compression Protocol (IPComp) (RFC3173), |
365 | typically needed for IPsec. | 363 | typically needed for IPsec. |
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index dd919d84285f..8a3ac1fa71a9 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
@@ -148,10 +148,10 @@ void inet_sock_destruct(struct sock *sk) | |||
148 | return; | 148 | return; |
149 | } | 149 | } |
150 | 150 | ||
151 | BUG_TRAP(!atomic_read(&sk->sk_rmem_alloc)); | 151 | WARN_ON(atomic_read(&sk->sk_rmem_alloc)); |
152 | BUG_TRAP(!atomic_read(&sk->sk_wmem_alloc)); | 152 | WARN_ON(atomic_read(&sk->sk_wmem_alloc)); |
153 | BUG_TRAP(!sk->sk_wmem_queued); | 153 | WARN_ON(sk->sk_wmem_queued); |
154 | BUG_TRAP(!sk->sk_forward_alloc); | 154 | WARN_ON(sk->sk_forward_alloc); |
155 | 155 | ||
156 | kfree(inet->opt); | 156 | kfree(inet->opt); |
157 | dst_release(sk->sk_dst_cache); | 157 | dst_release(sk->sk_dst_cache); |
@@ -264,7 +264,6 @@ static inline int inet_netns_ok(struct net *net, int protocol) | |||
264 | static int inet_create(struct net *net, struct socket *sock, int protocol) | 264 | static int inet_create(struct net *net, struct socket *sock, int protocol) |
265 | { | 265 | { |
266 | struct sock *sk; | 266 | struct sock *sk; |
267 | struct list_head *p; | ||
268 | struct inet_protosw *answer; | 267 | struct inet_protosw *answer; |
269 | struct inet_sock *inet; | 268 | struct inet_sock *inet; |
270 | struct proto *answer_prot; | 269 | struct proto *answer_prot; |
@@ -281,13 +280,12 @@ static int inet_create(struct net *net, struct socket *sock, int protocol) | |||
281 | sock->state = SS_UNCONNECTED; | 280 | sock->state = SS_UNCONNECTED; |
282 | 281 | ||
283 | /* Look for the requested type/protocol pair. */ | 282 | /* Look for the requested type/protocol pair. */ |
284 | answer = NULL; | ||
285 | lookup_protocol: | 283 | lookup_protocol: |
286 | err = -ESOCKTNOSUPPORT; | 284 | err = -ESOCKTNOSUPPORT; |
287 | rcu_read_lock(); | 285 | rcu_read_lock(); |
288 | list_for_each_rcu(p, &inetsw[sock->type]) { | 286 | list_for_each_entry_rcu(answer, &inetsw[sock->type], list) { |
289 | answer = list_entry(p, struct inet_protosw, list); | ||
290 | 287 | ||
288 | err = 0; | ||
291 | /* Check the non-wild match. */ | 289 | /* Check the non-wild match. */ |
292 | if (protocol == answer->protocol) { | 290 | if (protocol == answer->protocol) { |
293 | if (protocol != IPPROTO_IP) | 291 | if (protocol != IPPROTO_IP) |
@@ -302,10 +300,9 @@ lookup_protocol: | |||
302 | break; | 300 | break; |
303 | } | 301 | } |
304 | err = -EPROTONOSUPPORT; | 302 | err = -EPROTONOSUPPORT; |
305 | answer = NULL; | ||
306 | } | 303 | } |
307 | 304 | ||
308 | if (unlikely(answer == NULL)) { | 305 | if (unlikely(err)) { |
309 | if (try_loading_module < 2) { | 306 | if (try_loading_module < 2) { |
310 | rcu_read_unlock(); | 307 | rcu_read_unlock(); |
311 | /* | 308 | /* |
@@ -341,7 +338,7 @@ lookup_protocol: | |||
341 | answer_flags = answer->flags; | 338 | answer_flags = answer->flags; |
342 | rcu_read_unlock(); | 339 | rcu_read_unlock(); |
343 | 340 | ||
344 | BUG_TRAP(answer_prot->slab != NULL); | 341 | WARN_ON(answer_prot->slab == NULL); |
345 | 342 | ||
346 | err = -ENOBUFS; | 343 | err = -ENOBUFS; |
347 | sk = sk_alloc(net, PF_INET, GFP_KERNEL, answer_prot); | 344 | sk = sk_alloc(net, PF_INET, GFP_KERNEL, answer_prot); |
@@ -661,8 +658,8 @@ int inet_accept(struct socket *sock, struct socket *newsock, int flags) | |||
661 | 658 | ||
662 | lock_sock(sk2); | 659 | lock_sock(sk2); |
663 | 660 | ||
664 | BUG_TRAP((1 << sk2->sk_state) & | 661 | WARN_ON(!((1 << sk2->sk_state) & |
665 | (TCPF_ESTABLISHED | TCPF_CLOSE_WAIT | TCPF_CLOSE)); | 662 | (TCPF_ESTABLISHED | TCPF_CLOSE_WAIT | TCPF_CLOSE))); |
666 | 663 | ||
667 | sock_graft(sk2, newsock); | 664 | sock_graft(sk2, newsock); |
668 | 665 | ||
@@ -1442,6 +1439,10 @@ static int __init inet_init(void) | |||
1442 | 1439 | ||
1443 | (void)sock_register(&inet_family_ops); | 1440 | (void)sock_register(&inet_family_ops); |
1444 | 1441 | ||
1442 | #ifdef CONFIG_SYSCTL | ||
1443 | ip_static_sysctl_init(); | ||
1444 | #endif | ||
1445 | |||
1445 | /* | 1446 | /* |
1446 | * Add all the base protocols. | 1447 | * Add all the base protocols. |
1447 | */ | 1448 | */ |
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index 2e667e2f90df..91d3d96805d0 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c | |||
@@ -138,8 +138,8 @@ void in_dev_finish_destroy(struct in_device *idev) | |||
138 | { | 138 | { |
139 | struct net_device *dev = idev->dev; | 139 | struct net_device *dev = idev->dev; |
140 | 140 | ||
141 | BUG_TRAP(!idev->ifa_list); | 141 | WARN_ON(idev->ifa_list); |
142 | BUG_TRAP(!idev->mc_list); | 142 | WARN_ON(idev->mc_list); |
143 | #ifdef NET_REFCNT_DEBUG | 143 | #ifdef NET_REFCNT_DEBUG |
144 | printk(KERN_DEBUG "in_dev_finish_destroy: %p=%s\n", | 144 | printk(KERN_DEBUG "in_dev_finish_destroy: %p=%s\n", |
145 | idev, dev ? dev->name : "NIL"); | 145 | idev, dev ? dev->name : "NIL"); |
@@ -399,7 +399,7 @@ static int inet_set_ifa(struct net_device *dev, struct in_ifaddr *ifa) | |||
399 | } | 399 | } |
400 | ipv4_devconf_setall(in_dev); | 400 | ipv4_devconf_setall(in_dev); |
401 | if (ifa->ifa_dev != in_dev) { | 401 | if (ifa->ifa_dev != in_dev) { |
402 | BUG_TRAP(!ifa->ifa_dev); | 402 | WARN_ON(ifa->ifa_dev); |
403 | in_dev_hold(in_dev); | 403 | in_dev_hold(in_dev); |
404 | ifa->ifa_dev = in_dev; | 404 | ifa->ifa_dev = in_dev; |
405 | } | 405 | } |
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index bb81c958b744..0c1ae68ee84b 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c | |||
@@ -167,7 +167,7 @@ tb_not_found: | |||
167 | success: | 167 | success: |
168 | if (!inet_csk(sk)->icsk_bind_hash) | 168 | if (!inet_csk(sk)->icsk_bind_hash) |
169 | inet_bind_hash(sk, tb, snum); | 169 | inet_bind_hash(sk, tb, snum); |
170 | BUG_TRAP(inet_csk(sk)->icsk_bind_hash == tb); | 170 | WARN_ON(inet_csk(sk)->icsk_bind_hash != tb); |
171 | ret = 0; | 171 | ret = 0; |
172 | 172 | ||
173 | fail_unlock: | 173 | fail_unlock: |
@@ -260,7 +260,7 @@ struct sock *inet_csk_accept(struct sock *sk, int flags, int *err) | |||
260 | } | 260 | } |
261 | 261 | ||
262 | newsk = reqsk_queue_get_child(&icsk->icsk_accept_queue, sk); | 262 | newsk = reqsk_queue_get_child(&icsk->icsk_accept_queue, sk); |
263 | BUG_TRAP(newsk->sk_state != TCP_SYN_RECV); | 263 | WARN_ON(newsk->sk_state == TCP_SYN_RECV); |
264 | out: | 264 | out: |
265 | release_sock(sk); | 265 | release_sock(sk); |
266 | return newsk; | 266 | return newsk; |
@@ -386,7 +386,7 @@ struct request_sock *inet_csk_search_req(const struct sock *sk, | |||
386 | ireq->rmt_addr == raddr && | 386 | ireq->rmt_addr == raddr && |
387 | ireq->loc_addr == laddr && | 387 | ireq->loc_addr == laddr && |
388 | AF_INET_FAMILY(req->rsk_ops->family)) { | 388 | AF_INET_FAMILY(req->rsk_ops->family)) { |
389 | BUG_TRAP(!req->sk); | 389 | WARN_ON(req->sk); |
390 | *prevp = prev; | 390 | *prevp = prev; |
391 | break; | 391 | break; |
392 | } | 392 | } |
@@ -539,14 +539,14 @@ EXPORT_SYMBOL_GPL(inet_csk_clone); | |||
539 | */ | 539 | */ |
540 | void inet_csk_destroy_sock(struct sock *sk) | 540 | void inet_csk_destroy_sock(struct sock *sk) |
541 | { | 541 | { |
542 | BUG_TRAP(sk->sk_state == TCP_CLOSE); | 542 | WARN_ON(sk->sk_state != TCP_CLOSE); |
543 | BUG_TRAP(sock_flag(sk, SOCK_DEAD)); | 543 | WARN_ON(!sock_flag(sk, SOCK_DEAD)); |
544 | 544 | ||
545 | /* It cannot be in hash table! */ | 545 | /* It cannot be in hash table! */ |
546 | BUG_TRAP(sk_unhashed(sk)); | 546 | WARN_ON(!sk_unhashed(sk)); |
547 | 547 | ||
548 | /* If it has not 0 inet_sk(sk)->num, it must be bound */ | 548 | /* If it has not 0 inet_sk(sk)->num, it must be bound */ |
549 | BUG_TRAP(!inet_sk(sk)->num || inet_csk(sk)->icsk_bind_hash); | 549 | WARN_ON(inet_sk(sk)->num && !inet_csk(sk)->icsk_bind_hash); |
550 | 550 | ||
551 | sk->sk_prot->destroy(sk); | 551 | sk->sk_prot->destroy(sk); |
552 | 552 | ||
@@ -629,7 +629,7 @@ void inet_csk_listen_stop(struct sock *sk) | |||
629 | 629 | ||
630 | local_bh_disable(); | 630 | local_bh_disable(); |
631 | bh_lock_sock(child); | 631 | bh_lock_sock(child); |
632 | BUG_TRAP(!sock_owned_by_user(child)); | 632 | WARN_ON(sock_owned_by_user(child)); |
633 | sock_hold(child); | 633 | sock_hold(child); |
634 | 634 | ||
635 | sk->sk_prot->disconnect(child, O_NONBLOCK); | 635 | sk->sk_prot->disconnect(child, O_NONBLOCK); |
@@ -647,7 +647,7 @@ void inet_csk_listen_stop(struct sock *sk) | |||
647 | sk_acceptq_removed(sk); | 647 | sk_acceptq_removed(sk); |
648 | __reqsk_free(req); | 648 | __reqsk_free(req); |
649 | } | 649 | } |
650 | BUG_TRAP(!sk->sk_ack_backlog); | 650 | WARN_ON(sk->sk_ack_backlog); |
651 | } | 651 | } |
652 | 652 | ||
653 | EXPORT_SYMBOL_GPL(inet_csk_listen_stop); | 653 | EXPORT_SYMBOL_GPL(inet_csk_listen_stop); |
diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c index 0546a0bc97ea..6c52e08f786e 100644 --- a/net/ipv4/inet_fragment.c +++ b/net/ipv4/inet_fragment.c | |||
@@ -134,8 +134,8 @@ void inet_frag_destroy(struct inet_frag_queue *q, struct inet_frags *f, | |||
134 | struct sk_buff *fp; | 134 | struct sk_buff *fp; |
135 | struct netns_frags *nf; | 135 | struct netns_frags *nf; |
136 | 136 | ||
137 | BUG_TRAP(q->last_in & INET_FRAG_COMPLETE); | 137 | WARN_ON(!(q->last_in & INET_FRAG_COMPLETE)); |
138 | BUG_TRAP(del_timer(&q->timer) == 0); | 138 | WARN_ON(del_timer(&q->timer) != 0); |
139 | 139 | ||
140 | /* Release all fragment data. */ | 140 | /* Release all fragment data. */ |
141 | fp = q->fragments; | 141 | fp = q->fragments; |
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c index 115f53722d20..44981906fb91 100644 --- a/net/ipv4/inet_hashtables.c +++ b/net/ipv4/inet_hashtables.c | |||
@@ -305,7 +305,7 @@ unique: | |||
305 | inet->num = lport; | 305 | inet->num = lport; |
306 | inet->sport = htons(lport); | 306 | inet->sport = htons(lport); |
307 | sk->sk_hash = hash; | 307 | sk->sk_hash = hash; |
308 | BUG_TRAP(sk_unhashed(sk)); | 308 | WARN_ON(!sk_unhashed(sk)); |
309 | __sk_add_node(sk, &head->chain); | 309 | __sk_add_node(sk, &head->chain); |
310 | sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); | 310 | sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); |
311 | write_unlock(lock); | 311 | write_unlock(lock); |
@@ -342,7 +342,7 @@ void __inet_hash_nolisten(struct sock *sk) | |||
342 | rwlock_t *lock; | 342 | rwlock_t *lock; |
343 | struct inet_ehash_bucket *head; | 343 | struct inet_ehash_bucket *head; |
344 | 344 | ||
345 | BUG_TRAP(sk_unhashed(sk)); | 345 | WARN_ON(!sk_unhashed(sk)); |
346 | 346 | ||
347 | sk->sk_hash = inet_sk_ehashfn(sk); | 347 | sk->sk_hash = inet_sk_ehashfn(sk); |
348 | head = inet_ehash_bucket(hashinfo, sk->sk_hash); | 348 | head = inet_ehash_bucket(hashinfo, sk->sk_hash); |
@@ -367,7 +367,7 @@ static void __inet_hash(struct sock *sk) | |||
367 | return; | 367 | return; |
368 | } | 368 | } |
369 | 369 | ||
370 | BUG_TRAP(sk_unhashed(sk)); | 370 | WARN_ON(!sk_unhashed(sk)); |
371 | list = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)]; | 371 | list = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)]; |
372 | lock = &hashinfo->lhash_lock; | 372 | lock = &hashinfo->lhash_lock; |
373 | 373 | ||
@@ -450,7 +450,7 @@ int __inet_hash_connect(struct inet_timewait_death_row *death_row, | |||
450 | */ | 450 | */ |
451 | inet_bind_bucket_for_each(tb, node, &head->chain) { | 451 | inet_bind_bucket_for_each(tb, node, &head->chain) { |
452 | if (tb->ib_net == net && tb->port == port) { | 452 | if (tb->ib_net == net && tb->port == port) { |
453 | BUG_TRAP(!hlist_empty(&tb->owners)); | 453 | WARN_ON(hlist_empty(&tb->owners)); |
454 | if (tb->fastreuse >= 0) | 454 | if (tb->fastreuse >= 0) |
455 | goto next_port; | 455 | goto next_port; |
456 | if (!check_established(death_row, sk, | 456 | if (!check_established(death_row, sk, |
diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c index 75c2def8f9a0..d985bd613d25 100644 --- a/net/ipv4/inet_timewait_sock.c +++ b/net/ipv4/inet_timewait_sock.c | |||
@@ -86,7 +86,7 @@ void __inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk, | |||
86 | hashinfo->bhash_size)]; | 86 | hashinfo->bhash_size)]; |
87 | spin_lock(&bhead->lock); | 87 | spin_lock(&bhead->lock); |
88 | tw->tw_tb = icsk->icsk_bind_hash; | 88 | tw->tw_tb = icsk->icsk_bind_hash; |
89 | BUG_TRAP(icsk->icsk_bind_hash); | 89 | WARN_ON(!icsk->icsk_bind_hash); |
90 | inet_twsk_add_bind_node(tw, &tw->tw_tb->owners); | 90 | inet_twsk_add_bind_node(tw, &tw->tw_tb->owners); |
91 | spin_unlock(&bhead->lock); | 91 | spin_unlock(&bhead->lock); |
92 | 92 | ||
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c index 38d38f058018..2152d222b954 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c | |||
@@ -488,8 +488,8 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *prev, | |||
488 | qp->q.fragments = head; | 488 | qp->q.fragments = head; |
489 | } | 489 | } |
490 | 490 | ||
491 | BUG_TRAP(head != NULL); | 491 | WARN_ON(head == NULL); |
492 | BUG_TRAP(FRAG_CB(head)->offset == 0); | 492 | WARN_ON(FRAG_CB(head)->offset != 0); |
493 | 493 | ||
494 | /* Allocate a new buffer for the datagram. */ | 494 | /* Allocate a new buffer for the datagram. */ |
495 | ihlen = ip_hdrlen(head); | 495 | ihlen = ip_hdrlen(head); |
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 465544f6281a..d533a89e08de 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c | |||
@@ -118,7 +118,7 @@ static int ip_dev_loopback_xmit(struct sk_buff *newskb) | |||
118 | __skb_pull(newskb, skb_network_offset(newskb)); | 118 | __skb_pull(newskb, skb_network_offset(newskb)); |
119 | newskb->pkt_type = PACKET_LOOPBACK; | 119 | newskb->pkt_type = PACKET_LOOPBACK; |
120 | newskb->ip_summed = CHECKSUM_UNNECESSARY; | 120 | newskb->ip_summed = CHECKSUM_UNNECESSARY; |
121 | BUG_TRAP(newskb->dst); | 121 | WARN_ON(!newskb->dst); |
122 | netif_rx(newskb); | 122 | netif_rx(newskb); |
123 | return 0; | 123 | return 0; |
124 | } | 124 | } |
diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c index a75807b971b3..a42b64d040c4 100644 --- a/net/ipv4/ipcomp.c +++ b/net/ipv4/ipcomp.c | |||
@@ -14,153 +14,14 @@ | |||
14 | * - Adaptive compression. | 14 | * - Adaptive compression. |
15 | */ | 15 | */ |
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <linux/crypto.h> | ||
18 | #include <linux/err.h> | 17 | #include <linux/err.h> |
19 | #include <linux/pfkeyv2.h> | ||
20 | #include <linux/percpu.h> | ||
21 | #include <linux/smp.h> | ||
22 | #include <linux/list.h> | ||
23 | #include <linux/vmalloc.h> | ||
24 | #include <linux/rtnetlink.h> | 18 | #include <linux/rtnetlink.h> |
25 | #include <linux/mutex.h> | ||
26 | #include <net/ip.h> | 19 | #include <net/ip.h> |
27 | #include <net/xfrm.h> | 20 | #include <net/xfrm.h> |
28 | #include <net/icmp.h> | 21 | #include <net/icmp.h> |
29 | #include <net/ipcomp.h> | 22 | #include <net/ipcomp.h> |
30 | #include <net/protocol.h> | 23 | #include <net/protocol.h> |
31 | 24 | #include <net/sock.h> | |
32 | struct ipcomp_tfms { | ||
33 | struct list_head list; | ||
34 | struct crypto_comp **tfms; | ||
35 | int users; | ||
36 | }; | ||
37 | |||
38 | static DEFINE_MUTEX(ipcomp_resource_mutex); | ||
39 | static void **ipcomp_scratches; | ||
40 | static int ipcomp_scratch_users; | ||
41 | static LIST_HEAD(ipcomp_tfms_list); | ||
42 | |||
43 | static int ipcomp_decompress(struct xfrm_state *x, struct sk_buff *skb) | ||
44 | { | ||
45 | struct ipcomp_data *ipcd = x->data; | ||
46 | const int plen = skb->len; | ||
47 | int dlen = IPCOMP_SCRATCH_SIZE; | ||
48 | const u8 *start = skb->data; | ||
49 | const int cpu = get_cpu(); | ||
50 | u8 *scratch = *per_cpu_ptr(ipcomp_scratches, cpu); | ||
51 | struct crypto_comp *tfm = *per_cpu_ptr(ipcd->tfms, cpu); | ||
52 | int err = crypto_comp_decompress(tfm, start, plen, scratch, &dlen); | ||
53 | |||
54 | if (err) | ||
55 | goto out; | ||
56 | |||
57 | if (dlen < (plen + sizeof(struct ip_comp_hdr))) { | ||
58 | err = -EINVAL; | ||
59 | goto out; | ||
60 | } | ||
61 | |||
62 | err = pskb_expand_head(skb, 0, dlen - plen, GFP_ATOMIC); | ||
63 | if (err) | ||
64 | goto out; | ||
65 | |||
66 | skb->truesize += dlen - plen; | ||
67 | __skb_put(skb, dlen - plen); | ||
68 | skb_copy_to_linear_data(skb, scratch, dlen); | ||
69 | out: | ||
70 | put_cpu(); | ||
71 | return err; | ||
72 | } | ||
73 | |||
74 | static int ipcomp_input(struct xfrm_state *x, struct sk_buff *skb) | ||
75 | { | ||
76 | int nexthdr; | ||
77 | int err = -ENOMEM; | ||
78 | struct ip_comp_hdr *ipch; | ||
79 | |||
80 | if (skb_linearize_cow(skb)) | ||
81 | goto out; | ||
82 | |||
83 | skb->ip_summed = CHECKSUM_NONE; | ||
84 | |||
85 | /* Remove ipcomp header and decompress original payload */ | ||
86 | ipch = (void *)skb->data; | ||
87 | nexthdr = ipch->nexthdr; | ||
88 | |||
89 | skb->transport_header = skb->network_header + sizeof(*ipch); | ||
90 | __skb_pull(skb, sizeof(*ipch)); | ||
91 | err = ipcomp_decompress(x, skb); | ||
92 | if (err) | ||
93 | goto out; | ||
94 | |||
95 | err = nexthdr; | ||
96 | |||
97 | out: | ||
98 | return err; | ||
99 | } | ||
100 | |||
101 | static int ipcomp_compress(struct xfrm_state *x, struct sk_buff *skb) | ||
102 | { | ||
103 | struct ipcomp_data *ipcd = x->data; | ||
104 | const int plen = skb->len; | ||
105 | int dlen = IPCOMP_SCRATCH_SIZE; | ||
106 | u8 *start = skb->data; | ||
107 | const int cpu = get_cpu(); | ||
108 | u8 *scratch = *per_cpu_ptr(ipcomp_scratches, cpu); | ||
109 | struct crypto_comp *tfm = *per_cpu_ptr(ipcd->tfms, cpu); | ||
110 | int err; | ||
111 | |||
112 | local_bh_disable(); | ||
113 | err = crypto_comp_compress(tfm, start, plen, scratch, &dlen); | ||
114 | local_bh_enable(); | ||
115 | if (err) | ||
116 | goto out; | ||
117 | |||
118 | if ((dlen + sizeof(struct ip_comp_hdr)) >= plen) { | ||
119 | err = -EMSGSIZE; | ||
120 | goto out; | ||
121 | } | ||
122 | |||
123 | memcpy(start + sizeof(struct ip_comp_hdr), scratch, dlen); | ||
124 | put_cpu(); | ||
125 | |||
126 | pskb_trim(skb, dlen + sizeof(struct ip_comp_hdr)); | ||
127 | return 0; | ||
128 | |||
129 | out: | ||
130 | put_cpu(); | ||
131 | return err; | ||
132 | } | ||
133 | |||
134 | static int ipcomp_output(struct xfrm_state *x, struct sk_buff *skb) | ||
135 | { | ||
136 | int err; | ||
137 | struct ip_comp_hdr *ipch; | ||
138 | struct ipcomp_data *ipcd = x->data; | ||
139 | |||
140 | if (skb->len < ipcd->threshold) { | ||
141 | /* Don't bother compressing */ | ||
142 | goto out_ok; | ||
143 | } | ||
144 | |||
145 | if (skb_linearize_cow(skb)) | ||
146 | goto out_ok; | ||
147 | |||
148 | err = ipcomp_compress(x, skb); | ||
149 | |||
150 | if (err) { | ||
151 | goto out_ok; | ||
152 | } | ||
153 | |||
154 | /* Install ipcomp header, convert into ipcomp datagram. */ | ||
155 | ipch = ip_comp_hdr(skb); | ||
156 | ipch->nexthdr = *skb_mac_header(skb); | ||
157 | ipch->flags = 0; | ||
158 | ipch->cpi = htons((u16 )ntohl(x->id.spi)); | ||
159 | *skb_mac_header(skb) = IPPROTO_COMP; | ||
160 | out_ok: | ||
161 | skb_push(skb, -skb_network_offset(skb)); | ||
162 | return 0; | ||
163 | } | ||
164 | 25 | ||
165 | static void ipcomp4_err(struct sk_buff *skb, u32 info) | 26 | static void ipcomp4_err(struct sk_buff *skb, u32 info) |
166 | { | 27 | { |
@@ -241,156 +102,12 @@ out: | |||
241 | return err; | 102 | return err; |
242 | } | 103 | } |
243 | 104 | ||
244 | static void ipcomp_free_scratches(void) | 105 | static int ipcomp4_init_state(struct xfrm_state *x) |
245 | { | ||
246 | int i; | ||
247 | void **scratches; | ||
248 | |||
249 | if (--ipcomp_scratch_users) | ||
250 | return; | ||
251 | |||
252 | scratches = ipcomp_scratches; | ||
253 | if (!scratches) | ||
254 | return; | ||
255 | |||
256 | for_each_possible_cpu(i) | ||
257 | vfree(*per_cpu_ptr(scratches, i)); | ||
258 | |||
259 | free_percpu(scratches); | ||
260 | } | ||
261 | |||
262 | static void **ipcomp_alloc_scratches(void) | ||
263 | { | ||
264 | int i; | ||
265 | void **scratches; | ||
266 | |||
267 | if (ipcomp_scratch_users++) | ||
268 | return ipcomp_scratches; | ||
269 | |||
270 | scratches = alloc_percpu(void *); | ||
271 | if (!scratches) | ||
272 | return NULL; | ||
273 | |||
274 | ipcomp_scratches = scratches; | ||
275 | |||
276 | for_each_possible_cpu(i) { | ||
277 | void *scratch = vmalloc(IPCOMP_SCRATCH_SIZE); | ||
278 | if (!scratch) | ||
279 | return NULL; | ||
280 | *per_cpu_ptr(scratches, i) = scratch; | ||
281 | } | ||
282 | |||
283 | return scratches; | ||
284 | } | ||
285 | |||
286 | static void ipcomp_free_tfms(struct crypto_comp **tfms) | ||
287 | { | ||
288 | struct ipcomp_tfms *pos; | ||
289 | int cpu; | ||
290 | |||
291 | list_for_each_entry(pos, &ipcomp_tfms_list, list) { | ||
292 | if (pos->tfms == tfms) | ||
293 | break; | ||
294 | } | ||
295 | |||
296 | BUG_TRAP(pos); | ||
297 | |||
298 | if (--pos->users) | ||
299 | return; | ||
300 | |||
301 | list_del(&pos->list); | ||
302 | kfree(pos); | ||
303 | |||
304 | if (!tfms) | ||
305 | return; | ||
306 | |||
307 | for_each_possible_cpu(cpu) { | ||
308 | struct crypto_comp *tfm = *per_cpu_ptr(tfms, cpu); | ||
309 | crypto_free_comp(tfm); | ||
310 | } | ||
311 | free_percpu(tfms); | ||
312 | } | ||
313 | |||
314 | static struct crypto_comp **ipcomp_alloc_tfms(const char *alg_name) | ||
315 | { | ||
316 | struct ipcomp_tfms *pos; | ||
317 | struct crypto_comp **tfms; | ||
318 | int cpu; | ||
319 | |||
320 | /* This can be any valid CPU ID so we don't need locking. */ | ||
321 | cpu = raw_smp_processor_id(); | ||
322 | |||
323 | list_for_each_entry(pos, &ipcomp_tfms_list, list) { | ||
324 | struct crypto_comp *tfm; | ||
325 | |||
326 | tfms = pos->tfms; | ||
327 | tfm = *per_cpu_ptr(tfms, cpu); | ||
328 | |||
329 | if (!strcmp(crypto_comp_name(tfm), alg_name)) { | ||
330 | pos->users++; | ||
331 | return tfms; | ||
332 | } | ||
333 | } | ||
334 | |||
335 | pos = kmalloc(sizeof(*pos), GFP_KERNEL); | ||
336 | if (!pos) | ||
337 | return NULL; | ||
338 | |||
339 | pos->users = 1; | ||
340 | INIT_LIST_HEAD(&pos->list); | ||
341 | list_add(&pos->list, &ipcomp_tfms_list); | ||
342 | |||
343 | pos->tfms = tfms = alloc_percpu(struct crypto_comp *); | ||
344 | if (!tfms) | ||
345 | goto error; | ||
346 | |||
347 | for_each_possible_cpu(cpu) { | ||
348 | struct crypto_comp *tfm = crypto_alloc_comp(alg_name, 0, | ||
349 | CRYPTO_ALG_ASYNC); | ||
350 | if (IS_ERR(tfm)) | ||
351 | goto error; | ||
352 | *per_cpu_ptr(tfms, cpu) = tfm; | ||
353 | } | ||
354 | |||
355 | return tfms; | ||
356 | |||
357 | error: | ||
358 | ipcomp_free_tfms(tfms); | ||
359 | return NULL; | ||
360 | } | ||
361 | |||
362 | static void ipcomp_free_data(struct ipcomp_data *ipcd) | ||
363 | { | ||
364 | if (ipcd->tfms) | ||
365 | ipcomp_free_tfms(ipcd->tfms); | ||
366 | ipcomp_free_scratches(); | ||
367 | } | ||
368 | |||
369 | static void ipcomp_destroy(struct xfrm_state *x) | ||
370 | { | ||
371 | struct ipcomp_data *ipcd = x->data; | ||
372 | if (!ipcd) | ||
373 | return; | ||
374 | xfrm_state_delete_tunnel(x); | ||
375 | mutex_lock(&ipcomp_resource_mutex); | ||
376 | ipcomp_free_data(ipcd); | ||
377 | mutex_unlock(&ipcomp_resource_mutex); | ||
378 | kfree(ipcd); | ||
379 | } | ||
380 | |||
381 | static int ipcomp_init_state(struct xfrm_state *x) | ||
382 | { | 106 | { |
383 | int err; | 107 | int err; |
384 | struct ipcomp_data *ipcd; | 108 | struct ipcomp_data *ipcd; |
385 | struct xfrm_algo_desc *calg_desc; | 109 | struct xfrm_algo_desc *calg_desc; |
386 | 110 | ||
387 | err = -EINVAL; | ||
388 | if (!x->calg) | ||
389 | goto out; | ||
390 | |||
391 | if (x->encap) | ||
392 | goto out; | ||
393 | |||
394 | x->props.header_len = 0; | 111 | x->props.header_len = 0; |
395 | switch (x->props.mode) { | 112 | switch (x->props.mode) { |
396 | case XFRM_MODE_TRANSPORT: | 113 | case XFRM_MODE_TRANSPORT: |
@@ -402,40 +119,22 @@ static int ipcomp_init_state(struct xfrm_state *x) | |||
402 | goto out; | 119 | goto out; |
403 | } | 120 | } |
404 | 121 | ||
405 | err = -ENOMEM; | 122 | err = ipcomp_init_state(x); |
406 | ipcd = kzalloc(sizeof(*ipcd), GFP_KERNEL); | 123 | if (err) |
407 | if (!ipcd) | ||
408 | goto out; | 124 | goto out; |
409 | 125 | ||
410 | mutex_lock(&ipcomp_resource_mutex); | ||
411 | if (!ipcomp_alloc_scratches()) | ||
412 | goto error; | ||
413 | |||
414 | ipcd->tfms = ipcomp_alloc_tfms(x->calg->alg_name); | ||
415 | if (!ipcd->tfms) | ||
416 | goto error; | ||
417 | mutex_unlock(&ipcomp_resource_mutex); | ||
418 | |||
419 | if (x->props.mode == XFRM_MODE_TUNNEL) { | 126 | if (x->props.mode == XFRM_MODE_TUNNEL) { |
420 | err = ipcomp_tunnel_attach(x); | 127 | err = ipcomp_tunnel_attach(x); |
421 | if (err) | 128 | if (err) |
422 | goto error_tunnel; | 129 | goto error_tunnel; |
423 | } | 130 | } |
424 | 131 | ||
425 | calg_desc = xfrm_calg_get_byname(x->calg->alg_name, 0); | ||
426 | BUG_ON(!calg_desc); | ||
427 | ipcd->threshold = calg_desc->uinfo.comp.threshold; | ||
428 | x->data = ipcd; | ||
429 | err = 0; | 132 | err = 0; |
430 | out: | 133 | out: |
431 | return err; | 134 | return err; |
432 | 135 | ||
433 | error_tunnel: | 136 | error_tunnel: |
434 | mutex_lock(&ipcomp_resource_mutex); | 137 | ipcomp_destroy(x); |
435 | error: | ||
436 | ipcomp_free_data(ipcd); | ||
437 | mutex_unlock(&ipcomp_resource_mutex); | ||
438 | kfree(ipcd); | ||
439 | goto out; | 138 | goto out; |
440 | } | 139 | } |
441 | 140 | ||
@@ -443,7 +142,7 @@ static const struct xfrm_type ipcomp_type = { | |||
443 | .description = "IPCOMP4", | 142 | .description = "IPCOMP4", |
444 | .owner = THIS_MODULE, | 143 | .owner = THIS_MODULE, |
445 | .proto = IPPROTO_COMP, | 144 | .proto = IPPROTO_COMP, |
446 | .init_state = ipcomp_init_state, | 145 | .init_state = ipcomp4_init_state, |
447 | .destructor = ipcomp_destroy, | 146 | .destructor = ipcomp_destroy, |
448 | .input = ipcomp_input, | 147 | .input = ipcomp_input, |
449 | .output = ipcomp_output | 148 | .output = ipcomp_output |
@@ -481,7 +180,7 @@ module_init(ipcomp4_init); | |||
481 | module_exit(ipcomp4_fini); | 180 | module_exit(ipcomp4_fini); |
482 | 181 | ||
483 | MODULE_LICENSE("GPL"); | 182 | MODULE_LICENSE("GPL"); |
484 | MODULE_DESCRIPTION("IP Payload Compression Protocol (IPComp) - RFC3173"); | 183 | MODULE_DESCRIPTION("IP Payload Compression Protocol (IPComp/IPv4) - RFC3173"); |
485 | MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>"); | 184 | MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>"); |
486 | 185 | ||
487 | MODULE_ALIAS_XFRM_TYPE(AF_INET, XFRM_PROTO_COMP); | 186 | MODULE_ALIAS_XFRM_TYPE(AF_INET, XFRM_PROTO_COMP); |
diff --git a/net/ipv4/netfilter/Kconfig b/net/ipv4/netfilter/Kconfig index f23e60c93ef9..90eb7cb47e77 100644 --- a/net/ipv4/netfilter/Kconfig +++ b/net/ipv4/netfilter/Kconfig | |||
@@ -369,7 +369,7 @@ config IP_NF_SECURITY | |||
369 | tristate "Security table" | 369 | tristate "Security table" |
370 | depends on IP_NF_IPTABLES | 370 | depends on IP_NF_IPTABLES |
371 | depends on SECURITY | 371 | depends on SECURITY |
372 | default m if NETFILTER_ADVANCED=n | 372 | depends on NETFILTER_ADVANCED |
373 | help | 373 | help |
374 | This option adds a `security' table to iptables, for use | 374 | This option adds a `security' table to iptables, for use |
375 | with Mandatory Access Control (MAC) policy. | 375 | with Mandatory Access Control (MAC) policy. |
diff --git a/net/ipv4/netfilter/arptable_filter.c b/net/ipv4/netfilter/arptable_filter.c index 3be4d07e7ed9..082f5dd3156c 100644 --- a/net/ipv4/netfilter/arptable_filter.c +++ b/net/ipv4/netfilter/arptable_filter.c | |||
@@ -55,32 +55,53 @@ static struct xt_table packet_filter = { | |||
55 | }; | 55 | }; |
56 | 56 | ||
57 | /* The work comes in here from netfilter.c */ | 57 | /* The work comes in here from netfilter.c */ |
58 | static unsigned int arpt_hook(unsigned int hook, | 58 | static unsigned int arpt_in_hook(unsigned int hook, |
59 | struct sk_buff *skb, | 59 | struct sk_buff *skb, |
60 | const struct net_device *in, | 60 | const struct net_device *in, |
61 | const struct net_device *out, | 61 | const struct net_device *out, |
62 | int (*okfn)(struct sk_buff *)) | 62 | int (*okfn)(struct sk_buff *)) |
63 | { | 63 | { |
64 | return arpt_do_table(skb, hook, in, out, init_net.ipv4.arptable_filter); | 64 | return arpt_do_table(skb, hook, in, out, |
65 | dev_net(in)->ipv4.arptable_filter); | ||
66 | } | ||
67 | |||
68 | static unsigned int arpt_out_hook(unsigned int hook, | ||
69 | struct sk_buff *skb, | ||
70 | const struct net_device *in, | ||
71 | const struct net_device *out, | ||
72 | int (*okfn)(struct sk_buff *)) | ||
73 | { | ||
74 | return arpt_do_table(skb, hook, in, out, | ||
75 | dev_net(out)->ipv4.arptable_filter); | ||
76 | } | ||
77 | |||
78 | static unsigned int arpt_forward_hook(unsigned int hook, | ||
79 | struct sk_buff *skb, | ||
80 | const struct net_device *in, | ||
81 | const struct net_device *out, | ||
82 | int (*okfn)(struct sk_buff *)) | ||
83 | { | ||
84 | return arpt_do_table(skb, hook, in, out, | ||
85 | dev_net(in)->ipv4.arptable_filter); | ||
65 | } | 86 | } |
66 | 87 | ||
67 | static struct nf_hook_ops arpt_ops[] __read_mostly = { | 88 | static struct nf_hook_ops arpt_ops[] __read_mostly = { |
68 | { | 89 | { |
69 | .hook = arpt_hook, | 90 | .hook = arpt_in_hook, |
70 | .owner = THIS_MODULE, | 91 | .owner = THIS_MODULE, |
71 | .pf = NF_ARP, | 92 | .pf = NF_ARP, |
72 | .hooknum = NF_ARP_IN, | 93 | .hooknum = NF_ARP_IN, |
73 | .priority = NF_IP_PRI_FILTER, | 94 | .priority = NF_IP_PRI_FILTER, |
74 | }, | 95 | }, |
75 | { | 96 | { |
76 | .hook = arpt_hook, | 97 | .hook = arpt_out_hook, |
77 | .owner = THIS_MODULE, | 98 | .owner = THIS_MODULE, |
78 | .pf = NF_ARP, | 99 | .pf = NF_ARP, |
79 | .hooknum = NF_ARP_OUT, | 100 | .hooknum = NF_ARP_OUT, |
80 | .priority = NF_IP_PRI_FILTER, | 101 | .priority = NF_IP_PRI_FILTER, |
81 | }, | 102 | }, |
82 | { | 103 | { |
83 | .hook = arpt_hook, | 104 | .hook = arpt_forward_hook, |
84 | .owner = THIS_MODULE, | 105 | .owner = THIS_MODULE, |
85 | .pf = NF_ARP, | 106 | .pf = NF_ARP, |
86 | .hooknum = NF_ARP_FORWARD, | 107 | .hooknum = NF_ARP_FORWARD, |
diff --git a/net/ipv4/netfilter/iptable_security.c b/net/ipv4/netfilter/iptable_security.c index 2b472ac2263a..db6d312128e1 100644 --- a/net/ipv4/netfilter/iptable_security.c +++ b/net/ipv4/netfilter/iptable_security.c | |||
@@ -32,7 +32,7 @@ static struct | |||
32 | struct ipt_replace repl; | 32 | struct ipt_replace repl; |
33 | struct ipt_standard entries[3]; | 33 | struct ipt_standard entries[3]; |
34 | struct ipt_error term; | 34 | struct ipt_error term; |
35 | } initial_table __initdata = { | 35 | } initial_table __net_initdata = { |
36 | .repl = { | 36 | .repl = { |
37 | .name = "security", | 37 | .name = "security", |
38 | .valid_hooks = SECURITY_VALID_HOOKS, | 38 | .valid_hooks = SECURITY_VALID_HOOKS, |
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index e4ab0ac94f92..380d6474cf66 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -1502,7 +1502,7 @@ unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph, | |||
1502 | rth->fl.iif != 0 || | 1502 | rth->fl.iif != 0 || |
1503 | dst_metric_locked(&rth->u.dst, RTAX_MTU) || | 1503 | dst_metric_locked(&rth->u.dst, RTAX_MTU) || |
1504 | !net_eq(dev_net(rth->u.dst.dev), net) || | 1504 | !net_eq(dev_net(rth->u.dst.dev), net) || |
1505 | !rt_is_expired(rth)) | 1505 | rt_is_expired(rth)) |
1506 | continue; | 1506 | continue; |
1507 | 1507 | ||
1508 | if (new_mtu < 68 || new_mtu >= old_mtu) { | 1508 | if (new_mtu < 68 || new_mtu >= old_mtu) { |
@@ -2914,7 +2914,7 @@ static int ipv4_sysctl_rtcache_flush_strategy(ctl_table *table, | |||
2914 | return 0; | 2914 | return 0; |
2915 | } | 2915 | } |
2916 | 2916 | ||
2917 | ctl_table ipv4_route_table[] = { | 2917 | static ctl_table ipv4_route_table[] = { |
2918 | { | 2918 | { |
2919 | .ctl_name = NET_IPV4_ROUTE_GC_THRESH, | 2919 | .ctl_name = NET_IPV4_ROUTE_GC_THRESH, |
2920 | .procname = "gc_thresh", | 2920 | .procname = "gc_thresh", |
@@ -3216,6 +3216,15 @@ int __init ip_rt_init(void) | |||
3216 | return rc; | 3216 | return rc; |
3217 | } | 3217 | } |
3218 | 3218 | ||
3219 | /* | ||
3220 | * We really need to sanitize the damn ipv4 init order, then all | ||
3221 | * this nonsense will go away. | ||
3222 | */ | ||
3223 | void __init ip_static_sysctl_init(void) | ||
3224 | { | ||
3225 | register_sysctl_paths(ipv4_route_path, ipv4_route_table); | ||
3226 | } | ||
3227 | |||
3219 | EXPORT_SYMBOL(__ip_select_ident); | 3228 | EXPORT_SYMBOL(__ip_select_ident); |
3220 | EXPORT_SYMBOL(ip_route_input); | 3229 | EXPORT_SYMBOL(ip_route_input); |
3221 | EXPORT_SYMBOL(ip_route_output_key); | 3230 | EXPORT_SYMBOL(ip_route_output_key); |
diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c index 51bc24d3b8a7..9d38005abbac 100644 --- a/net/ipv4/syncookies.c +++ b/net/ipv4/syncookies.c | |||
@@ -299,6 +299,7 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb, | |||
299 | ireq->rmt_port = th->source; | 299 | ireq->rmt_port = th->source; |
300 | ireq->loc_addr = ip_hdr(skb)->daddr; | 300 | ireq->loc_addr = ip_hdr(skb)->daddr; |
301 | ireq->rmt_addr = ip_hdr(skb)->saddr; | 301 | ireq->rmt_addr = ip_hdr(skb)->saddr; |
302 | ireq->ecn_ok = 0; | ||
302 | ireq->snd_wscale = tcp_opt.snd_wscale; | 303 | ireq->snd_wscale = tcp_opt.snd_wscale; |
303 | ireq->rcv_wscale = tcp_opt.rcv_wscale; | 304 | ireq->rcv_wscale = tcp_opt.rcv_wscale; |
304 | ireq->sack_ok = tcp_opt.sack_ok; | 305 | ireq->sack_ok = tcp_opt.sack_ok; |
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index 14ef202a2254..770d827f5ab8 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c | |||
@@ -401,13 +401,6 @@ static struct ctl_table ipv4_table[] = { | |||
401 | .proc_handler = &ipv4_local_port_range, | 401 | .proc_handler = &ipv4_local_port_range, |
402 | .strategy = &ipv4_sysctl_local_port_range, | 402 | .strategy = &ipv4_sysctl_local_port_range, |
403 | }, | 403 | }, |
404 | { | ||
405 | .ctl_name = NET_IPV4_ROUTE, | ||
406 | .procname = "route", | ||
407 | .maxlen = 0, | ||
408 | .mode = 0555, | ||
409 | .child = ipv4_route_table | ||
410 | }, | ||
411 | #ifdef CONFIG_IP_MULTICAST | 404 | #ifdef CONFIG_IP_MULTICAST |
412 | { | 405 | { |
413 | .ctl_name = NET_IPV4_IGMP_MAX_MEMBERSHIPS, | 406 | .ctl_name = NET_IPV4_IGMP_MAX_MEMBERSHIPS, |
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 0b491bf03db4..1ab341e5d3e0 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -1096,7 +1096,7 @@ void tcp_cleanup_rbuf(struct sock *sk, int copied) | |||
1096 | #if TCP_DEBUG | 1096 | #if TCP_DEBUG |
1097 | struct sk_buff *skb = skb_peek(&sk->sk_receive_queue); | 1097 | struct sk_buff *skb = skb_peek(&sk->sk_receive_queue); |
1098 | 1098 | ||
1099 | BUG_TRAP(!skb || before(tp->copied_seq, TCP_SKB_CB(skb)->end_seq)); | 1099 | WARN_ON(skb && !before(tp->copied_seq, TCP_SKB_CB(skb)->end_seq)); |
1100 | #endif | 1100 | #endif |
1101 | 1101 | ||
1102 | if (inet_csk_ack_scheduled(sk)) { | 1102 | if (inet_csk_ack_scheduled(sk)) { |
@@ -1358,7 +1358,7 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, | |||
1358 | goto found_ok_skb; | 1358 | goto found_ok_skb; |
1359 | if (tcp_hdr(skb)->fin) | 1359 | if (tcp_hdr(skb)->fin) |
1360 | goto found_fin_ok; | 1360 | goto found_fin_ok; |
1361 | BUG_TRAP(flags & MSG_PEEK); | 1361 | WARN_ON(!(flags & MSG_PEEK)); |
1362 | skb = skb->next; | 1362 | skb = skb->next; |
1363 | } while (skb != (struct sk_buff *)&sk->sk_receive_queue); | 1363 | } while (skb != (struct sk_buff *)&sk->sk_receive_queue); |
1364 | 1364 | ||
@@ -1421,8 +1421,8 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, | |||
1421 | 1421 | ||
1422 | tp->ucopy.len = len; | 1422 | tp->ucopy.len = len; |
1423 | 1423 | ||
1424 | BUG_TRAP(tp->copied_seq == tp->rcv_nxt || | 1424 | WARN_ON(tp->copied_seq != tp->rcv_nxt && |
1425 | (flags & (MSG_PEEK | MSG_TRUNC))); | 1425 | !(flags & (MSG_PEEK | MSG_TRUNC))); |
1426 | 1426 | ||
1427 | /* Ugly... If prequeue is not empty, we have to | 1427 | /* Ugly... If prequeue is not empty, we have to |
1428 | * process it before releasing socket, otherwise | 1428 | * process it before releasing socket, otherwise |
@@ -1844,7 +1844,7 @@ adjudge_to_death: | |||
1844 | */ | 1844 | */ |
1845 | local_bh_disable(); | 1845 | local_bh_disable(); |
1846 | bh_lock_sock(sk); | 1846 | bh_lock_sock(sk); |
1847 | BUG_TRAP(!sock_owned_by_user(sk)); | 1847 | WARN_ON(sock_owned_by_user(sk)); |
1848 | 1848 | ||
1849 | /* Have we already been destroyed by a softirq or backlog? */ | 1849 | /* Have we already been destroyed by a softirq or backlog? */ |
1850 | if (state != TCP_CLOSE && sk->sk_state == TCP_CLOSE) | 1850 | if (state != TCP_CLOSE && sk->sk_state == TCP_CLOSE) |
@@ -1973,7 +1973,7 @@ int tcp_disconnect(struct sock *sk, int flags) | |||
1973 | memset(&tp->rx_opt, 0, sizeof(tp->rx_opt)); | 1973 | memset(&tp->rx_opt, 0, sizeof(tp->rx_opt)); |
1974 | __sk_dst_reset(sk); | 1974 | __sk_dst_reset(sk); |
1975 | 1975 | ||
1976 | BUG_TRAP(!inet->num || icsk->icsk_bind_hash); | 1976 | WARN_ON(inet->num && !icsk->icsk_bind_hash); |
1977 | 1977 | ||
1978 | sk->sk_error_report(sk); | 1978 | sk->sk_error_report(sk); |
1979 | return err; | 1979 | return err; |
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 1f5e6049883e..67ccce2a96bd 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
@@ -1629,10 +1629,10 @@ advance_sp: | |||
1629 | out: | 1629 | out: |
1630 | 1630 | ||
1631 | #if FASTRETRANS_DEBUG > 0 | 1631 | #if FASTRETRANS_DEBUG > 0 |
1632 | BUG_TRAP((int)tp->sacked_out >= 0); | 1632 | WARN_ON((int)tp->sacked_out < 0); |
1633 | BUG_TRAP((int)tp->lost_out >= 0); | 1633 | WARN_ON((int)tp->lost_out < 0); |
1634 | BUG_TRAP((int)tp->retrans_out >= 0); | 1634 | WARN_ON((int)tp->retrans_out < 0); |
1635 | BUG_TRAP((int)tcp_packets_in_flight(tp) >= 0); | 1635 | WARN_ON((int)tcp_packets_in_flight(tp) < 0); |
1636 | #endif | 1636 | #endif |
1637 | return flag; | 1637 | return flag; |
1638 | } | 1638 | } |
@@ -2181,7 +2181,7 @@ static void tcp_mark_head_lost(struct sock *sk, int packets) | |||
2181 | int err; | 2181 | int err; |
2182 | unsigned int mss; | 2182 | unsigned int mss; |
2183 | 2183 | ||
2184 | BUG_TRAP(packets <= tp->packets_out); | 2184 | WARN_ON(packets > tp->packets_out); |
2185 | if (tp->lost_skb_hint) { | 2185 | if (tp->lost_skb_hint) { |
2186 | skb = tp->lost_skb_hint; | 2186 | skb = tp->lost_skb_hint; |
2187 | cnt = tp->lost_cnt_hint; | 2187 | cnt = tp->lost_cnt_hint; |
@@ -2610,7 +2610,7 @@ static void tcp_fastretrans_alert(struct sock *sk, int pkts_acked, int flag) | |||
2610 | /* E. Check state exit conditions. State can be terminated | 2610 | /* E. Check state exit conditions. State can be terminated |
2611 | * when high_seq is ACKed. */ | 2611 | * when high_seq is ACKed. */ |
2612 | if (icsk->icsk_ca_state == TCP_CA_Open) { | 2612 | if (icsk->icsk_ca_state == TCP_CA_Open) { |
2613 | BUG_TRAP(tp->retrans_out == 0); | 2613 | WARN_ON(tp->retrans_out != 0); |
2614 | tp->retrans_stamp = 0; | 2614 | tp->retrans_stamp = 0; |
2615 | } else if (!before(tp->snd_una, tp->high_seq)) { | 2615 | } else if (!before(tp->snd_una, tp->high_seq)) { |
2616 | switch (icsk->icsk_ca_state) { | 2616 | switch (icsk->icsk_ca_state) { |
@@ -2972,9 +2972,9 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets) | |||
2972 | } | 2972 | } |
2973 | 2973 | ||
2974 | #if FASTRETRANS_DEBUG > 0 | 2974 | #if FASTRETRANS_DEBUG > 0 |
2975 | BUG_TRAP((int)tp->sacked_out >= 0); | 2975 | WARN_ON((int)tp->sacked_out < 0); |
2976 | BUG_TRAP((int)tp->lost_out >= 0); | 2976 | WARN_ON((int)tp->lost_out < 0); |
2977 | BUG_TRAP((int)tp->retrans_out >= 0); | 2977 | WARN_ON((int)tp->retrans_out < 0); |
2978 | if (!tp->packets_out && tcp_is_sack(tp)) { | 2978 | if (!tp->packets_out && tcp_is_sack(tp)) { |
2979 | icsk = inet_csk(sk); | 2979 | icsk = inet_csk(sk); |
2980 | if (tp->lost_out) { | 2980 | if (tp->lost_out) { |
@@ -3292,6 +3292,7 @@ static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag) | |||
3292 | * log. Something worked... | 3292 | * log. Something worked... |
3293 | */ | 3293 | */ |
3294 | sk->sk_err_soft = 0; | 3294 | sk->sk_err_soft = 0; |
3295 | icsk->icsk_probes_out = 0; | ||
3295 | tp->rcv_tstamp = tcp_time_stamp; | 3296 | tp->rcv_tstamp = tcp_time_stamp; |
3296 | prior_packets = tp->packets_out; | 3297 | prior_packets = tp->packets_out; |
3297 | if (!prior_packets) | 3298 | if (!prior_packets) |
@@ -3324,8 +3325,6 @@ static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag) | |||
3324 | return 1; | 3325 | return 1; |
3325 | 3326 | ||
3326 | no_queue: | 3327 | no_queue: |
3327 | icsk->icsk_probes_out = 0; | ||
3328 | |||
3329 | /* If this ack opens up a zero window, clear backoff. It was | 3328 | /* If this ack opens up a zero window, clear backoff. It was |
3330 | * being used to time the probes, and is probably far higher than | 3329 | * being used to time the probes, and is probably far higher than |
3331 | * it needs to be for normal retransmission. | 3330 | * it needs to be for normal retransmission. |
@@ -3878,7 +3877,7 @@ static void tcp_sack_remove(struct tcp_sock *tp) | |||
3878 | int i; | 3877 | int i; |
3879 | 3878 | ||
3880 | /* RCV.NXT must cover all the block! */ | 3879 | /* RCV.NXT must cover all the block! */ |
3881 | BUG_TRAP(!before(tp->rcv_nxt, sp->end_seq)); | 3880 | WARN_ON(before(tp->rcv_nxt, sp->end_seq)); |
3882 | 3881 | ||
3883 | /* Zap this SACK, by moving forward any other SACKS. */ | 3882 | /* Zap this SACK, by moving forward any other SACKS. */ |
3884 | for (i=this_sack+1; i < num_sacks; i++) | 3883 | for (i=this_sack+1; i < num_sacks; i++) |
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index a82df6307567..a2b06d0cc26b 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c | |||
@@ -418,7 +418,7 @@ void tcp_v4_err(struct sk_buff *skb, u32 info) | |||
418 | /* ICMPs are not backlogged, hence we cannot get | 418 | /* ICMPs are not backlogged, hence we cannot get |
419 | an established socket here. | 419 | an established socket here. |
420 | */ | 420 | */ |
421 | BUG_TRAP(!req->sk); | 421 | WARN_ON(req->sk); |
422 | 422 | ||
423 | if (seq != tcp_rsk(req)->snt_isn) { | 423 | if (seq != tcp_rsk(req)->snt_isn) { |
424 | NET_INC_STATS_BH(net, LINUX_MIB_OUTOFWINDOWICMPS); | 424 | NET_INC_STATS_BH(net, LINUX_MIB_OUTOFWINDOWICMPS); |
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 1fa683c0ba9b..a00532de2a8c 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
@@ -472,7 +472,7 @@ static unsigned tcp_syn_options(struct sock *sk, struct sk_buff *skb, | |||
472 | } | 472 | } |
473 | if (likely(sysctl_tcp_sack)) { | 473 | if (likely(sysctl_tcp_sack)) { |
474 | opts->options |= OPTION_SACK_ADVERTISE; | 474 | opts->options |= OPTION_SACK_ADVERTISE; |
475 | if (unlikely(!OPTION_TS & opts->options)) | 475 | if (unlikely(!(OPTION_TS & opts->options))) |
476 | size += TCPOLEN_SACKPERM_ALIGNED; | 476 | size += TCPOLEN_SACKPERM_ALIGNED; |
477 | } | 477 | } |
478 | 478 | ||
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index 328e0cf42b3c..5ab6ba19c3ce 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c | |||
@@ -287,7 +287,7 @@ static void tcp_retransmit_timer(struct sock *sk) | |||
287 | if (!tp->packets_out) | 287 | if (!tp->packets_out) |
288 | goto out; | 288 | goto out; |
289 | 289 | ||
290 | BUG_TRAP(!tcp_write_queue_empty(sk)); | 290 | WARN_ON(tcp_write_queue_empty(sk)); |
291 | 291 | ||
292 | if (!tp->snd_wnd && !sock_flag(sk, SOCK_DEAD) && | 292 | if (!tp->snd_wnd && !sock_flag(sk, SOCK_DEAD) && |
293 | !((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV))) { | 293 | !((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV))) { |
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index a751770947a3..383d17359d01 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
@@ -1325,6 +1325,8 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname, | |||
1325 | return -ENOPROTOOPT; | 1325 | return -ENOPROTOOPT; |
1326 | if (val != 0 && val < 8) /* Illegal coverage: use default (8) */ | 1326 | if (val != 0 && val < 8) /* Illegal coverage: use default (8) */ |
1327 | val = 8; | 1327 | val = 8; |
1328 | else if (val > USHORT_MAX) | ||
1329 | val = USHORT_MAX; | ||
1328 | up->pcslen = val; | 1330 | up->pcslen = val; |
1329 | up->pcflag |= UDPLITE_SEND_CC; | 1331 | up->pcflag |= UDPLITE_SEND_CC; |
1330 | break; | 1332 | break; |
@@ -1337,6 +1339,8 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname, | |||
1337 | return -ENOPROTOOPT; | 1339 | return -ENOPROTOOPT; |
1338 | if (val != 0 && val < 8) /* Avoid silly minimal values. */ | 1340 | if (val != 0 && val < 8) /* Avoid silly minimal values. */ |
1339 | val = 8; | 1341 | val = 8; |
1342 | else if (val > USHORT_MAX) | ||
1343 | val = USHORT_MAX; | ||
1340 | up->pcrlen = val; | 1344 | up->pcrlen = val; |
1341 | up->pcflag |= UDPLITE_RECV_CC; | 1345 | up->pcflag |= UDPLITE_RECV_CC; |
1342 | break; | 1346 | break; |
diff --git a/net/ipv6/Kconfig b/net/ipv6/Kconfig index 42814a2ec9d7..ec992159b5f8 100644 --- a/net/ipv6/Kconfig +++ b/net/ipv6/Kconfig | |||
@@ -96,10 +96,8 @@ config INET6_ESP | |||
96 | 96 | ||
97 | config INET6_IPCOMP | 97 | config INET6_IPCOMP |
98 | tristate "IPv6: IPComp transformation" | 98 | tristate "IPv6: IPComp transformation" |
99 | select XFRM | ||
100 | select INET6_XFRM_TUNNEL | 99 | select INET6_XFRM_TUNNEL |
101 | select CRYPTO | 100 | select XFRM_IPCOMP |
102 | select CRYPTO_DEFLATE | ||
103 | ---help--- | 101 | ---help--- |
104 | Support for IP Payload Compression Protocol (IPComp) (RFC3173), | 102 | Support for IP Payload Compression Protocol (IPComp) (RFC3173), |
105 | typically needed for IPsec. | 103 | typically needed for IPsec. |
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 9f4fcce6379b..a7842c54f58a 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
@@ -153,7 +153,7 @@ static int ipv6_chk_same_addr(struct net *net, const struct in6_addr *addr, | |||
153 | 153 | ||
154 | static ATOMIC_NOTIFIER_HEAD(inet6addr_chain); | 154 | static ATOMIC_NOTIFIER_HEAD(inet6addr_chain); |
155 | 155 | ||
156 | struct ipv6_devconf ipv6_devconf __read_mostly = { | 156 | static struct ipv6_devconf ipv6_devconf __read_mostly = { |
157 | .forwarding = 0, | 157 | .forwarding = 0, |
158 | .hop_limit = IPV6_DEFAULT_HOPLIMIT, | 158 | .hop_limit = IPV6_DEFAULT_HOPLIMIT, |
159 | .mtu6 = IPV6_MIN_MTU, | 159 | .mtu6 = IPV6_MIN_MTU, |
@@ -313,8 +313,10 @@ static void in6_dev_finish_destroy_rcu(struct rcu_head *head) | |||
313 | void in6_dev_finish_destroy(struct inet6_dev *idev) | 313 | void in6_dev_finish_destroy(struct inet6_dev *idev) |
314 | { | 314 | { |
315 | struct net_device *dev = idev->dev; | 315 | struct net_device *dev = idev->dev; |
316 | BUG_TRAP(idev->addr_list==NULL); | 316 | |
317 | BUG_TRAP(idev->mc_list==NULL); | 317 | WARN_ON(idev->addr_list != NULL); |
318 | WARN_ON(idev->mc_list != NULL); | ||
319 | |||
318 | #ifdef NET_REFCNT_DEBUG | 320 | #ifdef NET_REFCNT_DEBUG |
319 | printk(KERN_DEBUG "in6_dev_finish_destroy: %s\n", dev ? dev->name : "NIL"); | 321 | printk(KERN_DEBUG "in6_dev_finish_destroy: %s\n", dev ? dev->name : "NIL"); |
320 | #endif | 322 | #endif |
@@ -517,8 +519,9 @@ static void addrconf_fixup_forwarding(struct ctl_table *table, int *p, int old) | |||
517 | 519 | ||
518 | void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp) | 520 | void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp) |
519 | { | 521 | { |
520 | BUG_TRAP(ifp->if_next==NULL); | 522 | WARN_ON(ifp->if_next != NULL); |
521 | BUG_TRAP(ifp->lst_next==NULL); | 523 | WARN_ON(ifp->lst_next != NULL); |
524 | |||
522 | #ifdef NET_REFCNT_DEBUG | 525 | #ifdef NET_REFCNT_DEBUG |
523 | printk(KERN_DEBUG "inet6_ifa_finish_destroy\n"); | 526 | printk(KERN_DEBUG "inet6_ifa_finish_destroy\n"); |
524 | #endif | 527 | #endif |
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index 3d828bc4b1cf..95055f8c3f35 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c | |||
@@ -83,7 +83,6 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol) | |||
83 | struct inet_sock *inet; | 83 | struct inet_sock *inet; |
84 | struct ipv6_pinfo *np; | 84 | struct ipv6_pinfo *np; |
85 | struct sock *sk; | 85 | struct sock *sk; |
86 | struct list_head *p; | ||
87 | struct inet_protosw *answer; | 86 | struct inet_protosw *answer; |
88 | struct proto *answer_prot; | 87 | struct proto *answer_prot; |
89 | unsigned char answer_flags; | 88 | unsigned char answer_flags; |
@@ -97,13 +96,12 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol) | |||
97 | build_ehash_secret(); | 96 | build_ehash_secret(); |
98 | 97 | ||
99 | /* Look for the requested type/protocol pair. */ | 98 | /* Look for the requested type/protocol pair. */ |
100 | answer = NULL; | ||
101 | lookup_protocol: | 99 | lookup_protocol: |
102 | err = -ESOCKTNOSUPPORT; | 100 | err = -ESOCKTNOSUPPORT; |
103 | rcu_read_lock(); | 101 | rcu_read_lock(); |
104 | list_for_each_rcu(p, &inetsw6[sock->type]) { | 102 | list_for_each_entry_rcu(answer, &inetsw6[sock->type], list) { |
105 | answer = list_entry(p, struct inet_protosw, list); | ||
106 | 103 | ||
104 | err = 0; | ||
107 | /* Check the non-wild match. */ | 105 | /* Check the non-wild match. */ |
108 | if (protocol == answer->protocol) { | 106 | if (protocol == answer->protocol) { |
109 | if (protocol != IPPROTO_IP) | 107 | if (protocol != IPPROTO_IP) |
@@ -118,10 +116,9 @@ lookup_protocol: | |||
118 | break; | 116 | break; |
119 | } | 117 | } |
120 | err = -EPROTONOSUPPORT; | 118 | err = -EPROTONOSUPPORT; |
121 | answer = NULL; | ||
122 | } | 119 | } |
123 | 120 | ||
124 | if (!answer) { | 121 | if (err) { |
125 | if (try_loading_module < 2) { | 122 | if (try_loading_module < 2) { |
126 | rcu_read_unlock(); | 123 | rcu_read_unlock(); |
127 | /* | 124 | /* |
@@ -153,7 +150,7 @@ lookup_protocol: | |||
153 | answer_flags = answer->flags; | 150 | answer_flags = answer->flags; |
154 | rcu_read_unlock(); | 151 | rcu_read_unlock(); |
155 | 152 | ||
156 | BUG_TRAP(answer_prot->slab != NULL); | 153 | WARN_ON(answer_prot->slab == NULL); |
157 | 154 | ||
158 | err = -ENOBUFS; | 155 | err = -ENOBUFS; |
159 | sk = sk_alloc(net, PF_INET6, GFP_KERNEL, answer_prot); | 156 | sk = sk_alloc(net, PF_INET6, GFP_KERNEL, answer_prot); |
@@ -937,6 +934,11 @@ static int __init inet6_init(void) | |||
937 | if (err) | 934 | if (err) |
938 | goto out_unregister_sock; | 935 | goto out_unregister_sock; |
939 | 936 | ||
937 | #ifdef CONFIG_SYSCTL | ||
938 | err = ipv6_static_sysctl_register(); | ||
939 | if (err) | ||
940 | goto static_sysctl_fail; | ||
941 | #endif | ||
940 | /* | 942 | /* |
941 | * ipngwg API draft makes clear that the correct semantics | 943 | * ipngwg API draft makes clear that the correct semantics |
942 | * for TCP and UDP is to consider one TCP and UDP instance | 944 | * for TCP and UDP is to consider one TCP and UDP instance |
@@ -1061,6 +1063,10 @@ ipmr_fail: | |||
1061 | icmp_fail: | 1063 | icmp_fail: |
1062 | unregister_pernet_subsys(&inet6_net_ops); | 1064 | unregister_pernet_subsys(&inet6_net_ops); |
1063 | register_pernet_fail: | 1065 | register_pernet_fail: |
1066 | #ifdef CONFIG_SYSCTL | ||
1067 | ipv6_static_sysctl_unregister(); | ||
1068 | static_sysctl_fail: | ||
1069 | #endif | ||
1064 | cleanup_ipv6_mibs(); | 1070 | cleanup_ipv6_mibs(); |
1065 | out_unregister_sock: | 1071 | out_unregister_sock: |
1066 | sock_unregister(PF_INET6); | 1072 | sock_unregister(PF_INET6); |
@@ -1116,6 +1122,9 @@ static void __exit inet6_exit(void) | |||
1116 | rawv6_exit(); | 1122 | rawv6_exit(); |
1117 | 1123 | ||
1118 | unregister_pernet_subsys(&inet6_net_ops); | 1124 | unregister_pernet_subsys(&inet6_net_ops); |
1125 | #ifdef CONFIG_SYSCTL | ||
1126 | ipv6_static_sysctl_unregister(); | ||
1127 | #endif | ||
1119 | cleanup_ipv6_mibs(); | 1128 | cleanup_ipv6_mibs(); |
1120 | proto_unregister(&rawv6_prot); | 1129 | proto_unregister(&rawv6_prot); |
1121 | proto_unregister(&udplitev6_prot); | 1130 | proto_unregister(&udplitev6_prot); |
diff --git a/net/ipv6/inet6_connection_sock.c b/net/ipv6/inet6_connection_sock.c index 87801cc1b2f8..16d43f20b32f 100644 --- a/net/ipv6/inet6_connection_sock.c +++ b/net/ipv6/inet6_connection_sock.c | |||
@@ -98,7 +98,7 @@ struct request_sock *inet6_csk_search_req(const struct sock *sk, | |||
98 | ipv6_addr_equal(&treq->rmt_addr, raddr) && | 98 | ipv6_addr_equal(&treq->rmt_addr, raddr) && |
99 | ipv6_addr_equal(&treq->loc_addr, laddr) && | 99 | ipv6_addr_equal(&treq->loc_addr, laddr) && |
100 | (!treq->iif || treq->iif == iif)) { | 100 | (!treq->iif || treq->iif == iif)) { |
101 | BUG_TRAP(req->sk == NULL); | 101 | WARN_ON(req->sk != NULL); |
102 | *prevp = prev; | 102 | *prevp = prev; |
103 | return req; | 103 | return req; |
104 | } | 104 | } |
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c index 00a8a5f9380c..1646a5658255 100644 --- a/net/ipv6/inet6_hashtables.c +++ b/net/ipv6/inet6_hashtables.c | |||
@@ -28,7 +28,7 @@ void __inet6_hash(struct sock *sk) | |||
28 | struct hlist_head *list; | 28 | struct hlist_head *list; |
29 | rwlock_t *lock; | 29 | rwlock_t *lock; |
30 | 30 | ||
31 | BUG_TRAP(sk_unhashed(sk)); | 31 | WARN_ON(!sk_unhashed(sk)); |
32 | 32 | ||
33 | if (sk->sk_state == TCP_LISTEN) { | 33 | if (sk->sk_state == TCP_LISTEN) { |
34 | list = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)]; | 34 | list = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)]; |
@@ -202,7 +202,7 @@ unique: | |||
202 | * in hash table socket with a funny identity. */ | 202 | * in hash table socket with a funny identity. */ |
203 | inet->num = lport; | 203 | inet->num = lport; |
204 | inet->sport = htons(lport); | 204 | inet->sport = htons(lport); |
205 | BUG_TRAP(sk_unhashed(sk)); | 205 | WARN_ON(!sk_unhashed(sk)); |
206 | __sk_add_node(sk, &head->chain); | 206 | __sk_add_node(sk, &head->chain); |
207 | sk->sk_hash = hash; | 207 | sk->sk_hash = hash; |
208 | sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); | 208 | sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); |
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index 4de2b9efcacb..52dddc25d3e6 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c | |||
@@ -287,7 +287,7 @@ static int fib6_dump_node(struct fib6_walker_t *w) | |||
287 | w->leaf = rt; | 287 | w->leaf = rt; |
288 | return 1; | 288 | return 1; |
289 | } | 289 | } |
290 | BUG_TRAP(res!=0); | 290 | WARN_ON(res == 0); |
291 | } | 291 | } |
292 | w->leaf = NULL; | 292 | w->leaf = NULL; |
293 | return 0; | 293 | return 0; |
@@ -661,17 +661,17 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt, | |||
661 | 661 | ||
662 | static __inline__ void fib6_start_gc(struct net *net, struct rt6_info *rt) | 662 | static __inline__ void fib6_start_gc(struct net *net, struct rt6_info *rt) |
663 | { | 663 | { |
664 | if (net->ipv6.ip6_fib_timer->expires == 0 && | 664 | if (!timer_pending(&net->ipv6.ip6_fib_timer) && |
665 | (rt->rt6i_flags & (RTF_EXPIRES|RTF_CACHE))) | 665 | (rt->rt6i_flags & (RTF_EXPIRES|RTF_CACHE))) |
666 | mod_timer(net->ipv6.ip6_fib_timer, jiffies + | 666 | mod_timer(&net->ipv6.ip6_fib_timer, |
667 | net->ipv6.sysctl.ip6_rt_gc_interval); | 667 | jiffies + net->ipv6.sysctl.ip6_rt_gc_interval); |
668 | } | 668 | } |
669 | 669 | ||
670 | void fib6_force_start_gc(struct net *net) | 670 | void fib6_force_start_gc(struct net *net) |
671 | { | 671 | { |
672 | if (net->ipv6.ip6_fib_timer->expires == 0) | 672 | if (!timer_pending(&net->ipv6.ip6_fib_timer)) |
673 | mod_timer(net->ipv6.ip6_fib_timer, jiffies + | 673 | mod_timer(&net->ipv6.ip6_fib_timer, |
674 | net->ipv6.sysctl.ip6_rt_gc_interval); | 674 | jiffies + net->ipv6.sysctl.ip6_rt_gc_interval); |
675 | } | 675 | } |
676 | 676 | ||
677 | /* | 677 | /* |
@@ -778,7 +778,7 @@ out: | |||
778 | pn->leaf = fib6_find_prefix(info->nl_net, pn); | 778 | pn->leaf = fib6_find_prefix(info->nl_net, pn); |
779 | #if RT6_DEBUG >= 2 | 779 | #if RT6_DEBUG >= 2 |
780 | if (!pn->leaf) { | 780 | if (!pn->leaf) { |
781 | BUG_TRAP(pn->leaf != NULL); | 781 | WARN_ON(pn->leaf == NULL); |
782 | pn->leaf = info->nl_net->ipv6.ip6_null_entry; | 782 | pn->leaf = info->nl_net->ipv6.ip6_null_entry; |
783 | } | 783 | } |
784 | #endif | 784 | #endif |
@@ -942,7 +942,7 @@ struct fib6_node * fib6_locate(struct fib6_node *root, | |||
942 | 942 | ||
943 | #ifdef CONFIG_IPV6_SUBTREES | 943 | #ifdef CONFIG_IPV6_SUBTREES |
944 | if (src_len) { | 944 | if (src_len) { |
945 | BUG_TRAP(saddr!=NULL); | 945 | WARN_ON(saddr == NULL); |
946 | if (fn && fn->subtree) | 946 | if (fn && fn->subtree) |
947 | fn = fib6_locate_1(fn->subtree, saddr, src_len, | 947 | fn = fib6_locate_1(fn->subtree, saddr, src_len, |
948 | offsetof(struct rt6_info, rt6i_src)); | 948 | offsetof(struct rt6_info, rt6i_src)); |
@@ -996,9 +996,9 @@ static struct fib6_node *fib6_repair_tree(struct net *net, | |||
996 | RT6_TRACE("fixing tree: plen=%d iter=%d\n", fn->fn_bit, iter); | 996 | RT6_TRACE("fixing tree: plen=%d iter=%d\n", fn->fn_bit, iter); |
997 | iter++; | 997 | iter++; |
998 | 998 | ||
999 | BUG_TRAP(!(fn->fn_flags&RTN_RTINFO)); | 999 | WARN_ON(fn->fn_flags & RTN_RTINFO); |
1000 | BUG_TRAP(!(fn->fn_flags&RTN_TL_ROOT)); | 1000 | WARN_ON(fn->fn_flags & RTN_TL_ROOT); |
1001 | BUG_TRAP(fn->leaf==NULL); | 1001 | WARN_ON(fn->leaf != NULL); |
1002 | 1002 | ||
1003 | children = 0; | 1003 | children = 0; |
1004 | child = NULL; | 1004 | child = NULL; |
@@ -1014,7 +1014,7 @@ static struct fib6_node *fib6_repair_tree(struct net *net, | |||
1014 | fn->leaf = fib6_find_prefix(net, fn); | 1014 | fn->leaf = fib6_find_prefix(net, fn); |
1015 | #if RT6_DEBUG >= 2 | 1015 | #if RT6_DEBUG >= 2 |
1016 | if (fn->leaf==NULL) { | 1016 | if (fn->leaf==NULL) { |
1017 | BUG_TRAP(fn->leaf); | 1017 | WARN_ON(!fn->leaf); |
1018 | fn->leaf = net->ipv6.ip6_null_entry; | 1018 | fn->leaf = net->ipv6.ip6_null_entry; |
1019 | } | 1019 | } |
1020 | #endif | 1020 | #endif |
@@ -1025,16 +1025,17 @@ static struct fib6_node *fib6_repair_tree(struct net *net, | |||
1025 | pn = fn->parent; | 1025 | pn = fn->parent; |
1026 | #ifdef CONFIG_IPV6_SUBTREES | 1026 | #ifdef CONFIG_IPV6_SUBTREES |
1027 | if (FIB6_SUBTREE(pn) == fn) { | 1027 | if (FIB6_SUBTREE(pn) == fn) { |
1028 | BUG_TRAP(fn->fn_flags&RTN_ROOT); | 1028 | WARN_ON(!(fn->fn_flags & RTN_ROOT)); |
1029 | FIB6_SUBTREE(pn) = NULL; | 1029 | FIB6_SUBTREE(pn) = NULL; |
1030 | nstate = FWS_L; | 1030 | nstate = FWS_L; |
1031 | } else { | 1031 | } else { |
1032 | BUG_TRAP(!(fn->fn_flags&RTN_ROOT)); | 1032 | WARN_ON(fn->fn_flags & RTN_ROOT); |
1033 | #endif | 1033 | #endif |
1034 | if (pn->right == fn) pn->right = child; | 1034 | if (pn->right == fn) pn->right = child; |
1035 | else if (pn->left == fn) pn->left = child; | 1035 | else if (pn->left == fn) pn->left = child; |
1036 | #if RT6_DEBUG >= 2 | 1036 | #if RT6_DEBUG >= 2 |
1037 | else BUG_TRAP(0); | 1037 | else |
1038 | WARN_ON(1); | ||
1038 | #endif | 1039 | #endif |
1039 | if (child) | 1040 | if (child) |
1040 | child->parent = pn; | 1041 | child->parent = pn; |
@@ -1154,14 +1155,14 @@ int fib6_del(struct rt6_info *rt, struct nl_info *info) | |||
1154 | 1155 | ||
1155 | #if RT6_DEBUG >= 2 | 1156 | #if RT6_DEBUG >= 2 |
1156 | if (rt->u.dst.obsolete>0) { | 1157 | if (rt->u.dst.obsolete>0) { |
1157 | BUG_TRAP(fn==NULL); | 1158 | WARN_ON(fn != NULL); |
1158 | return -ENOENT; | 1159 | return -ENOENT; |
1159 | } | 1160 | } |
1160 | #endif | 1161 | #endif |
1161 | if (fn == NULL || rt == net->ipv6.ip6_null_entry) | 1162 | if (fn == NULL || rt == net->ipv6.ip6_null_entry) |
1162 | return -ENOENT; | 1163 | return -ENOENT; |
1163 | 1164 | ||
1164 | BUG_TRAP(fn->fn_flags&RTN_RTINFO); | 1165 | WARN_ON(!(fn->fn_flags & RTN_RTINFO)); |
1165 | 1166 | ||
1166 | if (!(rt->rt6i_flags&RTF_CACHE)) { | 1167 | if (!(rt->rt6i_flags&RTF_CACHE)) { |
1167 | struct fib6_node *pn = fn; | 1168 | struct fib6_node *pn = fn; |
@@ -1266,7 +1267,7 @@ static int fib6_walk_continue(struct fib6_walker_t *w) | |||
1266 | w->node = pn; | 1267 | w->node = pn; |
1267 | #ifdef CONFIG_IPV6_SUBTREES | 1268 | #ifdef CONFIG_IPV6_SUBTREES |
1268 | if (FIB6_SUBTREE(pn) == fn) { | 1269 | if (FIB6_SUBTREE(pn) == fn) { |
1269 | BUG_TRAP(fn->fn_flags&RTN_ROOT); | 1270 | WARN_ON(!(fn->fn_flags & RTN_ROOT)); |
1270 | w->state = FWS_L; | 1271 | w->state = FWS_L; |
1271 | continue; | 1272 | continue; |
1272 | } | 1273 | } |
@@ -1281,7 +1282,7 @@ static int fib6_walk_continue(struct fib6_walker_t *w) | |||
1281 | continue; | 1282 | continue; |
1282 | } | 1283 | } |
1283 | #if RT6_DEBUG >= 2 | 1284 | #if RT6_DEBUG >= 2 |
1284 | BUG_TRAP(0); | 1285 | WARN_ON(1); |
1285 | #endif | 1286 | #endif |
1286 | } | 1287 | } |
1287 | } | 1288 | } |
@@ -1323,7 +1324,7 @@ static int fib6_clean_node(struct fib6_walker_t *w) | |||
1323 | } | 1324 | } |
1324 | return 0; | 1325 | return 0; |
1325 | } | 1326 | } |
1326 | BUG_TRAP(res==0); | 1327 | WARN_ON(res != 0); |
1327 | } | 1328 | } |
1328 | w->leaf = rt; | 1329 | w->leaf = rt; |
1329 | return 0; | 1330 | return 0; |
@@ -1447,27 +1448,23 @@ void fib6_run_gc(unsigned long expires, struct net *net) | |||
1447 | gc_args.timeout = expires ? (int)expires : | 1448 | gc_args.timeout = expires ? (int)expires : |
1448 | net->ipv6.sysctl.ip6_rt_gc_interval; | 1449 | net->ipv6.sysctl.ip6_rt_gc_interval; |
1449 | } else { | 1450 | } else { |
1450 | local_bh_disable(); | 1451 | if (!spin_trylock_bh(&fib6_gc_lock)) { |
1451 | if (!spin_trylock(&fib6_gc_lock)) { | 1452 | mod_timer(&net->ipv6.ip6_fib_timer, jiffies + HZ); |
1452 | mod_timer(net->ipv6.ip6_fib_timer, jiffies + HZ); | ||
1453 | local_bh_enable(); | ||
1454 | return; | 1453 | return; |
1455 | } | 1454 | } |
1456 | gc_args.timeout = net->ipv6.sysctl.ip6_rt_gc_interval; | 1455 | gc_args.timeout = net->ipv6.sysctl.ip6_rt_gc_interval; |
1457 | } | 1456 | } |
1458 | gc_args.more = 0; | ||
1459 | 1457 | ||
1460 | icmp6_dst_gc(&gc_args.more); | 1458 | gc_args.more = icmp6_dst_gc(); |
1461 | 1459 | ||
1462 | fib6_clean_all(net, fib6_age, 0, NULL); | 1460 | fib6_clean_all(net, fib6_age, 0, NULL); |
1463 | 1461 | ||
1464 | if (gc_args.more) | 1462 | if (gc_args.more) |
1465 | mod_timer(net->ipv6.ip6_fib_timer, jiffies + | 1463 | mod_timer(&net->ipv6.ip6_fib_timer, |
1466 | net->ipv6.sysctl.ip6_rt_gc_interval); | 1464 | round_jiffies(jiffies |
1467 | else { | 1465 | + net->ipv6.sysctl.ip6_rt_gc_interval)); |
1468 | del_timer(net->ipv6.ip6_fib_timer); | 1466 | else |
1469 | net->ipv6.ip6_fib_timer->expires = 0; | 1467 | del_timer(&net->ipv6.ip6_fib_timer); |
1470 | } | ||
1471 | spin_unlock_bh(&fib6_gc_lock); | 1468 | spin_unlock_bh(&fib6_gc_lock); |
1472 | } | 1469 | } |
1473 | 1470 | ||
@@ -1478,24 +1475,15 @@ static void fib6_gc_timer_cb(unsigned long arg) | |||
1478 | 1475 | ||
1479 | static int fib6_net_init(struct net *net) | 1476 | static int fib6_net_init(struct net *net) |
1480 | { | 1477 | { |
1481 | int ret; | 1478 | setup_timer(&net->ipv6.ip6_fib_timer, fib6_gc_timer_cb, (unsigned long)net); |
1482 | struct timer_list *timer; | ||
1483 | |||
1484 | ret = -ENOMEM; | ||
1485 | timer = kzalloc(sizeof(*timer), GFP_KERNEL); | ||
1486 | if (!timer) | ||
1487 | goto out; | ||
1488 | |||
1489 | setup_timer(timer, fib6_gc_timer_cb, (unsigned long)net); | ||
1490 | net->ipv6.ip6_fib_timer = timer; | ||
1491 | 1479 | ||
1492 | net->ipv6.rt6_stats = kzalloc(sizeof(*net->ipv6.rt6_stats), GFP_KERNEL); | 1480 | net->ipv6.rt6_stats = kzalloc(sizeof(*net->ipv6.rt6_stats), GFP_KERNEL); |
1493 | if (!net->ipv6.rt6_stats) | 1481 | if (!net->ipv6.rt6_stats) |
1494 | goto out_timer; | 1482 | goto out_timer; |
1495 | 1483 | ||
1496 | net->ipv6.fib_table_hash = | 1484 | net->ipv6.fib_table_hash = kcalloc(FIB_TABLE_HASHSZ, |
1497 | kzalloc(sizeof(*net->ipv6.fib_table_hash)*FIB_TABLE_HASHSZ, | 1485 | sizeof(*net->ipv6.fib_table_hash), |
1498 | GFP_KERNEL); | 1486 | GFP_KERNEL); |
1499 | if (!net->ipv6.fib_table_hash) | 1487 | if (!net->ipv6.fib_table_hash) |
1500 | goto out_rt6_stats; | 1488 | goto out_rt6_stats; |
1501 | 1489 | ||
@@ -1521,9 +1509,7 @@ static int fib6_net_init(struct net *net) | |||
1521 | #endif | 1509 | #endif |
1522 | fib6_tables_init(net); | 1510 | fib6_tables_init(net); |
1523 | 1511 | ||
1524 | ret = 0; | 1512 | return 0; |
1525 | out: | ||
1526 | return ret; | ||
1527 | 1513 | ||
1528 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES | 1514 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES |
1529 | out_fib6_main_tbl: | 1515 | out_fib6_main_tbl: |
@@ -1534,15 +1520,14 @@ out_fib_table_hash: | |||
1534 | out_rt6_stats: | 1520 | out_rt6_stats: |
1535 | kfree(net->ipv6.rt6_stats); | 1521 | kfree(net->ipv6.rt6_stats); |
1536 | out_timer: | 1522 | out_timer: |
1537 | kfree(timer); | 1523 | return -ENOMEM; |
1538 | goto out; | ||
1539 | } | 1524 | } |
1540 | 1525 | ||
1541 | static void fib6_net_exit(struct net *net) | 1526 | static void fib6_net_exit(struct net *net) |
1542 | { | 1527 | { |
1543 | rt6_ifdown(net, NULL); | 1528 | rt6_ifdown(net, NULL); |
1544 | del_timer_sync(net->ipv6.ip6_fib_timer); | 1529 | del_timer_sync(&net->ipv6.ip6_fib_timer); |
1545 | kfree(net->ipv6.ip6_fib_timer); | 1530 | |
1546 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES | 1531 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES |
1547 | kfree(net->ipv6.fib6_local_tbl); | 1532 | kfree(net->ipv6.fib6_local_tbl); |
1548 | #endif | 1533 | #endif |
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 6407c64ea4a5..6811901e6b1e 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c | |||
@@ -116,7 +116,7 @@ static int ip6_dev_loopback_xmit(struct sk_buff *newskb) | |||
116 | __skb_pull(newskb, skb_network_offset(newskb)); | 116 | __skb_pull(newskb, skb_network_offset(newskb)); |
117 | newskb->pkt_type = PACKET_LOOPBACK; | 117 | newskb->pkt_type = PACKET_LOOPBACK; |
118 | newskb->ip_summed = CHECKSUM_UNNECESSARY; | 118 | newskb->ip_summed = CHECKSUM_UNNECESSARY; |
119 | BUG_TRAP(newskb->dst); | 119 | WARN_ON(!newskb->dst); |
120 | 120 | ||
121 | netif_rx(newskb); | 121 | netif_rx(newskb); |
122 | return 0; | 122 | return 0; |
diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c index ee6de425ce6b..0cfcea42153a 100644 --- a/net/ipv6/ipcomp6.c +++ b/net/ipv6/ipcomp6.c | |||
@@ -50,125 +50,6 @@ | |||
50 | #include <linux/icmpv6.h> | 50 | #include <linux/icmpv6.h> |
51 | #include <linux/mutex.h> | 51 | #include <linux/mutex.h> |
52 | 52 | ||
53 | struct ipcomp6_tfms { | ||
54 | struct list_head list; | ||
55 | struct crypto_comp **tfms; | ||
56 | int users; | ||
57 | }; | ||
58 | |||
59 | static DEFINE_MUTEX(ipcomp6_resource_mutex); | ||
60 | static void **ipcomp6_scratches; | ||
61 | static int ipcomp6_scratch_users; | ||
62 | static LIST_HEAD(ipcomp6_tfms_list); | ||
63 | |||
64 | static int ipcomp6_input(struct xfrm_state *x, struct sk_buff *skb) | ||
65 | { | ||
66 | int nexthdr; | ||
67 | int err = -ENOMEM; | ||
68 | struct ip_comp_hdr *ipch; | ||
69 | int plen, dlen; | ||
70 | struct ipcomp_data *ipcd = x->data; | ||
71 | u8 *start, *scratch; | ||
72 | struct crypto_comp *tfm; | ||
73 | int cpu; | ||
74 | |||
75 | if (skb_linearize_cow(skb)) | ||
76 | goto out; | ||
77 | |||
78 | skb->ip_summed = CHECKSUM_NONE; | ||
79 | |||
80 | /* Remove ipcomp header and decompress original payload */ | ||
81 | ipch = (void *)skb->data; | ||
82 | nexthdr = ipch->nexthdr; | ||
83 | |||
84 | skb->transport_header = skb->network_header + sizeof(*ipch); | ||
85 | __skb_pull(skb, sizeof(*ipch)); | ||
86 | |||
87 | /* decompression */ | ||
88 | plen = skb->len; | ||
89 | dlen = IPCOMP_SCRATCH_SIZE; | ||
90 | start = skb->data; | ||
91 | |||
92 | cpu = get_cpu(); | ||
93 | scratch = *per_cpu_ptr(ipcomp6_scratches, cpu); | ||
94 | tfm = *per_cpu_ptr(ipcd->tfms, cpu); | ||
95 | |||
96 | err = crypto_comp_decompress(tfm, start, plen, scratch, &dlen); | ||
97 | if (err) | ||
98 | goto out_put_cpu; | ||
99 | |||
100 | if (dlen < (plen + sizeof(*ipch))) { | ||
101 | err = -EINVAL; | ||
102 | goto out_put_cpu; | ||
103 | } | ||
104 | |||
105 | err = pskb_expand_head(skb, 0, dlen - plen, GFP_ATOMIC); | ||
106 | if (err) { | ||
107 | goto out_put_cpu; | ||
108 | } | ||
109 | |||
110 | skb->truesize += dlen - plen; | ||
111 | __skb_put(skb, dlen - plen); | ||
112 | skb_copy_to_linear_data(skb, scratch, dlen); | ||
113 | err = nexthdr; | ||
114 | |||
115 | out_put_cpu: | ||
116 | put_cpu(); | ||
117 | out: | ||
118 | return err; | ||
119 | } | ||
120 | |||
121 | static int ipcomp6_output(struct xfrm_state *x, struct sk_buff *skb) | ||
122 | { | ||
123 | int err; | ||
124 | struct ip_comp_hdr *ipch; | ||
125 | struct ipcomp_data *ipcd = x->data; | ||
126 | int plen, dlen; | ||
127 | u8 *start, *scratch; | ||
128 | struct crypto_comp *tfm; | ||
129 | int cpu; | ||
130 | |||
131 | /* check whether datagram len is larger than threshold */ | ||
132 | if (skb->len < ipcd->threshold) { | ||
133 | goto out_ok; | ||
134 | } | ||
135 | |||
136 | if (skb_linearize_cow(skb)) | ||
137 | goto out_ok; | ||
138 | |||
139 | /* compression */ | ||
140 | plen = skb->len; | ||
141 | dlen = IPCOMP_SCRATCH_SIZE; | ||
142 | start = skb->data; | ||
143 | |||
144 | cpu = get_cpu(); | ||
145 | scratch = *per_cpu_ptr(ipcomp6_scratches, cpu); | ||
146 | tfm = *per_cpu_ptr(ipcd->tfms, cpu); | ||
147 | |||
148 | local_bh_disable(); | ||
149 | err = crypto_comp_compress(tfm, start, plen, scratch, &dlen); | ||
150 | local_bh_enable(); | ||
151 | if (err || (dlen + sizeof(*ipch)) >= plen) { | ||
152 | put_cpu(); | ||
153 | goto out_ok; | ||
154 | } | ||
155 | memcpy(start + sizeof(struct ip_comp_hdr), scratch, dlen); | ||
156 | put_cpu(); | ||
157 | pskb_trim(skb, dlen + sizeof(struct ip_comp_hdr)); | ||
158 | |||
159 | /* insert ipcomp header and replace datagram */ | ||
160 | ipch = ip_comp_hdr(skb); | ||
161 | ipch->nexthdr = *skb_mac_header(skb); | ||
162 | ipch->flags = 0; | ||
163 | ipch->cpi = htons((u16 )ntohl(x->id.spi)); | ||
164 | *skb_mac_header(skb) = IPPROTO_COMP; | ||
165 | |||
166 | out_ok: | ||
167 | skb_push(skb, -skb_network_offset(skb)); | ||
168 | |||
169 | return 0; | ||
170 | } | ||
171 | |||
172 | static void ipcomp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | 53 | static void ipcomp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, |
173 | int type, int code, int offset, __be32 info) | 54 | int type, int code, int offset, __be32 info) |
174 | { | 55 | { |
@@ -251,161 +132,12 @@ out: | |||
251 | return err; | 132 | return err; |
252 | } | 133 | } |
253 | 134 | ||
254 | static void ipcomp6_free_scratches(void) | ||
255 | { | ||
256 | int i; | ||
257 | void **scratches; | ||
258 | |||
259 | if (--ipcomp6_scratch_users) | ||
260 | return; | ||
261 | |||
262 | scratches = ipcomp6_scratches; | ||
263 | if (!scratches) | ||
264 | return; | ||
265 | |||
266 | for_each_possible_cpu(i) { | ||
267 | void *scratch = *per_cpu_ptr(scratches, i); | ||
268 | |||
269 | vfree(scratch); | ||
270 | } | ||
271 | |||
272 | free_percpu(scratches); | ||
273 | } | ||
274 | |||
275 | static void **ipcomp6_alloc_scratches(void) | ||
276 | { | ||
277 | int i; | ||
278 | void **scratches; | ||
279 | |||
280 | if (ipcomp6_scratch_users++) | ||
281 | return ipcomp6_scratches; | ||
282 | |||
283 | scratches = alloc_percpu(void *); | ||
284 | if (!scratches) | ||
285 | return NULL; | ||
286 | |||
287 | ipcomp6_scratches = scratches; | ||
288 | |||
289 | for_each_possible_cpu(i) { | ||
290 | void *scratch = vmalloc(IPCOMP_SCRATCH_SIZE); | ||
291 | if (!scratch) | ||
292 | return NULL; | ||
293 | *per_cpu_ptr(scratches, i) = scratch; | ||
294 | } | ||
295 | |||
296 | return scratches; | ||
297 | } | ||
298 | |||
299 | static void ipcomp6_free_tfms(struct crypto_comp **tfms) | ||
300 | { | ||
301 | struct ipcomp6_tfms *pos; | ||
302 | int cpu; | ||
303 | |||
304 | list_for_each_entry(pos, &ipcomp6_tfms_list, list) { | ||
305 | if (pos->tfms == tfms) | ||
306 | break; | ||
307 | } | ||
308 | |||
309 | BUG_TRAP(pos); | ||
310 | |||
311 | if (--pos->users) | ||
312 | return; | ||
313 | |||
314 | list_del(&pos->list); | ||
315 | kfree(pos); | ||
316 | |||
317 | if (!tfms) | ||
318 | return; | ||
319 | |||
320 | for_each_possible_cpu(cpu) { | ||
321 | struct crypto_comp *tfm = *per_cpu_ptr(tfms, cpu); | ||
322 | crypto_free_comp(tfm); | ||
323 | } | ||
324 | free_percpu(tfms); | ||
325 | } | ||
326 | |||
327 | static struct crypto_comp **ipcomp6_alloc_tfms(const char *alg_name) | ||
328 | { | ||
329 | struct ipcomp6_tfms *pos; | ||
330 | struct crypto_comp **tfms; | ||
331 | int cpu; | ||
332 | |||
333 | /* This can be any valid CPU ID so we don't need locking. */ | ||
334 | cpu = raw_smp_processor_id(); | ||
335 | |||
336 | list_for_each_entry(pos, &ipcomp6_tfms_list, list) { | ||
337 | struct crypto_comp *tfm; | ||
338 | |||
339 | tfms = pos->tfms; | ||
340 | tfm = *per_cpu_ptr(tfms, cpu); | ||
341 | |||
342 | if (!strcmp(crypto_comp_name(tfm), alg_name)) { | ||
343 | pos->users++; | ||
344 | return tfms; | ||
345 | } | ||
346 | } | ||
347 | |||
348 | pos = kmalloc(sizeof(*pos), GFP_KERNEL); | ||
349 | if (!pos) | ||
350 | return NULL; | ||
351 | |||
352 | pos->users = 1; | ||
353 | INIT_LIST_HEAD(&pos->list); | ||
354 | list_add(&pos->list, &ipcomp6_tfms_list); | ||
355 | |||
356 | pos->tfms = tfms = alloc_percpu(struct crypto_comp *); | ||
357 | if (!tfms) | ||
358 | goto error; | ||
359 | |||
360 | for_each_possible_cpu(cpu) { | ||
361 | struct crypto_comp *tfm = crypto_alloc_comp(alg_name, 0, | ||
362 | CRYPTO_ALG_ASYNC); | ||
363 | if (IS_ERR(tfm)) | ||
364 | goto error; | ||
365 | *per_cpu_ptr(tfms, cpu) = tfm; | ||
366 | } | ||
367 | |||
368 | return tfms; | ||
369 | |||
370 | error: | ||
371 | ipcomp6_free_tfms(tfms); | ||
372 | return NULL; | ||
373 | } | ||
374 | |||
375 | static void ipcomp6_free_data(struct ipcomp_data *ipcd) | ||
376 | { | ||
377 | if (ipcd->tfms) | ||
378 | ipcomp6_free_tfms(ipcd->tfms); | ||
379 | ipcomp6_free_scratches(); | ||
380 | } | ||
381 | |||
382 | static void ipcomp6_destroy(struct xfrm_state *x) | ||
383 | { | ||
384 | struct ipcomp_data *ipcd = x->data; | ||
385 | if (!ipcd) | ||
386 | return; | ||
387 | xfrm_state_delete_tunnel(x); | ||
388 | mutex_lock(&ipcomp6_resource_mutex); | ||
389 | ipcomp6_free_data(ipcd); | ||
390 | mutex_unlock(&ipcomp6_resource_mutex); | ||
391 | kfree(ipcd); | ||
392 | |||
393 | xfrm6_tunnel_free_spi((xfrm_address_t *)&x->props.saddr); | ||
394 | } | ||
395 | |||
396 | static int ipcomp6_init_state(struct xfrm_state *x) | 135 | static int ipcomp6_init_state(struct xfrm_state *x) |
397 | { | 136 | { |
398 | int err; | 137 | int err; |
399 | struct ipcomp_data *ipcd; | 138 | struct ipcomp_data *ipcd; |
400 | struct xfrm_algo_desc *calg_desc; | 139 | struct xfrm_algo_desc *calg_desc; |
401 | 140 | ||
402 | err = -EINVAL; | ||
403 | if (!x->calg) | ||
404 | goto out; | ||
405 | |||
406 | if (x->encap) | ||
407 | goto out; | ||
408 | |||
409 | x->props.header_len = 0; | 141 | x->props.header_len = 0; |
410 | switch (x->props.mode) { | 142 | switch (x->props.mode) { |
411 | case XFRM_MODE_TRANSPORT: | 143 | case XFRM_MODE_TRANSPORT: |
@@ -417,39 +149,21 @@ static int ipcomp6_init_state(struct xfrm_state *x) | |||
417 | goto out; | 149 | goto out; |
418 | } | 150 | } |
419 | 151 | ||
420 | err = -ENOMEM; | 152 | err = ipcomp_init_state(x); |
421 | ipcd = kzalloc(sizeof(*ipcd), GFP_KERNEL); | 153 | if (err) |
422 | if (!ipcd) | ||
423 | goto out; | 154 | goto out; |
424 | 155 | ||
425 | mutex_lock(&ipcomp6_resource_mutex); | ||
426 | if (!ipcomp6_alloc_scratches()) | ||
427 | goto error; | ||
428 | |||
429 | ipcd->tfms = ipcomp6_alloc_tfms(x->calg->alg_name); | ||
430 | if (!ipcd->tfms) | ||
431 | goto error; | ||
432 | mutex_unlock(&ipcomp6_resource_mutex); | ||
433 | |||
434 | if (x->props.mode == XFRM_MODE_TUNNEL) { | 156 | if (x->props.mode == XFRM_MODE_TUNNEL) { |
435 | err = ipcomp6_tunnel_attach(x); | 157 | err = ipcomp6_tunnel_attach(x); |
436 | if (err) | 158 | if (err) |
437 | goto error_tunnel; | 159 | goto error_tunnel; |
438 | } | 160 | } |
439 | 161 | ||
440 | calg_desc = xfrm_calg_get_byname(x->calg->alg_name, 0); | ||
441 | BUG_ON(!calg_desc); | ||
442 | ipcd->threshold = calg_desc->uinfo.comp.threshold; | ||
443 | x->data = ipcd; | ||
444 | err = 0; | 162 | err = 0; |
445 | out: | 163 | out: |
446 | return err; | 164 | return err; |
447 | error_tunnel: | 165 | error_tunnel: |
448 | mutex_lock(&ipcomp6_resource_mutex); | 166 | ipcomp_destroy(x); |
449 | error: | ||
450 | ipcomp6_free_data(ipcd); | ||
451 | mutex_unlock(&ipcomp6_resource_mutex); | ||
452 | kfree(ipcd); | ||
453 | 167 | ||
454 | goto out; | 168 | goto out; |
455 | } | 169 | } |
@@ -460,9 +174,9 @@ static const struct xfrm_type ipcomp6_type = | |||
460 | .owner = THIS_MODULE, | 174 | .owner = THIS_MODULE, |
461 | .proto = IPPROTO_COMP, | 175 | .proto = IPPROTO_COMP, |
462 | .init_state = ipcomp6_init_state, | 176 | .init_state = ipcomp6_init_state, |
463 | .destructor = ipcomp6_destroy, | 177 | .destructor = ipcomp_destroy, |
464 | .input = ipcomp6_input, | 178 | .input = ipcomp_input, |
465 | .output = ipcomp6_output, | 179 | .output = ipcomp_output, |
466 | .hdr_offset = xfrm6_find_1stfragopt, | 180 | .hdr_offset = xfrm6_find_1stfragopt, |
467 | }; | 181 | }; |
468 | 182 | ||
diff --git a/net/ipv6/mip6.c b/net/ipv6/mip6.c index ad1cc5bbf977..31295c8f6196 100644 --- a/net/ipv6/mip6.c +++ b/net/ipv6/mip6.c | |||
@@ -164,8 +164,8 @@ static int mip6_destopt_output(struct xfrm_state *x, struct sk_buff *skb) | |||
164 | calc_padlen(sizeof(*dstopt), 6)); | 164 | calc_padlen(sizeof(*dstopt), 6)); |
165 | 165 | ||
166 | hao->type = IPV6_TLV_HAO; | 166 | hao->type = IPV6_TLV_HAO; |
167 | BUILD_BUG_ON(sizeof(*hao) != 18); | ||
167 | hao->length = sizeof(*hao) - 2; | 168 | hao->length = sizeof(*hao) - 2; |
168 | BUG_TRAP(hao->length == 16); | ||
169 | 169 | ||
170 | len = ((char *)hao - (char *)dstopt) + sizeof(*hao); | 170 | len = ((char *)hao - (char *)dstopt) + sizeof(*hao); |
171 | 171 | ||
@@ -174,7 +174,7 @@ static int mip6_destopt_output(struct xfrm_state *x, struct sk_buff *skb) | |||
174 | memcpy(&iph->saddr, x->coaddr, sizeof(iph->saddr)); | 174 | memcpy(&iph->saddr, x->coaddr, sizeof(iph->saddr)); |
175 | spin_unlock_bh(&x->lock); | 175 | spin_unlock_bh(&x->lock); |
176 | 176 | ||
177 | BUG_TRAP(len == x->props.header_len); | 177 | WARN_ON(len != x->props.header_len); |
178 | dstopt->hdrlen = (x->props.header_len >> 3) - 1; | 178 | dstopt->hdrlen = (x->props.header_len >> 3) - 1; |
179 | 179 | ||
180 | return 0; | 180 | return 0; |
@@ -317,7 +317,7 @@ static int mip6_destopt_init_state(struct xfrm_state *x) | |||
317 | x->props.header_len = sizeof(struct ipv6_destopt_hdr) + | 317 | x->props.header_len = sizeof(struct ipv6_destopt_hdr) + |
318 | calc_padlen(sizeof(struct ipv6_destopt_hdr), 6) + | 318 | calc_padlen(sizeof(struct ipv6_destopt_hdr), 6) + |
319 | sizeof(struct ipv6_destopt_hao); | 319 | sizeof(struct ipv6_destopt_hao); |
320 | BUG_TRAP(x->props.header_len == 24); | 320 | WARN_ON(x->props.header_len != 24); |
321 | 321 | ||
322 | return 0; | 322 | return 0; |
323 | } | 323 | } |
@@ -380,7 +380,7 @@ static int mip6_rthdr_output(struct xfrm_state *x, struct sk_buff *skb) | |||
380 | rt2->rt_hdr.segments_left = 1; | 380 | rt2->rt_hdr.segments_left = 1; |
381 | memset(&rt2->reserved, 0, sizeof(rt2->reserved)); | 381 | memset(&rt2->reserved, 0, sizeof(rt2->reserved)); |
382 | 382 | ||
383 | BUG_TRAP(rt2->rt_hdr.hdrlen == 2); | 383 | WARN_ON(rt2->rt_hdr.hdrlen != 2); |
384 | 384 | ||
385 | memcpy(&rt2->addr, &iph->daddr, sizeof(rt2->addr)); | 385 | memcpy(&rt2->addr, &iph->daddr, sizeof(rt2->addr)); |
386 | spin_lock_bh(&x->lock); | 386 | spin_lock_bh(&x->lock); |
diff --git a/net/ipv6/netfilter/Kconfig b/net/ipv6/netfilter/Kconfig index 689dec899c57..0cfcce7b18d8 100644 --- a/net/ipv6/netfilter/Kconfig +++ b/net/ipv6/netfilter/Kconfig | |||
@@ -213,7 +213,7 @@ config IP6_NF_SECURITY | |||
213 | tristate "Security table" | 213 | tristate "Security table" |
214 | depends on IP6_NF_IPTABLES | 214 | depends on IP6_NF_IPTABLES |
215 | depends on SECURITY | 215 | depends on SECURITY |
216 | default m if NETFILTER_ADVANCED=n | 216 | depends on NETFILTER_ADVANCED |
217 | help | 217 | help |
218 | This option adds a `security' table to iptables, for use | 218 | This option adds a `security' table to iptables, for use |
219 | with Mandatory Access Control (MAC) policy. | 219 | with Mandatory Access Control (MAC) policy. |
diff --git a/net/ipv6/netfilter/ip6table_security.c b/net/ipv6/netfilter/ip6table_security.c index a07abee30497..6e7131036bc6 100644 --- a/net/ipv6/netfilter/ip6table_security.c +++ b/net/ipv6/netfilter/ip6table_security.c | |||
@@ -31,7 +31,7 @@ static struct | |||
31 | struct ip6t_replace repl; | 31 | struct ip6t_replace repl; |
32 | struct ip6t_standard entries[3]; | 32 | struct ip6t_standard entries[3]; |
33 | struct ip6t_error term; | 33 | struct ip6t_error term; |
34 | } initial_table __initdata = { | 34 | } initial_table __net_initdata = { |
35 | .repl = { | 35 | .repl = { |
36 | .name = "security", | 36 | .name = "security", |
37 | .valid_hooks = SECURITY_VALID_HOOKS, | 37 | .valid_hooks = SECURITY_VALID_HOOKS, |
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c index cf20bc4fd60d..52d06dd4b817 100644 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c | |||
@@ -416,8 +416,8 @@ nf_ct_frag6_reasm(struct nf_ct_frag6_queue *fq, struct net_device *dev) | |||
416 | 416 | ||
417 | fq_kill(fq); | 417 | fq_kill(fq); |
418 | 418 | ||
419 | BUG_TRAP(head != NULL); | 419 | WARN_ON(head == NULL); |
420 | BUG_TRAP(NFCT_FRAG6_CB(head)->offset == 0); | 420 | WARN_ON(NFCT_FRAG6_CB(head)->offset != 0); |
421 | 421 | ||
422 | /* Unfragmented part is taken from the first segment. */ | 422 | /* Unfragmented part is taken from the first segment. */ |
423 | payload_len = ((head->data - skb_network_header(head)) - | 423 | payload_len = ((head->data - skb_network_header(head)) - |
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index 6ab957ec2dd6..89184b576e23 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c | |||
@@ -473,8 +473,8 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev, | |||
473 | fq->q.fragments = head; | 473 | fq->q.fragments = head; |
474 | } | 474 | } |
475 | 475 | ||
476 | BUG_TRAP(head != NULL); | 476 | WARN_ON(head == NULL); |
477 | BUG_TRAP(FRAG6_CB(head)->offset == 0); | 477 | WARN_ON(FRAG6_CB(head)->offset != 0); |
478 | 478 | ||
479 | /* Unfragmented part is taken from the first segment. */ | 479 | /* Unfragmented part is taken from the first segment. */ |
480 | payload_len = ((head->data - skb_network_header(head)) - | 480 | payload_len = ((head->data - skb_network_header(head)) - |
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 615b328de251..86540b24b27c 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -978,13 +978,12 @@ out: | |||
978 | return &rt->u.dst; | 978 | return &rt->u.dst; |
979 | } | 979 | } |
980 | 980 | ||
981 | int icmp6_dst_gc(int *more) | 981 | int icmp6_dst_gc(void) |
982 | { | 982 | { |
983 | struct dst_entry *dst, *next, **pprev; | 983 | struct dst_entry *dst, *next, **pprev; |
984 | int freed; | 984 | int more = 0; |
985 | 985 | ||
986 | next = NULL; | 986 | next = NULL; |
987 | freed = 0; | ||
988 | 987 | ||
989 | spin_lock_bh(&icmp6_dst_lock); | 988 | spin_lock_bh(&icmp6_dst_lock); |
990 | pprev = &icmp6_dst_gc_list; | 989 | pprev = &icmp6_dst_gc_list; |
@@ -993,16 +992,15 @@ int icmp6_dst_gc(int *more) | |||
993 | if (!atomic_read(&dst->__refcnt)) { | 992 | if (!atomic_read(&dst->__refcnt)) { |
994 | *pprev = dst->next; | 993 | *pprev = dst->next; |
995 | dst_free(dst); | 994 | dst_free(dst); |
996 | freed++; | ||
997 | } else { | 995 | } else { |
998 | pprev = &dst->next; | 996 | pprev = &dst->next; |
999 | (*more)++; | 997 | ++more; |
1000 | } | 998 | } |
1001 | } | 999 | } |
1002 | 1000 | ||
1003 | spin_unlock_bh(&icmp6_dst_lock); | 1001 | spin_unlock_bh(&icmp6_dst_lock); |
1004 | 1002 | ||
1005 | return freed; | 1003 | return more; |
1006 | } | 1004 | } |
1007 | 1005 | ||
1008 | static int ip6_dst_gc(struct dst_ops *ops) | 1006 | static int ip6_dst_gc(struct dst_ops *ops) |
diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c index 6a68eeb7bbf8..a46badd1082d 100644 --- a/net/ipv6/syncookies.c +++ b/net/ipv6/syncookies.c | |||
@@ -223,6 +223,7 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb) | |||
223 | 223 | ||
224 | req->expires = 0UL; | 224 | req->expires = 0UL; |
225 | req->retrans = 0; | 225 | req->retrans = 0; |
226 | ireq->ecn_ok = 0; | ||
226 | ireq->snd_wscale = tcp_opt.snd_wscale; | 227 | ireq->snd_wscale = tcp_opt.snd_wscale; |
227 | ireq->rcv_wscale = tcp_opt.rcv_wscale; | 228 | ireq->rcv_wscale = tcp_opt.rcv_wscale; |
228 | ireq->sack_ok = tcp_opt.sack_ok; | 229 | ireq->sack_ok = tcp_opt.sack_ok; |
diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c index 5c99274558bf..e6dfaeac6be3 100644 --- a/net/ipv6/sysctl_net_ipv6.c +++ b/net/ipv6/sysctl_net_ipv6.c | |||
@@ -150,3 +150,19 @@ void ipv6_sysctl_unregister(void) | |||
150 | unregister_net_sysctl_table(ip6_header); | 150 | unregister_net_sysctl_table(ip6_header); |
151 | unregister_pernet_subsys(&ipv6_sysctl_net_ops); | 151 | unregister_pernet_subsys(&ipv6_sysctl_net_ops); |
152 | } | 152 | } |
153 | |||
154 | static struct ctl_table_header *ip6_base; | ||
155 | |||
156 | int ipv6_static_sysctl_register(void) | ||
157 | { | ||
158 | static struct ctl_table empty[1]; | ||
159 | ip6_base = register_net_sysctl_rotable(net_ipv6_ctl_path, empty); | ||
160 | if (ip6_base == NULL) | ||
161 | return -ENOMEM; | ||
162 | return 0; | ||
163 | } | ||
164 | |||
165 | void ipv6_static_sysctl_unregister(void) | ||
166 | { | ||
167 | unregister_net_sysctl_table(ip6_base); | ||
168 | } | ||
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index ae45f9835014..cff778b23a7f 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c | |||
@@ -421,7 +421,7 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | |||
421 | /* ICMPs are not backlogged, hence we cannot get | 421 | /* ICMPs are not backlogged, hence we cannot get |
422 | * an established socket here. | 422 | * an established socket here. |
423 | */ | 423 | */ |
424 | BUG_TRAP(req->sk == NULL); | 424 | WARN_ON(req->sk != NULL); |
425 | 425 | ||
426 | if (seq != tcp_rsk(req)->snt_isn) { | 426 | if (seq != tcp_rsk(req)->snt_isn) { |
427 | NET_INC_STATS_BH(net, LINUX_MIB_OUTOFWINDOWICMPS); | 427 | NET_INC_STATS_BH(net, LINUX_MIB_OUTOFWINDOWICMPS); |
diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c index 265b1b289a32..705959b31e24 100644 --- a/net/iucv/iucv.c +++ b/net/iucv/iucv.c | |||
@@ -497,7 +497,7 @@ static void iucv_setmask_up(void) | |||
497 | /* Disable all cpu but the first in cpu_irq_cpumask. */ | 497 | /* Disable all cpu but the first in cpu_irq_cpumask. */ |
498 | cpumask = iucv_irq_cpumask; | 498 | cpumask = iucv_irq_cpumask; |
499 | cpu_clear(first_cpu(iucv_irq_cpumask), cpumask); | 499 | cpu_clear(first_cpu(iucv_irq_cpumask), cpumask); |
500 | for_each_cpu_mask(cpu, cpumask) | 500 | for_each_cpu_mask_nr(cpu, cpumask) |
501 | smp_call_function_single(cpu, iucv_block_cpu, NULL, 1); | 501 | smp_call_function_single(cpu, iucv_block_cpu, NULL, 1); |
502 | } | 502 | } |
503 | 503 | ||
diff --git a/net/key/af_key.c b/net/key/af_key.c index f0fc46c8038d..d628df97e02e 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c | |||
@@ -96,8 +96,8 @@ static void pfkey_sock_destruct(struct sock *sk) | |||
96 | return; | 96 | return; |
97 | } | 97 | } |
98 | 98 | ||
99 | BUG_TRAP(!atomic_read(&sk->sk_rmem_alloc)); | 99 | WARN_ON(atomic_read(&sk->sk_rmem_alloc)); |
100 | BUG_TRAP(!atomic_read(&sk->sk_wmem_alloc)); | 100 | WARN_ON(atomic_read(&sk->sk_wmem_alloc)); |
101 | 101 | ||
102 | atomic_dec(&pfkey_socks_nr); | 102 | atomic_dec(&pfkey_socks_nr); |
103 | } | 103 | } |
diff --git a/net/netfilter/nf_conntrack_extend.c b/net/netfilter/nf_conntrack_extend.c index 3469bc71a385..4b2c769d555f 100644 --- a/net/netfilter/nf_conntrack_extend.c +++ b/net/netfilter/nf_conntrack_extend.c | |||
@@ -95,7 +95,7 @@ void *__nf_ct_ext_add(struct nf_conn *ct, enum nf_ct_ext_id id, gfp_t gfp) | |||
95 | newlen = newoff + t->len; | 95 | newlen = newoff + t->len; |
96 | rcu_read_unlock(); | 96 | rcu_read_unlock(); |
97 | 97 | ||
98 | new = krealloc(ct->ext, newlen, gfp); | 98 | new = __krealloc(ct->ext, newlen, gfp); |
99 | if (!new) | 99 | if (!new) |
100 | return NULL; | 100 | return NULL; |
101 | 101 | ||
@@ -115,10 +115,10 @@ void *__nf_ct_ext_add(struct nf_conn *ct, enum nf_ct_ext_id id, gfp_t gfp) | |||
115 | ct->ext = new; | 115 | ct->ext = new; |
116 | } | 116 | } |
117 | 117 | ||
118 | ct->ext->offset[id] = newoff; | 118 | new->offset[id] = newoff; |
119 | ct->ext->len = newlen; | 119 | new->len = newlen; |
120 | memset((void *)ct->ext + newoff, 0, newlen - newoff); | 120 | memset((void *)new + newoff, 0, newlen - newoff); |
121 | return (void *)ct->ext + newoff; | 121 | return (void *)new + newoff; |
122 | } | 122 | } |
123 | EXPORT_SYMBOL(__nf_ct_ext_add); | 123 | EXPORT_SYMBOL(__nf_ct_ext_add); |
124 | 124 | ||
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 98bfe277eab2..b0eacc0007cc 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c | |||
@@ -158,9 +158,10 @@ static void netlink_sock_destruct(struct sock *sk) | |||
158 | printk(KERN_ERR "Freeing alive netlink socket %p\n", sk); | 158 | printk(KERN_ERR "Freeing alive netlink socket %p\n", sk); |
159 | return; | 159 | return; |
160 | } | 160 | } |
161 | BUG_TRAP(!atomic_read(&sk->sk_rmem_alloc)); | 161 | |
162 | BUG_TRAP(!atomic_read(&sk->sk_wmem_alloc)); | 162 | WARN_ON(atomic_read(&sk->sk_rmem_alloc)); |
163 | BUG_TRAP(!nlk_sk(sk)->groups); | 163 | WARN_ON(atomic_read(&sk->sk_wmem_alloc)); |
164 | WARN_ON(nlk_sk(sk)->groups); | ||
164 | } | 165 | } |
165 | 166 | ||
166 | /* This lock without WQ_FLAG_EXCLUSIVE is good on UP and it is _very_ bad on | 167 | /* This lock without WQ_FLAG_EXCLUSIVE is good on UP and it is _very_ bad on |
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index fccc250f95f5..532e4faa29f7 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c | |||
@@ -73,6 +73,7 @@ static const struct proto_ops nr_proto_ops; | |||
73 | * separate class since they always nest. | 73 | * separate class since they always nest. |
74 | */ | 74 | */ |
75 | static struct lock_class_key nr_netdev_xmit_lock_key; | 75 | static struct lock_class_key nr_netdev_xmit_lock_key; |
76 | static struct lock_class_key nr_netdev_addr_lock_key; | ||
76 | 77 | ||
77 | static void nr_set_lockdep_one(struct net_device *dev, | 78 | static void nr_set_lockdep_one(struct net_device *dev, |
78 | struct netdev_queue *txq, | 79 | struct netdev_queue *txq, |
@@ -83,6 +84,7 @@ static void nr_set_lockdep_one(struct net_device *dev, | |||
83 | 84 | ||
84 | static void nr_set_lockdep_key(struct net_device *dev) | 85 | static void nr_set_lockdep_key(struct net_device *dev) |
85 | { | 86 | { |
87 | lockdep_set_class(&dev->addr_list_lock, &nr_netdev_addr_lock_key); | ||
86 | netdev_for_each_tx_queue(dev, nr_set_lockdep_one, NULL); | 88 | netdev_for_each_tx_queue(dev, nr_set_lockdep_one, NULL); |
87 | } | 89 | } |
88 | 90 | ||
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index d56cae112dc8..c718e7e3f7de 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -260,8 +260,8 @@ static inline struct packet_sock *pkt_sk(struct sock *sk) | |||
260 | 260 | ||
261 | static void packet_sock_destruct(struct sock *sk) | 261 | static void packet_sock_destruct(struct sock *sk) |
262 | { | 262 | { |
263 | BUG_TRAP(!atomic_read(&sk->sk_rmem_alloc)); | 263 | WARN_ON(atomic_read(&sk->sk_rmem_alloc)); |
264 | BUG_TRAP(!atomic_read(&sk->sk_wmem_alloc)); | 264 | WARN_ON(atomic_read(&sk->sk_wmem_alloc)); |
265 | 265 | ||
266 | if (!sock_flag(sk, SOCK_DEAD)) { | 266 | if (!sock_flag(sk, SOCK_DEAD)) { |
267 | printk("Attempt to release alive packet socket: %p\n", sk); | 267 | printk("Attempt to release alive packet socket: %p\n", sk); |
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c index dbc963b4f5fb..a7f1ce11bc22 100644 --- a/net/rose/af_rose.c +++ b/net/rose/af_rose.c | |||
@@ -74,6 +74,7 @@ ax25_address rose_callsign; | |||
74 | * separate class since they always nest. | 74 | * separate class since they always nest. |
75 | */ | 75 | */ |
76 | static struct lock_class_key rose_netdev_xmit_lock_key; | 76 | static struct lock_class_key rose_netdev_xmit_lock_key; |
77 | static struct lock_class_key rose_netdev_addr_lock_key; | ||
77 | 78 | ||
78 | static void rose_set_lockdep_one(struct net_device *dev, | 79 | static void rose_set_lockdep_one(struct net_device *dev, |
79 | struct netdev_queue *txq, | 80 | struct netdev_queue *txq, |
@@ -84,6 +85,7 @@ static void rose_set_lockdep_one(struct net_device *dev, | |||
84 | 85 | ||
85 | static void rose_set_lockdep_key(struct net_device *dev) | 86 | static void rose_set_lockdep_key(struct net_device *dev) |
86 | { | 87 | { |
88 | lockdep_set_class(&dev->addr_list_lock, &rose_netdev_addr_lock_key); | ||
87 | netdev_for_each_tx_queue(dev, rose_set_lockdep_one, NULL); | 89 | netdev_for_each_tx_queue(dev, rose_set_lockdep_one, NULL); |
88 | } | 90 | } |
89 | 91 | ||
diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c index 4b2682feeedc..32e489118beb 100644 --- a/net/rxrpc/af_rxrpc.c +++ b/net/rxrpc/af_rxrpc.c | |||
@@ -660,9 +660,9 @@ static void rxrpc_sock_destructor(struct sock *sk) | |||
660 | 660 | ||
661 | rxrpc_purge_queue(&sk->sk_receive_queue); | 661 | rxrpc_purge_queue(&sk->sk_receive_queue); |
662 | 662 | ||
663 | BUG_TRAP(!atomic_read(&sk->sk_wmem_alloc)); | 663 | WARN_ON(atomic_read(&sk->sk_wmem_alloc)); |
664 | BUG_TRAP(sk_unhashed(sk)); | 664 | WARN_ON(!sk_unhashed(sk)); |
665 | BUG_TRAP(!sk->sk_socket); | 665 | WARN_ON(sk->sk_socket); |
666 | 666 | ||
667 | if (!sock_flag(sk, SOCK_DEAD)) { | 667 | if (!sock_flag(sk, SOCK_DEAD)) { |
668 | printk("Attempt to release alive rxrpc socket: %p\n", sk); | 668 | printk("Attempt to release alive rxrpc socket: %p\n", sk); |
diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 74e662cbb2c5..d308c19aa3f9 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c | |||
@@ -41,7 +41,7 @@ void tcf_hash_destroy(struct tcf_common *p, struct tcf_hashinfo *hinfo) | |||
41 | return; | 41 | return; |
42 | } | 42 | } |
43 | } | 43 | } |
44 | BUG_TRAP(0); | 44 | WARN_ON(1); |
45 | } | 45 | } |
46 | EXPORT_SYMBOL(tcf_hash_destroy); | 46 | EXPORT_SYMBOL(tcf_hash_destroy); |
47 | 47 | ||
diff --git a/net/sched/act_police.c b/net/sched/act_police.c index 32c3f9d9fb7a..38015b493947 100644 --- a/net/sched/act_police.c +++ b/net/sched/act_police.c | |||
@@ -116,7 +116,7 @@ static void tcf_police_destroy(struct tcf_police *p) | |||
116 | return; | 116 | return; |
117 | } | 117 | } |
118 | } | 118 | } |
119 | BUG_TRAP(0); | 119 | WARN_ON(1); |
120 | } | 120 | } |
121 | 121 | ||
122 | static const struct nla_policy police_policy[TCA_POLICE_MAX + 1] = { | 122 | static const struct nla_policy police_policy[TCA_POLICE_MAX + 1] = { |
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index 527db2559dd2..246f9065ce34 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c | |||
@@ -345,7 +345,7 @@ static int u32_delete_key(struct tcf_proto *tp, struct tc_u_knode* key) | |||
345 | } | 345 | } |
346 | } | 346 | } |
347 | } | 347 | } |
348 | BUG_TRAP(0); | 348 | WARN_ON(1); |
349 | return 0; | 349 | return 0; |
350 | } | 350 | } |
351 | 351 | ||
@@ -368,7 +368,7 @@ static int u32_destroy_hnode(struct tcf_proto *tp, struct tc_u_hnode *ht) | |||
368 | struct tc_u_common *tp_c = tp->data; | 368 | struct tc_u_common *tp_c = tp->data; |
369 | struct tc_u_hnode **hn; | 369 | struct tc_u_hnode **hn; |
370 | 370 | ||
371 | BUG_TRAP(!ht->refcnt); | 371 | WARN_ON(ht->refcnt); |
372 | 372 | ||
373 | u32_clear_hnode(tp, ht); | 373 | u32_clear_hnode(tp, ht); |
374 | 374 | ||
@@ -380,7 +380,7 @@ static int u32_destroy_hnode(struct tcf_proto *tp, struct tc_u_hnode *ht) | |||
380 | } | 380 | } |
381 | } | 381 | } |
382 | 382 | ||
383 | BUG_TRAP(0); | 383 | WARN_ON(1); |
384 | return -ENOENT; | 384 | return -ENOENT; |
385 | } | 385 | } |
386 | 386 | ||
@@ -389,7 +389,7 @@ static void u32_destroy(struct tcf_proto *tp) | |||
389 | struct tc_u_common *tp_c = tp->data; | 389 | struct tc_u_common *tp_c = tp->data; |
390 | struct tc_u_hnode *root_ht = xchg(&tp->root, NULL); | 390 | struct tc_u_hnode *root_ht = xchg(&tp->root, NULL); |
391 | 391 | ||
392 | BUG_TRAP(root_ht != NULL); | 392 | WARN_ON(root_ht == NULL); |
393 | 393 | ||
394 | if (root_ht && --root_ht->refcnt == 0) | 394 | if (root_ht && --root_ht->refcnt == 0) |
395 | u32_destroy_hnode(tp, root_ht); | 395 | u32_destroy_hnode(tp, root_ht); |
@@ -407,7 +407,7 @@ static void u32_destroy(struct tcf_proto *tp) | |||
407 | while ((ht = tp_c->hlist) != NULL) { | 407 | while ((ht = tp_c->hlist) != NULL) { |
408 | tp_c->hlist = ht->next; | 408 | tp_c->hlist = ht->next; |
409 | 409 | ||
410 | BUG_TRAP(ht->refcnt == 0); | 410 | WARN_ON(ht->refcnt != 0); |
411 | 411 | ||
412 | kfree(ht); | 412 | kfree(ht); |
413 | } | 413 | } |
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index 5219d5f9d754..b0601642e227 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c | |||
@@ -447,7 +447,7 @@ void qdisc_watchdog_cancel(struct qdisc_watchdog *wd) | |||
447 | } | 447 | } |
448 | EXPORT_SYMBOL(qdisc_watchdog_cancel); | 448 | EXPORT_SYMBOL(qdisc_watchdog_cancel); |
449 | 449 | ||
450 | struct hlist_head *qdisc_class_hash_alloc(unsigned int n) | 450 | static struct hlist_head *qdisc_class_hash_alloc(unsigned int n) |
451 | { | 451 | { |
452 | unsigned int size = n * sizeof(struct hlist_head), i; | 452 | unsigned int size = n * sizeof(struct hlist_head), i; |
453 | struct hlist_head *h; | 453 | struct hlist_head *h; |
diff --git a/net/sched/sch_atm.c b/net/sched/sch_atm.c index 04faa835be17..6b517b9dac5b 100644 --- a/net/sched/sch_atm.c +++ b/net/sched/sch_atm.c | |||
@@ -162,7 +162,7 @@ static void atm_tc_put(struct Qdisc *sch, unsigned long cl) | |||
162 | qdisc_destroy(flow->q); | 162 | qdisc_destroy(flow->q); |
163 | tcf_destroy_chain(&flow->filter_list); | 163 | tcf_destroy_chain(&flow->filter_list); |
164 | if (flow->sock) { | 164 | if (flow->sock) { |
165 | pr_debug("atm_tc_put: f_count %d\n", | 165 | pr_debug("atm_tc_put: f_count %ld\n", |
166 | file_count(flow->sock->file)); | 166 | file_count(flow->sock->file)); |
167 | flow->vcc->pop = flow->old_pop; | 167 | flow->vcc->pop = flow->old_pop; |
168 | sockfd_put(flow->sock); | 168 | sockfd_put(flow->sock); |
@@ -259,7 +259,7 @@ static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent, | |||
259 | sock = sockfd_lookup(fd, &error); | 259 | sock = sockfd_lookup(fd, &error); |
260 | if (!sock) | 260 | if (!sock) |
261 | return error; /* f_count++ */ | 261 | return error; /* f_count++ */ |
262 | pr_debug("atm_tc_change: f_count %d\n", file_count(sock->file)); | 262 | pr_debug("atm_tc_change: f_count %ld\n", file_count(sock->file)); |
263 | if (sock->ops->family != PF_ATMSVC && sock->ops->family != PF_ATMPVC) { | 263 | if (sock->ops->family != PF_ATMSVC && sock->ops->family != PF_ATMPVC) { |
264 | error = -EPROTOTYPE; | 264 | error = -EPROTOTYPE; |
265 | goto err_out; | 265 | goto err_out; |
diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c index f1d2f8ec8b4c..14954bf4a683 100644 --- a/net/sched/sch_cbq.c +++ b/net/sched/sch_cbq.c | |||
@@ -1175,7 +1175,7 @@ static void cbq_unlink_class(struct cbq_class *this) | |||
1175 | this->tparent->children = NULL; | 1175 | this->tparent->children = NULL; |
1176 | } | 1176 | } |
1177 | } else { | 1177 | } else { |
1178 | BUG_TRAP(this->sibling == this); | 1178 | WARN_ON(this->sibling != this); |
1179 | } | 1179 | } |
1180 | } | 1180 | } |
1181 | 1181 | ||
@@ -1699,7 +1699,7 @@ static void cbq_destroy_class(struct Qdisc *sch, struct cbq_class *cl) | |||
1699 | { | 1699 | { |
1700 | struct cbq_sched_data *q = qdisc_priv(sch); | 1700 | struct cbq_sched_data *q = qdisc_priv(sch); |
1701 | 1701 | ||
1702 | BUG_TRAP(!cl->filters); | 1702 | WARN_ON(cl->filters); |
1703 | 1703 | ||
1704 | tcf_destroy_chain(&cl->filter_list); | 1704 | tcf_destroy_chain(&cl->filter_list); |
1705 | qdisc_destroy(cl->q); | 1705 | qdisc_destroy(cl->q); |
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c index cb625b4d6da5..fd2a6cadb115 100644 --- a/net/sched/sch_generic.c +++ b/net/sched/sch_generic.c | |||
@@ -212,9 +212,9 @@ static void dev_watchdog(unsigned long arg) | |||
212 | if (some_queue_stopped && | 212 | if (some_queue_stopped && |
213 | time_after(jiffies, (dev->trans_start + | 213 | time_after(jiffies, (dev->trans_start + |
214 | dev->watchdog_timeo))) { | 214 | dev->watchdog_timeo))) { |
215 | printk(KERN_INFO "NETDEV WATCHDOG: %s: " | 215 | char drivername[64]; |
216 | "transmit timed out\n", | 216 | printk(KERN_INFO "NETDEV WATCHDOG: %s (%s): transmit timed out\n", |
217 | dev->name); | 217 | dev->name, netdev_drivername(dev, drivername, 64)); |
218 | dev->tx_timeout(dev); | 218 | dev->tx_timeout(dev); |
219 | WARN_ON_ONCE(1); | 219 | WARN_ON_ONCE(1); |
220 | } | 220 | } |
@@ -736,9 +736,9 @@ static void shutdown_scheduler_queue(struct net_device *dev, | |||
736 | dev_queue->qdisc = qdisc_default; | 736 | dev_queue->qdisc = qdisc_default; |
737 | dev_queue->qdisc_sleeping = qdisc_default; | 737 | dev_queue->qdisc_sleeping = qdisc_default; |
738 | 738 | ||
739 | spin_lock(root_lock); | 739 | spin_lock_bh(root_lock); |
740 | qdisc_destroy(qdisc); | 740 | qdisc_destroy(qdisc); |
741 | spin_unlock(root_lock); | 741 | spin_unlock_bh(root_lock); |
742 | } | 742 | } |
743 | } | 743 | } |
744 | 744 | ||
@@ -746,5 +746,5 @@ void dev_shutdown(struct net_device *dev) | |||
746 | { | 746 | { |
747 | netdev_for_each_tx_queue(dev, shutdown_scheduler_queue, &noop_qdisc); | 747 | netdev_for_each_tx_queue(dev, shutdown_scheduler_queue, &noop_qdisc); |
748 | shutdown_scheduler_queue(dev, &dev->rx_queue, NULL); | 748 | shutdown_scheduler_queue(dev, &dev->rx_queue, NULL); |
749 | BUG_TRAP(!timer_pending(&dev->watchdog_timer)); | 749 | WARN_ON(timer_pending(&dev->watchdog_timer)); |
750 | } | 750 | } |
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c index 30c999c61b01..75a40951c4f2 100644 --- a/net/sched/sch_htb.c +++ b/net/sched/sch_htb.c | |||
@@ -524,7 +524,7 @@ htb_change_class_mode(struct htb_sched *q, struct htb_class *cl, long *diff) | |||
524 | */ | 524 | */ |
525 | static inline void htb_activate(struct htb_sched *q, struct htb_class *cl) | 525 | static inline void htb_activate(struct htb_sched *q, struct htb_class *cl) |
526 | { | 526 | { |
527 | BUG_TRAP(!cl->level && cl->un.leaf.q && cl->un.leaf.q->q.qlen); | 527 | WARN_ON(cl->level || !cl->un.leaf.q || !cl->un.leaf.q->q.qlen); |
528 | 528 | ||
529 | if (!cl->prio_activity) { | 529 | if (!cl->prio_activity) { |
530 | cl->prio_activity = 1 << (cl->un.leaf.aprio = cl->un.leaf.prio); | 530 | cl->prio_activity = 1 << (cl->un.leaf.aprio = cl->un.leaf.prio); |
@@ -542,7 +542,7 @@ static inline void htb_activate(struct htb_sched *q, struct htb_class *cl) | |||
542 | */ | 542 | */ |
543 | static inline void htb_deactivate(struct htb_sched *q, struct htb_class *cl) | 543 | static inline void htb_deactivate(struct htb_sched *q, struct htb_class *cl) |
544 | { | 544 | { |
545 | BUG_TRAP(cl->prio_activity); | 545 | WARN_ON(!cl->prio_activity); |
546 | 546 | ||
547 | htb_deactivate_prios(q, cl); | 547 | htb_deactivate_prios(q, cl); |
548 | cl->prio_activity = 0; | 548 | cl->prio_activity = 0; |
@@ -757,7 +757,7 @@ static struct htb_class *htb_lookup_leaf(struct rb_root *tree, int prio, | |||
757 | u32 *pid; | 757 | u32 *pid; |
758 | } stk[TC_HTB_MAXDEPTH], *sp = stk; | 758 | } stk[TC_HTB_MAXDEPTH], *sp = stk; |
759 | 759 | ||
760 | BUG_TRAP(tree->rb_node); | 760 | WARN_ON(!tree->rb_node); |
761 | sp->root = tree->rb_node; | 761 | sp->root = tree->rb_node; |
762 | sp->pptr = pptr; | 762 | sp->pptr = pptr; |
763 | sp->pid = pid; | 763 | sp->pid = pid; |
@@ -777,7 +777,7 @@ static struct htb_class *htb_lookup_leaf(struct rb_root *tree, int prio, | |||
777 | *sp->pptr = (*sp->pptr)->rb_left; | 777 | *sp->pptr = (*sp->pptr)->rb_left; |
778 | if (sp > stk) { | 778 | if (sp > stk) { |
779 | sp--; | 779 | sp--; |
780 | BUG_TRAP(*sp->pptr); | 780 | WARN_ON(!*sp->pptr); |
781 | if (!*sp->pptr) | 781 | if (!*sp->pptr) |
782 | return NULL; | 782 | return NULL; |
783 | htb_next_rb_node(sp->pptr); | 783 | htb_next_rb_node(sp->pptr); |
@@ -792,7 +792,7 @@ static struct htb_class *htb_lookup_leaf(struct rb_root *tree, int prio, | |||
792 | sp->pid = cl->un.inner.last_ptr_id + prio; | 792 | sp->pid = cl->un.inner.last_ptr_id + prio; |
793 | } | 793 | } |
794 | } | 794 | } |
795 | BUG_TRAP(0); | 795 | WARN_ON(1); |
796 | return NULL; | 796 | return NULL; |
797 | } | 797 | } |
798 | 798 | ||
@@ -810,7 +810,7 @@ static struct sk_buff *htb_dequeue_tree(struct htb_sched *q, int prio, | |||
810 | 810 | ||
811 | do { | 811 | do { |
812 | next: | 812 | next: |
813 | BUG_TRAP(cl); | 813 | WARN_ON(!cl); |
814 | if (!cl) | 814 | if (!cl) |
815 | return NULL; | 815 | return NULL; |
816 | 816 | ||
@@ -1185,7 +1185,7 @@ static void htb_parent_to_leaf(struct htb_sched *q, struct htb_class *cl, | |||
1185 | { | 1185 | { |
1186 | struct htb_class *parent = cl->parent; | 1186 | struct htb_class *parent = cl->parent; |
1187 | 1187 | ||
1188 | BUG_TRAP(!cl->level && cl->un.leaf.q && !cl->prio_activity); | 1188 | WARN_ON(cl->level || !cl->un.leaf.q || cl->prio_activity); |
1189 | 1189 | ||
1190 | if (parent->cmode != HTB_CAN_SEND) | 1190 | if (parent->cmode != HTB_CAN_SEND) |
1191 | htb_safe_rb_erase(&parent->pq_node, q->wait_pq + parent->level); | 1191 | htb_safe_rb_erase(&parent->pq_node, q->wait_pq + parent->level); |
@@ -1205,7 +1205,7 @@ static void htb_parent_to_leaf(struct htb_sched *q, struct htb_class *cl, | |||
1205 | static void htb_destroy_class(struct Qdisc *sch, struct htb_class *cl) | 1205 | static void htb_destroy_class(struct Qdisc *sch, struct htb_class *cl) |
1206 | { | 1206 | { |
1207 | if (!cl->level) { | 1207 | if (!cl->level) { |
1208 | BUG_TRAP(cl->un.leaf.q); | 1208 | WARN_ON(!cl->un.leaf.q); |
1209 | qdisc_destroy(cl->un.leaf.q); | 1209 | qdisc_destroy(cl->un.leaf.q); |
1210 | } | 1210 | } |
1211 | gen_kill_estimator(&cl->bstats, &cl->rate_est); | 1211 | gen_kill_estimator(&cl->bstats, &cl->rate_est); |
diff --git a/net/sctp/associola.c b/net/sctp/associola.c index ec2a0a33fd78..8472b8b349c4 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c | |||
@@ -464,7 +464,7 @@ static void sctp_association_destroy(struct sctp_association *asoc) | |||
464 | spin_unlock_bh(&sctp_assocs_id_lock); | 464 | spin_unlock_bh(&sctp_assocs_id_lock); |
465 | } | 465 | } |
466 | 466 | ||
467 | BUG_TRAP(!atomic_read(&asoc->rmem_alloc)); | 467 | WARN_ON(atomic_read(&asoc->rmem_alloc)); |
468 | 468 | ||
469 | if (asoc->base.malloced) { | 469 | if (asoc->base.malloced) { |
470 | kfree(asoc); | 470 | kfree(asoc); |
diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c index 70ead8dc3485..4328ad5439c9 100644 --- a/net/sctp/outqueue.c +++ b/net/sctp/outqueue.c | |||
@@ -71,6 +71,8 @@ static void sctp_mark_missing(struct sctp_outq *q, | |||
71 | 71 | ||
72 | static void sctp_generate_fwdtsn(struct sctp_outq *q, __u32 sack_ctsn); | 72 | static void sctp_generate_fwdtsn(struct sctp_outq *q, __u32 sack_ctsn); |
73 | 73 | ||
74 | static int sctp_outq_flush(struct sctp_outq *q, int rtx_timeout); | ||
75 | |||
74 | /* Add data to the front of the queue. */ | 76 | /* Add data to the front of the queue. */ |
75 | static inline void sctp_outq_head_data(struct sctp_outq *q, | 77 | static inline void sctp_outq_head_data(struct sctp_outq *q, |
76 | struct sctp_chunk *ch) | 78 | struct sctp_chunk *ch) |
@@ -712,7 +714,7 @@ int sctp_outq_uncork(struct sctp_outq *q) | |||
712 | * locking concerns must be made. Today we use the sock lock to protect | 714 | * locking concerns must be made. Today we use the sock lock to protect |
713 | * this function. | 715 | * this function. |
714 | */ | 716 | */ |
715 | int sctp_outq_flush(struct sctp_outq *q, int rtx_timeout) | 717 | static int sctp_outq_flush(struct sctp_outq *q, int rtx_timeout) |
716 | { | 718 | { |
717 | struct sctp_packet *packet; | 719 | struct sctp_packet *packet; |
718 | struct sctp_packet singleton; | 720 | struct sctp_packet singleton; |
diff --git a/net/sctp/proc.c b/net/sctp/proc.c index 5dd89831eceb..f268910620be 100644 --- a/net/sctp/proc.c +++ b/net/sctp/proc.c | |||
@@ -519,8 +519,3 @@ int __init sctp_remaddr_proc_init(void) | |||
519 | 519 | ||
520 | return 0; | 520 | return 0; |
521 | } | 521 | } |
522 | |||
523 | void sctp_assoc_proc_exit(void) | ||
524 | { | ||
525 | remove_proc_entry("remaddr", proc_net_sctp); | ||
526 | } | ||
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 79bece16aede..dbb79adf8f3c 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
@@ -3910,7 +3910,7 @@ static int sctp_getsockopt_peeloff(struct sock *sk, int len, char __user *optval | |||
3910 | goto out; | 3910 | goto out; |
3911 | 3911 | ||
3912 | /* Map the socket to an unused fd that can be returned to the user. */ | 3912 | /* Map the socket to an unused fd that can be returned to the user. */ |
3913 | retval = sock_map_fd(newsock); | 3913 | retval = sock_map_fd(newsock, 0); |
3914 | if (retval < 0) { | 3914 | if (retval < 0) { |
3915 | sock_release(newsock); | 3915 | sock_release(newsock); |
3916 | goto out; | 3916 | goto out; |
diff --git a/net/socket.c b/net/socket.c index 1ba57d888981..8ef8ba81b9e2 100644 --- a/net/socket.c +++ b/net/socket.c | |||
@@ -63,11 +63,13 @@ | |||
63 | #include <linux/file.h> | 63 | #include <linux/file.h> |
64 | #include <linux/net.h> | 64 | #include <linux/net.h> |
65 | #include <linux/interrupt.h> | 65 | #include <linux/interrupt.h> |
66 | #include <linux/thread_info.h> | ||
66 | #include <linux/rcupdate.h> | 67 | #include <linux/rcupdate.h> |
67 | #include <linux/netdevice.h> | 68 | #include <linux/netdevice.h> |
68 | #include <linux/proc_fs.h> | 69 | #include <linux/proc_fs.h> |
69 | #include <linux/seq_file.h> | 70 | #include <linux/seq_file.h> |
70 | #include <linux/mutex.h> | 71 | #include <linux/mutex.h> |
72 | #include <linux/thread_info.h> | ||
71 | #include <linux/wanrouter.h> | 73 | #include <linux/wanrouter.h> |
72 | #include <linux/if_bridge.h> | 74 | #include <linux/if_bridge.h> |
73 | #include <linux/if_frad.h> | 75 | #include <linux/if_frad.h> |
@@ -263,7 +265,7 @@ static void sock_destroy_inode(struct inode *inode) | |||
263 | container_of(inode, struct socket_alloc, vfs_inode)); | 265 | container_of(inode, struct socket_alloc, vfs_inode)); |
264 | } | 266 | } |
265 | 267 | ||
266 | static void init_once(struct kmem_cache *cachep, void *foo) | 268 | static void init_once(void *foo) |
267 | { | 269 | { |
268 | struct socket_alloc *ei = (struct socket_alloc *)foo; | 270 | struct socket_alloc *ei = (struct socket_alloc *)foo; |
269 | 271 | ||
@@ -349,11 +351,11 @@ static struct dentry_operations sockfs_dentry_operations = { | |||
349 | * but we take care of internal coherence yet. | 351 | * but we take care of internal coherence yet. |
350 | */ | 352 | */ |
351 | 353 | ||
352 | static int sock_alloc_fd(struct file **filep) | 354 | static int sock_alloc_fd(struct file **filep, int flags) |
353 | { | 355 | { |
354 | int fd; | 356 | int fd; |
355 | 357 | ||
356 | fd = get_unused_fd(); | 358 | fd = get_unused_fd_flags(flags); |
357 | if (likely(fd >= 0)) { | 359 | if (likely(fd >= 0)) { |
358 | struct file *file = get_empty_filp(); | 360 | struct file *file = get_empty_filp(); |
359 | 361 | ||
@@ -367,7 +369,7 @@ static int sock_alloc_fd(struct file **filep) | |||
367 | return fd; | 369 | return fd; |
368 | } | 370 | } |
369 | 371 | ||
370 | static int sock_attach_fd(struct socket *sock, struct file *file) | 372 | static int sock_attach_fd(struct socket *sock, struct file *file, int flags) |
371 | { | 373 | { |
372 | struct dentry *dentry; | 374 | struct dentry *dentry; |
373 | struct qstr name = { .name = "" }; | 375 | struct qstr name = { .name = "" }; |
@@ -389,20 +391,20 @@ static int sock_attach_fd(struct socket *sock, struct file *file) | |||
389 | init_file(file, sock_mnt, dentry, FMODE_READ | FMODE_WRITE, | 391 | init_file(file, sock_mnt, dentry, FMODE_READ | FMODE_WRITE, |
390 | &socket_file_ops); | 392 | &socket_file_ops); |
391 | SOCK_INODE(sock)->i_fop = &socket_file_ops; | 393 | SOCK_INODE(sock)->i_fop = &socket_file_ops; |
392 | file->f_flags = O_RDWR; | 394 | file->f_flags = O_RDWR | (flags & O_NONBLOCK); |
393 | file->f_pos = 0; | 395 | file->f_pos = 0; |
394 | file->private_data = sock; | 396 | file->private_data = sock; |
395 | 397 | ||
396 | return 0; | 398 | return 0; |
397 | } | 399 | } |
398 | 400 | ||
399 | int sock_map_fd(struct socket *sock) | 401 | int sock_map_fd(struct socket *sock, int flags) |
400 | { | 402 | { |
401 | struct file *newfile; | 403 | struct file *newfile; |
402 | int fd = sock_alloc_fd(&newfile); | 404 | int fd = sock_alloc_fd(&newfile, flags); |
403 | 405 | ||
404 | if (likely(fd >= 0)) { | 406 | if (likely(fd >= 0)) { |
405 | int err = sock_attach_fd(sock, newfile); | 407 | int err = sock_attach_fd(sock, newfile, flags); |
406 | 408 | ||
407 | if (unlikely(err < 0)) { | 409 | if (unlikely(err < 0)) { |
408 | put_filp(newfile); | 410 | put_filp(newfile); |
@@ -1218,12 +1220,27 @@ asmlinkage long sys_socket(int family, int type, int protocol) | |||
1218 | { | 1220 | { |
1219 | int retval; | 1221 | int retval; |
1220 | struct socket *sock; | 1222 | struct socket *sock; |
1223 | int flags; | ||
1224 | |||
1225 | /* Check the SOCK_* constants for consistency. */ | ||
1226 | BUILD_BUG_ON(SOCK_CLOEXEC != O_CLOEXEC); | ||
1227 | BUILD_BUG_ON((SOCK_MAX | SOCK_TYPE_MASK) != SOCK_TYPE_MASK); | ||
1228 | BUILD_BUG_ON(SOCK_CLOEXEC & SOCK_TYPE_MASK); | ||
1229 | BUILD_BUG_ON(SOCK_NONBLOCK & SOCK_TYPE_MASK); | ||
1230 | |||
1231 | flags = type & ~SOCK_TYPE_MASK; | ||
1232 | if (flags & ~(SOCK_CLOEXEC | SOCK_NONBLOCK)) | ||
1233 | return -EINVAL; | ||
1234 | type &= SOCK_TYPE_MASK; | ||
1235 | |||
1236 | if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK)) | ||
1237 | flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK; | ||
1221 | 1238 | ||
1222 | retval = sock_create(family, type, protocol, &sock); | 1239 | retval = sock_create(family, type, protocol, &sock); |
1223 | if (retval < 0) | 1240 | if (retval < 0) |
1224 | goto out; | 1241 | goto out; |
1225 | 1242 | ||
1226 | retval = sock_map_fd(sock); | 1243 | retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK)); |
1227 | if (retval < 0) | 1244 | if (retval < 0) |
1228 | goto out_release; | 1245 | goto out_release; |
1229 | 1246 | ||
@@ -1246,6 +1263,15 @@ asmlinkage long sys_socketpair(int family, int type, int protocol, | |||
1246 | struct socket *sock1, *sock2; | 1263 | struct socket *sock1, *sock2; |
1247 | int fd1, fd2, err; | 1264 | int fd1, fd2, err; |
1248 | struct file *newfile1, *newfile2; | 1265 | struct file *newfile1, *newfile2; |
1266 | int flags; | ||
1267 | |||
1268 | flags = type & ~SOCK_TYPE_MASK; | ||
1269 | if (flags & ~(SOCK_CLOEXEC | SOCK_NONBLOCK)) | ||
1270 | return -EINVAL; | ||
1271 | type &= SOCK_TYPE_MASK; | ||
1272 | |||
1273 | if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK)) | ||
1274 | flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK; | ||
1249 | 1275 | ||
1250 | /* | 1276 | /* |
1251 | * Obtain the first socket and check if the underlying protocol | 1277 | * Obtain the first socket and check if the underlying protocol |
@@ -1264,13 +1290,13 @@ asmlinkage long sys_socketpair(int family, int type, int protocol, | |||
1264 | if (err < 0) | 1290 | if (err < 0) |
1265 | goto out_release_both; | 1291 | goto out_release_both; |
1266 | 1292 | ||
1267 | fd1 = sock_alloc_fd(&newfile1); | 1293 | fd1 = sock_alloc_fd(&newfile1, flags & O_CLOEXEC); |
1268 | if (unlikely(fd1 < 0)) { | 1294 | if (unlikely(fd1 < 0)) { |
1269 | err = fd1; | 1295 | err = fd1; |
1270 | goto out_release_both; | 1296 | goto out_release_both; |
1271 | } | 1297 | } |
1272 | 1298 | ||
1273 | fd2 = sock_alloc_fd(&newfile2); | 1299 | fd2 = sock_alloc_fd(&newfile2, flags & O_CLOEXEC); |
1274 | if (unlikely(fd2 < 0)) { | 1300 | if (unlikely(fd2 < 0)) { |
1275 | err = fd2; | 1301 | err = fd2; |
1276 | put_filp(newfile1); | 1302 | put_filp(newfile1); |
@@ -1278,12 +1304,12 @@ asmlinkage long sys_socketpair(int family, int type, int protocol, | |||
1278 | goto out_release_both; | 1304 | goto out_release_both; |
1279 | } | 1305 | } |
1280 | 1306 | ||
1281 | err = sock_attach_fd(sock1, newfile1); | 1307 | err = sock_attach_fd(sock1, newfile1, flags & O_NONBLOCK); |
1282 | if (unlikely(err < 0)) { | 1308 | if (unlikely(err < 0)) { |
1283 | goto out_fd2; | 1309 | goto out_fd2; |
1284 | } | 1310 | } |
1285 | 1311 | ||
1286 | err = sock_attach_fd(sock2, newfile2); | 1312 | err = sock_attach_fd(sock2, newfile2, flags & O_NONBLOCK); |
1287 | if (unlikely(err < 0)) { | 1313 | if (unlikely(err < 0)) { |
1288 | fput(newfile1); | 1314 | fput(newfile1); |
1289 | goto out_fd1; | 1315 | goto out_fd1; |
@@ -1401,14 +1427,20 @@ asmlinkage long sys_listen(int fd, int backlog) | |||
1401 | * clean when we restucture accept also. | 1427 | * clean when we restucture accept also. |
1402 | */ | 1428 | */ |
1403 | 1429 | ||
1404 | asmlinkage long sys_accept(int fd, struct sockaddr __user *upeer_sockaddr, | 1430 | long do_accept(int fd, struct sockaddr __user *upeer_sockaddr, |
1405 | int __user *upeer_addrlen) | 1431 | int __user *upeer_addrlen, int flags) |
1406 | { | 1432 | { |
1407 | struct socket *sock, *newsock; | 1433 | struct socket *sock, *newsock; |
1408 | struct file *newfile; | 1434 | struct file *newfile; |
1409 | int err, len, newfd, fput_needed; | 1435 | int err, len, newfd, fput_needed; |
1410 | struct sockaddr_storage address; | 1436 | struct sockaddr_storage address; |
1411 | 1437 | ||
1438 | if (flags & ~(SOCK_CLOEXEC | SOCK_NONBLOCK)) | ||
1439 | return -EINVAL; | ||
1440 | |||
1441 | if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK)) | ||
1442 | flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK; | ||
1443 | |||
1412 | sock = sockfd_lookup_light(fd, &err, &fput_needed); | 1444 | sock = sockfd_lookup_light(fd, &err, &fput_needed); |
1413 | if (!sock) | 1445 | if (!sock) |
1414 | goto out; | 1446 | goto out; |
@@ -1426,14 +1458,14 @@ asmlinkage long sys_accept(int fd, struct sockaddr __user *upeer_sockaddr, | |||
1426 | */ | 1458 | */ |
1427 | __module_get(newsock->ops->owner); | 1459 | __module_get(newsock->ops->owner); |
1428 | 1460 | ||
1429 | newfd = sock_alloc_fd(&newfile); | 1461 | newfd = sock_alloc_fd(&newfile, flags & O_CLOEXEC); |
1430 | if (unlikely(newfd < 0)) { | 1462 | if (unlikely(newfd < 0)) { |
1431 | err = newfd; | 1463 | err = newfd; |
1432 | sock_release(newsock); | 1464 | sock_release(newsock); |
1433 | goto out_put; | 1465 | goto out_put; |
1434 | } | 1466 | } |
1435 | 1467 | ||
1436 | err = sock_attach_fd(newsock, newfile); | 1468 | err = sock_attach_fd(newsock, newfile, flags & O_NONBLOCK); |
1437 | if (err < 0) | 1469 | if (err < 0) |
1438 | goto out_fd_simple; | 1470 | goto out_fd_simple; |
1439 | 1471 | ||
@@ -1479,6 +1511,66 @@ out_fd: | |||
1479 | goto out_put; | 1511 | goto out_put; |
1480 | } | 1512 | } |
1481 | 1513 | ||
1514 | #ifdef HAVE_SET_RESTORE_SIGMASK | ||
1515 | asmlinkage long sys_paccept(int fd, struct sockaddr __user *upeer_sockaddr, | ||
1516 | int __user *upeer_addrlen, | ||
1517 | const sigset_t __user *sigmask, | ||
1518 | size_t sigsetsize, int flags) | ||
1519 | { | ||
1520 | sigset_t ksigmask, sigsaved; | ||
1521 | int ret; | ||
1522 | |||
1523 | if (sigmask) { | ||
1524 | /* XXX: Don't preclude handling different sized sigset_t's. */ | ||
1525 | if (sigsetsize != sizeof(sigset_t)) | ||
1526 | return -EINVAL; | ||
1527 | if (copy_from_user(&ksigmask, sigmask, sizeof(ksigmask))) | ||
1528 | return -EFAULT; | ||
1529 | |||
1530 | sigdelsetmask(&ksigmask, sigmask(SIGKILL)|sigmask(SIGSTOP)); | ||
1531 | sigprocmask(SIG_SETMASK, &ksigmask, &sigsaved); | ||
1532 | } | ||
1533 | |||
1534 | ret = do_accept(fd, upeer_sockaddr, upeer_addrlen, flags); | ||
1535 | |||
1536 | if (ret < 0 && signal_pending(current)) { | ||
1537 | /* | ||
1538 | * Don't restore the signal mask yet. Let do_signal() deliver | ||
1539 | * the signal on the way back to userspace, before the signal | ||
1540 | * mask is restored. | ||
1541 | */ | ||
1542 | if (sigmask) { | ||
1543 | memcpy(¤t->saved_sigmask, &sigsaved, | ||
1544 | sizeof(sigsaved)); | ||
1545 | set_restore_sigmask(); | ||
1546 | } | ||
1547 | } else if (sigmask) | ||
1548 | sigprocmask(SIG_SETMASK, &sigsaved, NULL); | ||
1549 | |||
1550 | return ret; | ||
1551 | } | ||
1552 | #else | ||
1553 | asmlinkage long sys_paccept(int fd, struct sockaddr __user *upeer_sockaddr, | ||
1554 | int __user *upeer_addrlen, | ||
1555 | const sigset_t __user *sigmask, | ||
1556 | size_t sigsetsize, int flags) | ||
1557 | { | ||
1558 | /* The platform does not support restoring the signal mask in the | ||
1559 | * return path. So we do not allow using paccept() with a signal | ||
1560 | * mask. */ | ||
1561 | if (sigmask) | ||
1562 | return -EINVAL; | ||
1563 | |||
1564 | return do_accept(fd, upeer_sockaddr, upeer_addrlen, flags); | ||
1565 | } | ||
1566 | #endif | ||
1567 | |||
1568 | asmlinkage long sys_accept(int fd, struct sockaddr __user *upeer_sockaddr, | ||
1569 | int __user *upeer_addrlen) | ||
1570 | { | ||
1571 | return do_accept(fd, upeer_sockaddr, upeer_addrlen, 0); | ||
1572 | } | ||
1573 | |||
1482 | /* | 1574 | /* |
1483 | * Attempt to connect to a socket with the server address. The address | 1575 | * Attempt to connect to a socket with the server address. The address |
1484 | * is in user space so we verify it is OK and move it to kernel space. | 1576 | * is in user space so we verify it is OK and move it to kernel space. |
@@ -1999,10 +2091,11 @@ out: | |||
1999 | 2091 | ||
2000 | /* Argument list sizes for sys_socketcall */ | 2092 | /* Argument list sizes for sys_socketcall */ |
2001 | #define AL(x) ((x) * sizeof(unsigned long)) | 2093 | #define AL(x) ((x) * sizeof(unsigned long)) |
2002 | static const unsigned char nargs[18]={ | 2094 | static const unsigned char nargs[19]={ |
2003 | AL(0),AL(3),AL(3),AL(3),AL(2),AL(3), | 2095 | AL(0),AL(3),AL(3),AL(3),AL(2),AL(3), |
2004 | AL(3),AL(3),AL(4),AL(4),AL(4),AL(6), | 2096 | AL(3),AL(3),AL(4),AL(4),AL(4),AL(6), |
2005 | AL(6),AL(2),AL(5),AL(5),AL(3),AL(3) | 2097 | AL(6),AL(2),AL(5),AL(5),AL(3),AL(3), |
2098 | AL(6) | ||
2006 | }; | 2099 | }; |
2007 | 2100 | ||
2008 | #undef AL | 2101 | #undef AL |
@@ -2021,7 +2114,7 @@ asmlinkage long sys_socketcall(int call, unsigned long __user *args) | |||
2021 | unsigned long a0, a1; | 2114 | unsigned long a0, a1; |
2022 | int err; | 2115 | int err; |
2023 | 2116 | ||
2024 | if (call < 1 || call > SYS_RECVMSG) | 2117 | if (call < 1 || call > SYS_PACCEPT) |
2025 | return -EINVAL; | 2118 | return -EINVAL; |
2026 | 2119 | ||
2027 | /* copy_from_user should be SMP safe. */ | 2120 | /* copy_from_user should be SMP safe. */ |
@@ -2050,8 +2143,8 @@ asmlinkage long sys_socketcall(int call, unsigned long __user *args) | |||
2050 | break; | 2143 | break; |
2051 | case SYS_ACCEPT: | 2144 | case SYS_ACCEPT: |
2052 | err = | 2145 | err = |
2053 | sys_accept(a0, (struct sockaddr __user *)a1, | 2146 | do_accept(a0, (struct sockaddr __user *)a1, |
2054 | (int __user *)a[2]); | 2147 | (int __user *)a[2], 0); |
2055 | break; | 2148 | break; |
2056 | case SYS_GETSOCKNAME: | 2149 | case SYS_GETSOCKNAME: |
2057 | err = | 2150 | err = |
@@ -2098,6 +2191,13 @@ asmlinkage long sys_socketcall(int call, unsigned long __user *args) | |||
2098 | case SYS_RECVMSG: | 2191 | case SYS_RECVMSG: |
2099 | err = sys_recvmsg(a0, (struct msghdr __user *)a1, a[2]); | 2192 | err = sys_recvmsg(a0, (struct msghdr __user *)a1, a[2]); |
2100 | break; | 2193 | break; |
2194 | case SYS_PACCEPT: | ||
2195 | err = | ||
2196 | sys_paccept(a0, (struct sockaddr __user *)a1, | ||
2197 | (int __user *)a[2], | ||
2198 | (const sigset_t __user *) a[3], | ||
2199 | a[4], a[5]); | ||
2200 | break; | ||
2101 | default: | 2201 | default: |
2102 | err = -EINVAL; | 2202 | err = -EINVAL; |
2103 | break; | 2203 | break; |
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c index 5a9b0e7828cd..23a2b8f6dc49 100644 --- a/net/sunrpc/rpc_pipe.c +++ b/net/sunrpc/rpc_pipe.c | |||
@@ -897,7 +897,7 @@ static struct file_system_type rpc_pipe_fs_type = { | |||
897 | }; | 897 | }; |
898 | 898 | ||
899 | static void | 899 | static void |
900 | init_once(struct kmem_cache * cachep, void *foo) | 900 | init_once(void *foo) |
901 | { | 901 | { |
902 | struct rpc_inode *rpci = (struct rpc_inode *) foo; | 902 | struct rpc_inode *rpci = (struct rpc_inode *) foo; |
903 | 903 | ||
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index 5a32cb7c4bb4..835d27413083 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c | |||
@@ -310,7 +310,8 @@ svc_pool_map_set_cpumask(struct task_struct *task, unsigned int pidx) | |||
310 | switch (m->mode) { | 310 | switch (m->mode) { |
311 | case SVC_POOL_PERCPU: | 311 | case SVC_POOL_PERCPU: |
312 | { | 312 | { |
313 | set_cpus_allowed_ptr(task, &cpumask_of_cpu(node)); | 313 | cpumask_of_cpu_ptr(cpumask, node); |
314 | set_cpus_allowed_ptr(task, cpumask); | ||
314 | break; | 315 | break; |
315 | } | 316 | } |
316 | case SVC_POOL_PERNODE: | 317 | case SVC_POOL_PERNODE: |
diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c index a19b22b452a3..84d328329d98 100644 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c | |||
@@ -169,7 +169,8 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp, | |||
169 | (void *) | 169 | (void *) |
170 | vec->sge[xdr_sge_no].iov_base + sge_off, | 170 | vec->sge[xdr_sge_no].iov_base + sge_off, |
171 | sge_bytes, DMA_TO_DEVICE); | 171 | sge_bytes, DMA_TO_DEVICE); |
172 | if (dma_mapping_error(sge[sge_no].addr)) | 172 | if (dma_mapping_error(xprt->sc_cm_id->device->dma_device, |
173 | sge[sge_no].addr)) | ||
173 | goto err; | 174 | goto err; |
174 | sge_off = 0; | 175 | sge_off = 0; |
175 | sge_no++; | 176 | sge_no++; |
diff --git a/net/sysctl_net.c b/net/sysctl_net.c index 007c1a6708ee..972201cd5fa7 100644 --- a/net/sysctl_net.c +++ b/net/sysctl_net.c | |||
@@ -29,23 +29,35 @@ | |||
29 | #include <linux/if_tr.h> | 29 | #include <linux/if_tr.h> |
30 | #endif | 30 | #endif |
31 | 31 | ||
32 | static struct list_head * | 32 | static struct ctl_table_set * |
33 | net_ctl_header_lookup(struct ctl_table_root *root, struct nsproxy *namespaces) | 33 | net_ctl_header_lookup(struct ctl_table_root *root, struct nsproxy *namespaces) |
34 | { | 34 | { |
35 | return &namespaces->net_ns->sysctl_table_headers; | 35 | return &namespaces->net_ns->sysctls; |
36 | } | 36 | } |
37 | 37 | ||
38 | static struct ctl_table_root net_sysctl_root = { | 38 | static int is_seen(struct ctl_table_set *set) |
39 | .lookup = net_ctl_header_lookup, | 39 | { |
40 | }; | 40 | return ¤t->nsproxy->net_ns->sysctls == set; |
41 | } | ||
41 | 42 | ||
42 | static LIST_HEAD(net_sysctl_ro_tables); | 43 | /* Return standard mode bits for table entry. */ |
43 | static struct list_head *net_ctl_ro_header_lookup(struct ctl_table_root *root, | 44 | static int net_ctl_permissions(struct ctl_table_root *root, |
44 | struct nsproxy *namespaces) | 45 | struct nsproxy *nsproxy, |
46 | struct ctl_table *table) | ||
45 | { | 47 | { |
46 | return &net_sysctl_ro_tables; | 48 | /* Allow network administrator to have same access as root. */ |
49 | if (capable(CAP_NET_ADMIN)) { | ||
50 | int mode = (table->mode >> 6) & 7; | ||
51 | return (mode << 6) | (mode << 3) | mode; | ||
52 | } | ||
53 | return table->mode; | ||
47 | } | 54 | } |
48 | 55 | ||
56 | static struct ctl_table_root net_sysctl_root = { | ||
57 | .lookup = net_ctl_header_lookup, | ||
58 | .permissions = net_ctl_permissions, | ||
59 | }; | ||
60 | |||
49 | static int net_ctl_ro_header_perms(struct ctl_table_root *root, | 61 | static int net_ctl_ro_header_perms(struct ctl_table_root *root, |
50 | struct nsproxy *namespaces, struct ctl_table *table) | 62 | struct nsproxy *namespaces, struct ctl_table *table) |
51 | { | 63 | { |
@@ -56,19 +68,20 @@ static int net_ctl_ro_header_perms(struct ctl_table_root *root, | |||
56 | } | 68 | } |
57 | 69 | ||
58 | static struct ctl_table_root net_sysctl_ro_root = { | 70 | static struct ctl_table_root net_sysctl_ro_root = { |
59 | .lookup = net_ctl_ro_header_lookup, | ||
60 | .permissions = net_ctl_ro_header_perms, | 71 | .permissions = net_ctl_ro_header_perms, |
61 | }; | 72 | }; |
62 | 73 | ||
63 | static int sysctl_net_init(struct net *net) | 74 | static int sysctl_net_init(struct net *net) |
64 | { | 75 | { |
65 | INIT_LIST_HEAD(&net->sysctl_table_headers); | 76 | setup_sysctl_set(&net->sysctls, |
77 | &net_sysctl_ro_root.default_set, | ||
78 | is_seen); | ||
66 | return 0; | 79 | return 0; |
67 | } | 80 | } |
68 | 81 | ||
69 | static void sysctl_net_exit(struct net *net) | 82 | static void sysctl_net_exit(struct net *net) |
70 | { | 83 | { |
71 | WARN_ON(!list_empty(&net->sysctl_table_headers)); | 84 | WARN_ON(!list_empty(&net->sysctls.list)); |
72 | return; | 85 | return; |
73 | } | 86 | } |
74 | 87 | ||
@@ -84,6 +97,7 @@ static __init int sysctl_init(void) | |||
84 | if (ret) | 97 | if (ret) |
85 | goto out; | 98 | goto out; |
86 | register_sysctl_root(&net_sysctl_root); | 99 | register_sysctl_root(&net_sysctl_root); |
100 | setup_sysctl_set(&net_sysctl_ro_root.default_set, NULL, NULL); | ||
87 | register_sysctl_root(&net_sysctl_ro_root); | 101 | register_sysctl_root(&net_sysctl_ro_root); |
88 | out: | 102 | out: |
89 | return ret; | 103 | return ret; |
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 70ceb1604ad8..015606b54d9b 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
@@ -227,7 +227,7 @@ static void __unix_remove_socket(struct sock *sk) | |||
227 | 227 | ||
228 | static void __unix_insert_socket(struct hlist_head *list, struct sock *sk) | 228 | static void __unix_insert_socket(struct hlist_head *list, struct sock *sk) |
229 | { | 229 | { |
230 | BUG_TRAP(sk_unhashed(sk)); | 230 | WARN_ON(!sk_unhashed(sk)); |
231 | sk_add_node(sk, list); | 231 | sk_add_node(sk, list); |
232 | } | 232 | } |
233 | 233 | ||
@@ -350,9 +350,9 @@ static void unix_sock_destructor(struct sock *sk) | |||
350 | 350 | ||
351 | skb_queue_purge(&sk->sk_receive_queue); | 351 | skb_queue_purge(&sk->sk_receive_queue); |
352 | 352 | ||
353 | BUG_TRAP(!atomic_read(&sk->sk_wmem_alloc)); | 353 | WARN_ON(atomic_read(&sk->sk_wmem_alloc)); |
354 | BUG_TRAP(sk_unhashed(sk)); | 354 | WARN_ON(!sk_unhashed(sk)); |
355 | BUG_TRAP(!sk->sk_socket); | 355 | WARN_ON(sk->sk_socket); |
356 | if (!sock_flag(sk, SOCK_DEAD)) { | 356 | if (!sock_flag(sk, SOCK_DEAD)) { |
357 | printk("Attempt to release alive unix socket: %p\n", sk); | 357 | printk("Attempt to release alive unix socket: %p\n", sk); |
358 | return; | 358 | return; |
@@ -603,7 +603,7 @@ static struct sock * unix_create1(struct net *net, struct socket *sock) | |||
603 | u->dentry = NULL; | 603 | u->dentry = NULL; |
604 | u->mnt = NULL; | 604 | u->mnt = NULL; |
605 | spin_lock_init(&u->lock); | 605 | spin_lock_init(&u->lock); |
606 | atomic_set(&u->inflight, 0); | 606 | atomic_long_set(&u->inflight, 0); |
607 | INIT_LIST_HEAD(&u->link); | 607 | INIT_LIST_HEAD(&u->link); |
608 | mutex_init(&u->readlock); /* single task reading lock */ | 608 | mutex_init(&u->readlock); /* single task reading lock */ |
609 | init_waitqueue_head(&u->peer_wait); | 609 | init_waitqueue_head(&u->peer_wait); |
diff --git a/net/unix/garbage.c b/net/unix/garbage.c index ebdff3d877a1..2a27b84f740b 100644 --- a/net/unix/garbage.c +++ b/net/unix/garbage.c | |||
@@ -127,7 +127,7 @@ void unix_inflight(struct file *fp) | |||
127 | if(s) { | 127 | if(s) { |
128 | struct unix_sock *u = unix_sk(s); | 128 | struct unix_sock *u = unix_sk(s); |
129 | spin_lock(&unix_gc_lock); | 129 | spin_lock(&unix_gc_lock); |
130 | if (atomic_inc_return(&u->inflight) == 1) { | 130 | if (atomic_long_inc_return(&u->inflight) == 1) { |
131 | BUG_ON(!list_empty(&u->link)); | 131 | BUG_ON(!list_empty(&u->link)); |
132 | list_add_tail(&u->link, &gc_inflight_list); | 132 | list_add_tail(&u->link, &gc_inflight_list); |
133 | } else { | 133 | } else { |
@@ -145,7 +145,7 @@ void unix_notinflight(struct file *fp) | |||
145 | struct unix_sock *u = unix_sk(s); | 145 | struct unix_sock *u = unix_sk(s); |
146 | spin_lock(&unix_gc_lock); | 146 | spin_lock(&unix_gc_lock); |
147 | BUG_ON(list_empty(&u->link)); | 147 | BUG_ON(list_empty(&u->link)); |
148 | if (atomic_dec_and_test(&u->inflight)) | 148 | if (atomic_long_dec_and_test(&u->inflight)) |
149 | list_del_init(&u->link); | 149 | list_del_init(&u->link); |
150 | unix_tot_inflight--; | 150 | unix_tot_inflight--; |
151 | spin_unlock(&unix_gc_lock); | 151 | spin_unlock(&unix_gc_lock); |
@@ -237,17 +237,17 @@ static void scan_children(struct sock *x, void (*func)(struct unix_sock *), | |||
237 | 237 | ||
238 | static void dec_inflight(struct unix_sock *usk) | 238 | static void dec_inflight(struct unix_sock *usk) |
239 | { | 239 | { |
240 | atomic_dec(&usk->inflight); | 240 | atomic_long_dec(&usk->inflight); |
241 | } | 241 | } |
242 | 242 | ||
243 | static void inc_inflight(struct unix_sock *usk) | 243 | static void inc_inflight(struct unix_sock *usk) |
244 | { | 244 | { |
245 | atomic_inc(&usk->inflight); | 245 | atomic_long_inc(&usk->inflight); |
246 | } | 246 | } |
247 | 247 | ||
248 | static void inc_inflight_move_tail(struct unix_sock *u) | 248 | static void inc_inflight_move_tail(struct unix_sock *u) |
249 | { | 249 | { |
250 | atomic_inc(&u->inflight); | 250 | atomic_long_inc(&u->inflight); |
251 | /* | 251 | /* |
252 | * If this is still a candidate, move it to the end of the | 252 | * If this is still a candidate, move it to the end of the |
253 | * list, so that it's checked even if it was already passed | 253 | * list, so that it's checked even if it was already passed |
@@ -288,11 +288,11 @@ void unix_gc(void) | |||
288 | * before the detach without atomicity guarantees. | 288 | * before the detach without atomicity guarantees. |
289 | */ | 289 | */ |
290 | list_for_each_entry_safe(u, next, &gc_inflight_list, link) { | 290 | list_for_each_entry_safe(u, next, &gc_inflight_list, link) { |
291 | int total_refs; | 291 | long total_refs; |
292 | int inflight_refs; | 292 | long inflight_refs; |
293 | 293 | ||
294 | total_refs = file_count(u->sk.sk_socket->file); | 294 | total_refs = file_count(u->sk.sk_socket->file); |
295 | inflight_refs = atomic_read(&u->inflight); | 295 | inflight_refs = atomic_long_read(&u->inflight); |
296 | 296 | ||
297 | BUG_ON(inflight_refs < 1); | 297 | BUG_ON(inflight_refs < 1); |
298 | BUG_ON(total_refs < inflight_refs); | 298 | BUG_ON(total_refs < inflight_refs); |
@@ -324,7 +324,7 @@ void unix_gc(void) | |||
324 | /* Move cursor to after the current position. */ | 324 | /* Move cursor to after the current position. */ |
325 | list_move(&cursor, &u->link); | 325 | list_move(&cursor, &u->link); |
326 | 326 | ||
327 | if (atomic_read(&u->inflight) > 0) { | 327 | if (atomic_long_read(&u->inflight) > 0) { |
328 | list_move_tail(&u->link, &gc_inflight_list); | 328 | list_move_tail(&u->link, &gc_inflight_list); |
329 | u->gc_candidate = 0; | 329 | u->gc_candidate = 0; |
330 | scan_children(&u->sk, inc_inflight_move_tail, NULL); | 330 | scan_children(&u->sk, inc_inflight_move_tail, NULL); |
diff --git a/net/xfrm/Kconfig b/net/xfrm/Kconfig index 9201ef8ad90e..6d081674515f 100644 --- a/net/xfrm/Kconfig +++ b/net/xfrm/Kconfig | |||
@@ -46,6 +46,12 @@ config XFRM_STATISTICS | |||
46 | 46 | ||
47 | If unsure, say N. | 47 | If unsure, say N. |
48 | 48 | ||
49 | config XFRM_IPCOMP | ||
50 | tristate | ||
51 | select XFRM | ||
52 | select CRYPTO | ||
53 | select CRYPTO_DEFLATE | ||
54 | |||
49 | config NET_KEY | 55 | config NET_KEY |
50 | tristate "PF_KEY sockets" | 56 | tristate "PF_KEY sockets" |
51 | select XFRM | 57 | select XFRM |
diff --git a/net/xfrm/Makefile b/net/xfrm/Makefile index 332cfb0ff566..0f439a72ccab 100644 --- a/net/xfrm/Makefile +++ b/net/xfrm/Makefile | |||
@@ -6,4 +6,5 @@ obj-$(CONFIG_XFRM) := xfrm_policy.o xfrm_state.o xfrm_hash.o \ | |||
6 | xfrm_input.o xfrm_output.o xfrm_algo.o | 6 | xfrm_input.o xfrm_output.o xfrm_algo.o |
7 | obj-$(CONFIG_XFRM_STATISTICS) += xfrm_proc.o | 7 | obj-$(CONFIG_XFRM_STATISTICS) += xfrm_proc.o |
8 | obj-$(CONFIG_XFRM_USER) += xfrm_user.o | 8 | obj-$(CONFIG_XFRM_USER) += xfrm_user.o |
9 | obj-$(CONFIG_XFRM_IPCOMP) += xfrm_ipcomp.o | ||
9 | 10 | ||
diff --git a/net/xfrm/xfrm_algo.c b/net/xfrm/xfrm_algo.c index 23a2cc04b8cd..96036cf2216d 100644 --- a/net/xfrm/xfrm_algo.c +++ b/net/xfrm/xfrm_algo.c | |||
@@ -718,7 +718,7 @@ int skb_icv_walk(const struct sk_buff *skb, struct hash_desc *desc, | |||
718 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { | 718 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { |
719 | int end; | 719 | int end; |
720 | 720 | ||
721 | BUG_TRAP(start <= offset + len); | 721 | WARN_ON(start > offset + len); |
722 | 722 | ||
723 | end = start + skb_shinfo(skb)->frags[i].size; | 723 | end = start + skb_shinfo(skb)->frags[i].size; |
724 | if ((copy = end - offset) > 0) { | 724 | if ((copy = end - offset) > 0) { |
@@ -748,7 +748,7 @@ int skb_icv_walk(const struct sk_buff *skb, struct hash_desc *desc, | |||
748 | for (; list; list = list->next) { | 748 | for (; list; list = list->next) { |
749 | int end; | 749 | int end; |
750 | 750 | ||
751 | BUG_TRAP(start <= offset + len); | 751 | WARN_ON(start > offset + len); |
752 | 752 | ||
753 | end = start + list->len; | 753 | end = start + list->len; |
754 | if ((copy = end - offset) > 0) { | 754 | if ((copy = end - offset) > 0) { |
diff --git a/net/xfrm/xfrm_ipcomp.c b/net/xfrm/xfrm_ipcomp.c new file mode 100644 index 000000000000..c609a4b98e15 --- /dev/null +++ b/net/xfrm/xfrm_ipcomp.c | |||
@@ -0,0 +1,384 @@ | |||
1 | /* | ||
2 | * IP Payload Compression Protocol (IPComp) - RFC3173. | ||
3 | * | ||
4 | * Copyright (c) 2003 James Morris <jmorris@intercode.com.au> | ||
5 | * Copyright (c) 2003-2008 Herbert Xu <herbert@gondor.apana.org.au> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify it | ||
8 | * under the terms of the GNU General Public License as published by the Free | ||
9 | * Software Foundation; either version 2 of the License, or (at your option) | ||
10 | * any later version. | ||
11 | * | ||
12 | * Todo: | ||
13 | * - Tunable compression parameters. | ||
14 | * - Compression stats. | ||
15 | * - Adaptive compression. | ||
16 | */ | ||
17 | |||
18 | #include <linux/crypto.h> | ||
19 | #include <linux/err.h> | ||
20 | #include <linux/gfp.h> | ||
21 | #include <linux/list.h> | ||
22 | #include <linux/module.h> | ||
23 | #include <linux/mutex.h> | ||
24 | #include <linux/percpu.h> | ||
25 | #include <linux/smp.h> | ||
26 | #include <linux/vmalloc.h> | ||
27 | #include <net/ip.h> | ||
28 | #include <net/ipcomp.h> | ||
29 | #include <net/xfrm.h> | ||
30 | |||
31 | struct ipcomp_tfms { | ||
32 | struct list_head list; | ||
33 | struct crypto_comp **tfms; | ||
34 | int users; | ||
35 | }; | ||
36 | |||
37 | static DEFINE_MUTEX(ipcomp_resource_mutex); | ||
38 | static void **ipcomp_scratches; | ||
39 | static int ipcomp_scratch_users; | ||
40 | static LIST_HEAD(ipcomp_tfms_list); | ||
41 | |||
42 | static int ipcomp_decompress(struct xfrm_state *x, struct sk_buff *skb) | ||
43 | { | ||
44 | struct ipcomp_data *ipcd = x->data; | ||
45 | const int plen = skb->len; | ||
46 | int dlen = IPCOMP_SCRATCH_SIZE; | ||
47 | const u8 *start = skb->data; | ||
48 | const int cpu = get_cpu(); | ||
49 | u8 *scratch = *per_cpu_ptr(ipcomp_scratches, cpu); | ||
50 | struct crypto_comp *tfm = *per_cpu_ptr(ipcd->tfms, cpu); | ||
51 | int err = crypto_comp_decompress(tfm, start, plen, scratch, &dlen); | ||
52 | int len; | ||
53 | |||
54 | if (err) | ||
55 | goto out; | ||
56 | |||
57 | if (dlen < (plen + sizeof(struct ip_comp_hdr))) { | ||
58 | err = -EINVAL; | ||
59 | goto out; | ||
60 | } | ||
61 | |||
62 | len = dlen - plen; | ||
63 | if (len > skb_tailroom(skb)) | ||
64 | len = skb_tailroom(skb); | ||
65 | |||
66 | skb->truesize += len; | ||
67 | __skb_put(skb, len); | ||
68 | |||
69 | len += plen; | ||
70 | skb_copy_to_linear_data(skb, scratch, len); | ||
71 | |||
72 | while ((scratch += len, dlen -= len) > 0) { | ||
73 | skb_frag_t *frag; | ||
74 | |||
75 | err = -EMSGSIZE; | ||
76 | if (WARN_ON(skb_shinfo(skb)->nr_frags >= MAX_SKB_FRAGS)) | ||
77 | goto out; | ||
78 | |||
79 | frag = skb_shinfo(skb)->frags + skb_shinfo(skb)->nr_frags; | ||
80 | frag->page = alloc_page(GFP_ATOMIC); | ||
81 | |||
82 | err = -ENOMEM; | ||
83 | if (!frag->page) | ||
84 | goto out; | ||
85 | |||
86 | len = PAGE_SIZE; | ||
87 | if (dlen < len) | ||
88 | len = dlen; | ||
89 | |||
90 | memcpy(page_address(frag->page), scratch, len); | ||
91 | |||
92 | frag->page_offset = 0; | ||
93 | frag->size = len; | ||
94 | skb->truesize += len; | ||
95 | skb->data_len += len; | ||
96 | skb->len += len; | ||
97 | |||
98 | skb_shinfo(skb)->nr_frags++; | ||
99 | } | ||
100 | |||
101 | err = 0; | ||
102 | |||
103 | out: | ||
104 | put_cpu(); | ||
105 | return err; | ||
106 | } | ||
107 | |||
108 | int ipcomp_input(struct xfrm_state *x, struct sk_buff *skb) | ||
109 | { | ||
110 | int nexthdr; | ||
111 | int err = -ENOMEM; | ||
112 | struct ip_comp_hdr *ipch; | ||
113 | |||
114 | if (skb_linearize_cow(skb)) | ||
115 | goto out; | ||
116 | |||
117 | skb->ip_summed = CHECKSUM_NONE; | ||
118 | |||
119 | /* Remove ipcomp header and decompress original payload */ | ||
120 | ipch = (void *)skb->data; | ||
121 | nexthdr = ipch->nexthdr; | ||
122 | |||
123 | skb->transport_header = skb->network_header + sizeof(*ipch); | ||
124 | __skb_pull(skb, sizeof(*ipch)); | ||
125 | err = ipcomp_decompress(x, skb); | ||
126 | if (err) | ||
127 | goto out; | ||
128 | |||
129 | err = nexthdr; | ||
130 | |||
131 | out: | ||
132 | return err; | ||
133 | } | ||
134 | EXPORT_SYMBOL_GPL(ipcomp_input); | ||
135 | |||
136 | static int ipcomp_compress(struct xfrm_state *x, struct sk_buff *skb) | ||
137 | { | ||
138 | struct ipcomp_data *ipcd = x->data; | ||
139 | const int plen = skb->len; | ||
140 | int dlen = IPCOMP_SCRATCH_SIZE; | ||
141 | u8 *start = skb->data; | ||
142 | const int cpu = get_cpu(); | ||
143 | u8 *scratch = *per_cpu_ptr(ipcomp_scratches, cpu); | ||
144 | struct crypto_comp *tfm = *per_cpu_ptr(ipcd->tfms, cpu); | ||
145 | int err; | ||
146 | |||
147 | local_bh_disable(); | ||
148 | err = crypto_comp_compress(tfm, start, plen, scratch, &dlen); | ||
149 | local_bh_enable(); | ||
150 | if (err) | ||
151 | goto out; | ||
152 | |||
153 | if ((dlen + sizeof(struct ip_comp_hdr)) >= plen) { | ||
154 | err = -EMSGSIZE; | ||
155 | goto out; | ||
156 | } | ||
157 | |||
158 | memcpy(start + sizeof(struct ip_comp_hdr), scratch, dlen); | ||
159 | put_cpu(); | ||
160 | |||
161 | pskb_trim(skb, dlen + sizeof(struct ip_comp_hdr)); | ||
162 | return 0; | ||
163 | |||
164 | out: | ||
165 | put_cpu(); | ||
166 | return err; | ||
167 | } | ||
168 | |||
169 | int ipcomp_output(struct xfrm_state *x, struct sk_buff *skb) | ||
170 | { | ||
171 | int err; | ||
172 | struct ip_comp_hdr *ipch; | ||
173 | struct ipcomp_data *ipcd = x->data; | ||
174 | |||
175 | if (skb->len < ipcd->threshold) { | ||
176 | /* Don't bother compressing */ | ||
177 | goto out_ok; | ||
178 | } | ||
179 | |||
180 | if (skb_linearize_cow(skb)) | ||
181 | goto out_ok; | ||
182 | |||
183 | err = ipcomp_compress(x, skb); | ||
184 | |||
185 | if (err) { | ||
186 | goto out_ok; | ||
187 | } | ||
188 | |||
189 | /* Install ipcomp header, convert into ipcomp datagram. */ | ||
190 | ipch = ip_comp_hdr(skb); | ||
191 | ipch->nexthdr = *skb_mac_header(skb); | ||
192 | ipch->flags = 0; | ||
193 | ipch->cpi = htons((u16 )ntohl(x->id.spi)); | ||
194 | *skb_mac_header(skb) = IPPROTO_COMP; | ||
195 | out_ok: | ||
196 | skb_push(skb, -skb_network_offset(skb)); | ||
197 | return 0; | ||
198 | } | ||
199 | EXPORT_SYMBOL_GPL(ipcomp_output); | ||
200 | |||
201 | static void ipcomp_free_scratches(void) | ||
202 | { | ||
203 | int i; | ||
204 | void **scratches; | ||
205 | |||
206 | if (--ipcomp_scratch_users) | ||
207 | return; | ||
208 | |||
209 | scratches = ipcomp_scratches; | ||
210 | if (!scratches) | ||
211 | return; | ||
212 | |||
213 | for_each_possible_cpu(i) | ||
214 | vfree(*per_cpu_ptr(scratches, i)); | ||
215 | |||
216 | free_percpu(scratches); | ||
217 | } | ||
218 | |||
219 | static void **ipcomp_alloc_scratches(void) | ||
220 | { | ||
221 | int i; | ||
222 | void **scratches; | ||
223 | |||
224 | if (ipcomp_scratch_users++) | ||
225 | return ipcomp_scratches; | ||
226 | |||
227 | scratches = alloc_percpu(void *); | ||
228 | if (!scratches) | ||
229 | return NULL; | ||
230 | |||
231 | ipcomp_scratches = scratches; | ||
232 | |||
233 | for_each_possible_cpu(i) { | ||
234 | void *scratch = vmalloc(IPCOMP_SCRATCH_SIZE); | ||
235 | if (!scratch) | ||
236 | return NULL; | ||
237 | *per_cpu_ptr(scratches, i) = scratch; | ||
238 | } | ||
239 | |||
240 | return scratches; | ||
241 | } | ||
242 | |||
243 | static void ipcomp_free_tfms(struct crypto_comp **tfms) | ||
244 | { | ||
245 | struct ipcomp_tfms *pos; | ||
246 | int cpu; | ||
247 | |||
248 | list_for_each_entry(pos, &ipcomp_tfms_list, list) { | ||
249 | if (pos->tfms == tfms) | ||
250 | break; | ||
251 | } | ||
252 | |||
253 | WARN_ON(!pos); | ||
254 | |||
255 | if (--pos->users) | ||
256 | return; | ||
257 | |||
258 | list_del(&pos->list); | ||
259 | kfree(pos); | ||
260 | |||
261 | if (!tfms) | ||
262 | return; | ||
263 | |||
264 | for_each_possible_cpu(cpu) { | ||
265 | struct crypto_comp *tfm = *per_cpu_ptr(tfms, cpu); | ||
266 | crypto_free_comp(tfm); | ||
267 | } | ||
268 | free_percpu(tfms); | ||
269 | } | ||
270 | |||
271 | static struct crypto_comp **ipcomp_alloc_tfms(const char *alg_name) | ||
272 | { | ||
273 | struct ipcomp_tfms *pos; | ||
274 | struct crypto_comp **tfms; | ||
275 | int cpu; | ||
276 | |||
277 | /* This can be any valid CPU ID so we don't need locking. */ | ||
278 | cpu = raw_smp_processor_id(); | ||
279 | |||
280 | list_for_each_entry(pos, &ipcomp_tfms_list, list) { | ||
281 | struct crypto_comp *tfm; | ||
282 | |||
283 | tfms = pos->tfms; | ||
284 | tfm = *per_cpu_ptr(tfms, cpu); | ||
285 | |||
286 | if (!strcmp(crypto_comp_name(tfm), alg_name)) { | ||
287 | pos->users++; | ||
288 | return tfms; | ||
289 | } | ||
290 | } | ||
291 | |||
292 | pos = kmalloc(sizeof(*pos), GFP_KERNEL); | ||
293 | if (!pos) | ||
294 | return NULL; | ||
295 | |||
296 | pos->users = 1; | ||
297 | INIT_LIST_HEAD(&pos->list); | ||
298 | list_add(&pos->list, &ipcomp_tfms_list); | ||
299 | |||
300 | pos->tfms = tfms = alloc_percpu(struct crypto_comp *); | ||
301 | if (!tfms) | ||
302 | goto error; | ||
303 | |||
304 | for_each_possible_cpu(cpu) { | ||
305 | struct crypto_comp *tfm = crypto_alloc_comp(alg_name, 0, | ||
306 | CRYPTO_ALG_ASYNC); | ||
307 | if (IS_ERR(tfm)) | ||
308 | goto error; | ||
309 | *per_cpu_ptr(tfms, cpu) = tfm; | ||
310 | } | ||
311 | |||
312 | return tfms; | ||
313 | |||
314 | error: | ||
315 | ipcomp_free_tfms(tfms); | ||
316 | return NULL; | ||
317 | } | ||
318 | |||
319 | static void ipcomp_free_data(struct ipcomp_data *ipcd) | ||
320 | { | ||
321 | if (ipcd->tfms) | ||
322 | ipcomp_free_tfms(ipcd->tfms); | ||
323 | ipcomp_free_scratches(); | ||
324 | } | ||
325 | |||
326 | void ipcomp_destroy(struct xfrm_state *x) | ||
327 | { | ||
328 | struct ipcomp_data *ipcd = x->data; | ||
329 | if (!ipcd) | ||
330 | return; | ||
331 | xfrm_state_delete_tunnel(x); | ||
332 | mutex_lock(&ipcomp_resource_mutex); | ||
333 | ipcomp_free_data(ipcd); | ||
334 | mutex_unlock(&ipcomp_resource_mutex); | ||
335 | kfree(ipcd); | ||
336 | } | ||
337 | EXPORT_SYMBOL_GPL(ipcomp_destroy); | ||
338 | |||
339 | int ipcomp_init_state(struct xfrm_state *x) | ||
340 | { | ||
341 | int err; | ||
342 | struct ipcomp_data *ipcd; | ||
343 | struct xfrm_algo_desc *calg_desc; | ||
344 | |||
345 | err = -EINVAL; | ||
346 | if (!x->calg) | ||
347 | goto out; | ||
348 | |||
349 | if (x->encap) | ||
350 | goto out; | ||
351 | |||
352 | err = -ENOMEM; | ||
353 | ipcd = kzalloc(sizeof(*ipcd), GFP_KERNEL); | ||
354 | if (!ipcd) | ||
355 | goto out; | ||
356 | |||
357 | mutex_lock(&ipcomp_resource_mutex); | ||
358 | if (!ipcomp_alloc_scratches()) | ||
359 | goto error; | ||
360 | |||
361 | ipcd->tfms = ipcomp_alloc_tfms(x->calg->alg_name); | ||
362 | if (!ipcd->tfms) | ||
363 | goto error; | ||
364 | mutex_unlock(&ipcomp_resource_mutex); | ||
365 | |||
366 | calg_desc = xfrm_calg_get_byname(x->calg->alg_name, 0); | ||
367 | BUG_ON(!calg_desc); | ||
368 | ipcd->threshold = calg_desc->uinfo.comp.threshold; | ||
369 | x->data = ipcd; | ||
370 | err = 0; | ||
371 | out: | ||
372 | return err; | ||
373 | |||
374 | error: | ||
375 | ipcomp_free_data(ipcd); | ||
376 | mutex_unlock(&ipcomp_resource_mutex); | ||
377 | kfree(ipcd); | ||
378 | goto out; | ||
379 | } | ||
380 | EXPORT_SYMBOL_GPL(ipcomp_init_state); | ||
381 | |||
382 | MODULE_LICENSE("GPL"); | ||
383 | MODULE_DESCRIPTION("IP Payload Compression Protocol (IPComp) - RFC3173"); | ||
384 | MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>"); | ||
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index 72fddafd891a..4c6914ef7d92 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c | |||
@@ -538,7 +538,7 @@ EXPORT_SYMBOL(xfrm_state_alloc); | |||
538 | 538 | ||
539 | void __xfrm_state_destroy(struct xfrm_state *x) | 539 | void __xfrm_state_destroy(struct xfrm_state *x) |
540 | { | 540 | { |
541 | BUG_TRAP(x->km.state == XFRM_STATE_DEAD); | 541 | WARN_ON(x->km.state != XFRM_STATE_DEAD); |
542 | 542 | ||
543 | spin_lock_bh(&xfrm_state_lock); | 543 | spin_lock_bh(&xfrm_state_lock); |
544 | list_del(&x->all); | 544 | list_del(&x->all); |