aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-03-21 00:04:47 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-21 00:04:47 -0400
commit3b59bf081622b6446db77ad06c93fe23677bc533 (patch)
tree3f4bb5a27c90cc86994a1f6d3c53fbf9208003cb /net/ipv4
parente45836fafe157df137a837093037f741ad8f4c90 (diff)
parentbbdb32cb5b73597386913d052165423b9d736145 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
Pull networking merge from David Miller: "1) Move ixgbe driver over to purely page based buffering on receive. From Alexander Duyck. 2) Add receive packet steering support to e1000e, from Bruce Allan. 3) Convert TCP MD5 support over to RCU, from Eric Dumazet. 4) Reduce cpu usage in handling out-of-order TCP packets on modern systems, also from Eric Dumazet. 5) Support the IP{,V6}_UNICAST_IF socket options, making the wine folks happy, from Erich Hoover. 6) Support VLAN trunking from guests in hyperv driver, from Haiyang Zhang. 7) Support byte-queue-limtis in r8169, from Igor Maravic. 8) Outline code intended for IP_RECVTOS in IP_PKTOPTIONS existed but was never properly implemented, Jiri Benc fixed that. 9) 64-bit statistics support in r8169 and 8139too, from Junchang Wang. 10) Support kernel side dump filtering by ctmark in netfilter ctnetlink, from Pablo Neira Ayuso. 11) Support byte-queue-limits in gianfar driver, from Paul Gortmaker. 12) Add new peek socket options to assist with socket migration, from Pavel Emelyanov. 13) Add sch_plug packet scheduler whose queue is controlled by userland daemons using explicit freeze and release commands. From Shriram Rajagopalan. 14) Fix FCOE checksum offload handling on transmit, from Yi Zou." * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1846 commits) Fix pppol2tp getsockname() Remove printk from rds_sendmsg ipv6: fix incorrent ipv6 ipsec packet fragment cpsw: Hook up default ndo_change_mtu. net: qmi_wwan: fix build error due to cdc-wdm dependecy netdev: driver: ethernet: Add TI CPSW driver netdev: driver: ethernet: add cpsw address lookup engine support phy: add am79c874 PHY support mlx4_core: fix race on comm channel bonding: send igmp report for its master fs_enet: Add MPC5125 FEC support and PHY interface selection net: bpf_jit: fix BPF_S_LDX_B_MSH compilation net: update the usage of CHECKSUM_UNNECESSARY fcoe: use CHECKSUM_UNNECESSARY instead of CHECKSUM_PARTIAL on tx net: do not do gso for CHECKSUM_UNNECESSARY in netif_needs_gso ixgbe: Fix issues with SR-IOV loopback when flow control is disabled net/hyperv: Fix the code handling tx busy ixgbe: fix namespace issues when FCoE/DCB is not enabled rtlwifi: Remove unused ETH_ADDR_LEN defines igbvf: Use ETH_ALEN ... Fix up fairly trivial conflicts in drivers/isdn/gigaset/interface.c and drivers/net/usb/{Kconfig,qmi_wwan.c} as per David.
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/af_inet.c28
-rw-r--r--net/ipv4/ah4.c17
-rw-r--r--net/ipv4/arp.c2
-rw-r--r--net/ipv4/esp4.c10
-rw-r--r--net/ipv4/fib_frontend.c6
-rw-r--r--net/ipv4/fib_semantics.c2
-rw-r--r--net/ipv4/fib_trie.c5
-rw-r--r--net/ipv4/gre.c6
-rw-r--r--net/ipv4/icmp.c21
-rw-r--r--net/ipv4/inet_diag.c18
-rw-r--r--net/ipv4/ip_fragment.c11
-rw-r--r--net/ipv4/ip_gre.c29
-rw-r--r--net/ipv4/ip_input.c20
-rw-r--r--net/ipv4/ip_options.c4
-rw-r--r--net/ipv4/ip_sockglue.c37
-rw-r--r--net/ipv4/ipcomp.c8
-rw-r--r--net/ipv4/ipconfig.c110
-rw-r--r--net/ipv4/ipip.c7
-rw-r--r--net/ipv4/ipmr.c4
-rw-r--r--net/ipv4/netfilter/Kconfig9
-rw-r--r--net/ipv4/netfilter/Makefile1
-rw-r--r--net/ipv4/netfilter/ipt_LOG.c516
-rw-r--r--net/ipv4/netfilter/nf_conntrack_proto_icmp.c60
-rw-r--r--net/ipv4/netfilter/nf_nat_core.c8
-rw-r--r--net/ipv4/netfilter/nf_nat_h323.c14
-rw-r--r--net/ipv4/netfilter/nf_nat_sip.c7
-rw-r--r--net/ipv4/ping.c21
-rw-r--r--net/ipv4/proc.c2
-rw-r--r--net/ipv4/raw.c10
-rw-r--r--net/ipv4/route.c52
-rw-r--r--net/ipv4/tcp.c14
-rw-r--r--net/ipv4/tcp_cong.c9
-rw-r--r--net/ipv4/tcp_input.c241
-rw-r--r--net/ipv4/tcp_ipv4.c312
-rw-r--r--net/ipv4/tcp_minisocks.c12
-rw-r--r--net/ipv4/tcp_output.c4
-rw-r--r--net/ipv4/tcp_probe.c4
-rw-r--r--net/ipv4/tcp_timer.c14
-rw-r--r--net/ipv4/tunnel4.c8
-rw-r--r--net/ipv4/udp.c41
-rw-r--r--net/ipv4/udplite.c7
-rw-r--r--net/ipv4/xfrm4_tunnel.c16
42 files changed, 697 insertions, 1030 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index f7b5670744f..fdf49fd44bb 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -65,6 +65,8 @@
65 * 2 of the License, or (at your option) any later version. 65 * 2 of the License, or (at your option) any later version.
66 */ 66 */
67 67
68#define pr_fmt(fmt) "IPv4: " fmt
69
68#include <linux/err.h> 70#include <linux/err.h>
69#include <linux/errno.h> 71#include <linux/errno.h>
70#include <linux/types.h> 72#include <linux/types.h>
@@ -381,6 +383,7 @@ lookup_protocol:
381 inet->mc_all = 1; 383 inet->mc_all = 1;
382 inet->mc_index = 0; 384 inet->mc_index = 0;
383 inet->mc_list = NULL; 385 inet->mc_list = NULL;
386 inet->rcv_tos = 0;
384 387
385 sk_refcnt_debug_inc(sk); 388 sk_refcnt_debug_inc(sk);
386 389
@@ -1084,13 +1087,11 @@ out:
1084 return; 1087 return;
1085 1088
1086out_permanent: 1089out_permanent:
1087 printk(KERN_ERR "Attempt to override permanent protocol %d.\n", 1090 pr_err("Attempt to override permanent protocol %d\n", protocol);
1088 protocol);
1089 goto out; 1091 goto out;
1090 1092
1091out_illegal: 1093out_illegal:
1092 printk(KERN_ERR 1094 pr_err("Ignoring attempt to register invalid socket type %d\n",
1093 "Ignoring attempt to register invalid socket type %d.\n",
1094 p->type); 1095 p->type);
1095 goto out; 1096 goto out;
1096} 1097}
@@ -1099,8 +1100,7 @@ EXPORT_SYMBOL(inet_register_protosw);
1099void inet_unregister_protosw(struct inet_protosw *p) 1100void inet_unregister_protosw(struct inet_protosw *p)
1100{ 1101{
1101 if (INET_PROTOSW_PERMANENT & p->flags) { 1102 if (INET_PROTOSW_PERMANENT & p->flags) {
1102 printk(KERN_ERR 1103 pr_err("Attempt to unregister permanent protocol %d\n",
1103 "Attempt to unregister permanent protocol %d.\n",
1104 p->protocol); 1104 p->protocol);
1105 } else { 1105 } else {
1106 spin_lock_bh(&inetsw_lock); 1106 spin_lock_bh(&inetsw_lock);
@@ -1149,8 +1149,8 @@ static int inet_sk_reselect_saddr(struct sock *sk)
1149 return 0; 1149 return 0;
1150 1150
1151 if (sysctl_ip_dynaddr > 1) { 1151 if (sysctl_ip_dynaddr > 1) {
1152 printk(KERN_INFO "%s(): shifting inet->saddr from %pI4 to %pI4\n", 1152 pr_info("%s(): shifting inet->saddr from %pI4 to %pI4\n",
1153 __func__, &old_saddr, &new_saddr); 1153 __func__, &old_saddr, &new_saddr);
1154 } 1154 }
1155 1155
1156 inet->inet_saddr = inet->inet_rcv_saddr = new_saddr; 1156 inet->inet_saddr = inet->inet_rcv_saddr = new_saddr;
@@ -1679,14 +1679,14 @@ static int __init inet_init(void)
1679 */ 1679 */
1680 1680
1681 if (inet_add_protocol(&icmp_protocol, IPPROTO_ICMP) < 0) 1681 if (inet_add_protocol(&icmp_protocol, IPPROTO_ICMP) < 0)
1682 printk(KERN_CRIT "inet_init: Cannot add ICMP protocol\n"); 1682 pr_crit("%s: Cannot add ICMP protocol\n", __func__);
1683 if (inet_add_protocol(&udp_protocol, IPPROTO_UDP) < 0) 1683 if (inet_add_protocol(&udp_protocol, IPPROTO_UDP) < 0)
1684 printk(KERN_CRIT "inet_init: Cannot add UDP protocol\n"); 1684 pr_crit("%s: Cannot add UDP protocol\n", __func__);
1685 if (inet_add_protocol(&tcp_protocol, IPPROTO_TCP) < 0) 1685 if (inet_add_protocol(&tcp_protocol, IPPROTO_TCP) < 0)
1686 printk(KERN_CRIT "inet_init: Cannot add TCP protocol\n"); 1686 pr_crit("%s: Cannot add TCP protocol\n", __func__);
1687#ifdef CONFIG_IP_MULTICAST 1687#ifdef CONFIG_IP_MULTICAST
1688 if (inet_add_protocol(&igmp_protocol, IPPROTO_IGMP) < 0) 1688 if (inet_add_protocol(&igmp_protocol, IPPROTO_IGMP) < 0)
1689 printk(KERN_CRIT "inet_init: Cannot add IGMP protocol\n"); 1689 pr_crit("%s: Cannot add IGMP protocol\n", __func__);
1690#endif 1690#endif
1691 1691
1692 /* Register the socket-side information for inet_create. */ 1692 /* Register the socket-side information for inet_create. */
@@ -1733,14 +1733,14 @@ static int __init inet_init(void)
1733 */ 1733 */
1734#if defined(CONFIG_IP_MROUTE) 1734#if defined(CONFIG_IP_MROUTE)
1735 if (ip_mr_init()) 1735 if (ip_mr_init())
1736 printk(KERN_CRIT "inet_init: Cannot init ipv4 mroute\n"); 1736 pr_crit("%s: Cannot init ipv4 mroute\n", __func__);
1737#endif 1737#endif
1738 /* 1738 /*
1739 * Initialise per-cpu ipv4 mibs 1739 * Initialise per-cpu ipv4 mibs
1740 */ 1740 */
1741 1741
1742 if (init_ipv4_mibs()) 1742 if (init_ipv4_mibs())
1743 printk(KERN_CRIT "inet_init: Cannot init ipv4 mibs\n"); 1743 pr_crit("%s: Cannot init ipv4 mibs\n", __func__);
1744 1744
1745 ipv4_proc_init(); 1745 ipv4_proc_init();
1746 1746
diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
index 36d14406261..fd508b52601 100644
--- a/net/ipv4/ah4.c
+++ b/net/ipv4/ah4.c
@@ -1,3 +1,5 @@
1#define pr_fmt(fmt) "IPsec: " fmt
2
1#include <crypto/hash.h> 3#include <crypto/hash.h>
2#include <linux/err.h> 4#include <linux/err.h>
3#include <linux/module.h> 5#include <linux/module.h>
@@ -445,9 +447,10 @@ static int ah_init_state(struct xfrm_state *x)
445 447
446 if (aalg_desc->uinfo.auth.icv_fullbits/8 != 448 if (aalg_desc->uinfo.auth.icv_fullbits/8 !=
447 crypto_ahash_digestsize(ahash)) { 449 crypto_ahash_digestsize(ahash)) {
448 printk(KERN_INFO "AH: %s digestsize %u != %hu\n", 450 pr_info("%s: %s digestsize %u != %hu\n",
449 x->aalg->alg_name, crypto_ahash_digestsize(ahash), 451 __func__, x->aalg->alg_name,
450 aalg_desc->uinfo.auth.icv_fullbits/8); 452 crypto_ahash_digestsize(ahash),
453 aalg_desc->uinfo.auth.icv_fullbits / 8);
451 goto error; 454 goto error;
452 } 455 }
453 456
@@ -510,11 +513,11 @@ static const struct net_protocol ah4_protocol = {
510static int __init ah4_init(void) 513static int __init ah4_init(void)
511{ 514{
512 if (xfrm_register_type(&ah_type, AF_INET) < 0) { 515 if (xfrm_register_type(&ah_type, AF_INET) < 0) {
513 printk(KERN_INFO "ip ah init: can't add xfrm type\n"); 516 pr_info("%s: can't add xfrm type\n", __func__);
514 return -EAGAIN; 517 return -EAGAIN;
515 } 518 }
516 if (inet_add_protocol(&ah4_protocol, IPPROTO_AH) < 0) { 519 if (inet_add_protocol(&ah4_protocol, IPPROTO_AH) < 0) {
517 printk(KERN_INFO "ip ah init: can't add protocol\n"); 520 pr_info("%s: can't add protocol\n", __func__);
518 xfrm_unregister_type(&ah_type, AF_INET); 521 xfrm_unregister_type(&ah_type, AF_INET);
519 return -EAGAIN; 522 return -EAGAIN;
520 } 523 }
@@ -524,9 +527,9 @@ static int __init ah4_init(void)
524static void __exit ah4_fini(void) 527static void __exit ah4_fini(void)
525{ 528{
526 if (inet_del_protocol(&ah4_protocol, IPPROTO_AH) < 0) 529 if (inet_del_protocol(&ah4_protocol, IPPROTO_AH) < 0)
527 printk(KERN_INFO "ip ah close: can't remove protocol\n"); 530 pr_info("%s: can't remove protocol\n", __func__);
528 if (xfrm_unregister_type(&ah_type, AF_INET) < 0) 531 if (xfrm_unregister_type(&ah_type, AF_INET) < 0)
529 printk(KERN_INFO "ip ah close: can't remove xfrm type\n"); 532 pr_info("%s: can't remove xfrm type\n", __func__);
530} 533}
531 534
532module_init(ah4_init); 535module_init(ah4_init);
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index 63e49890ad3..73f46d691ab 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -889,7 +889,7 @@ static int arp_process(struct sk_buff *skb)
889 889
890 n = __neigh_lookup(&arp_tbl, &sip, dev, 0); 890 n = __neigh_lookup(&arp_tbl, &sip, dev, 0);
891 891
892 if (IPV4_DEVCONF_ALL(dev_net(dev), ARP_ACCEPT)) { 892 if (IN_DEV_ARP_ACCEPT(in_dev)) {
893 /* Unsolicited ARP is not accepted by default. 893 /* Unsolicited ARP is not accepted by default.
894 It is possible, that this option should be enabled for some 894 It is possible, that this option should be enabled for some
895 devices (strip is candidate) 895 devices (strip is candidate)
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index a5b413416da..89a47b35905 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -1,3 +1,5 @@
1#define pr_fmt(fmt) "IPsec: " fmt
2
1#include <crypto/aead.h> 3#include <crypto/aead.h>
2#include <crypto/authenc.h> 4#include <crypto/authenc.h>
3#include <linux/err.h> 5#include <linux/err.h>
@@ -706,11 +708,11 @@ static const struct net_protocol esp4_protocol = {
706static int __init esp4_init(void) 708static int __init esp4_init(void)
707{ 709{
708 if (xfrm_register_type(&esp_type, AF_INET) < 0) { 710 if (xfrm_register_type(&esp_type, AF_INET) < 0) {
709 printk(KERN_INFO "ip esp init: can't add xfrm type\n"); 711 pr_info("%s: can't add xfrm type\n", __func__);
710 return -EAGAIN; 712 return -EAGAIN;
711 } 713 }
712 if (inet_add_protocol(&esp4_protocol, IPPROTO_ESP) < 0) { 714 if (inet_add_protocol(&esp4_protocol, IPPROTO_ESP) < 0) {
713 printk(KERN_INFO "ip esp init: can't add protocol\n"); 715 pr_info("%s: can't add protocol\n", __func__);
714 xfrm_unregister_type(&esp_type, AF_INET); 716 xfrm_unregister_type(&esp_type, AF_INET);
715 return -EAGAIN; 717 return -EAGAIN;
716 } 718 }
@@ -720,9 +722,9 @@ static int __init esp4_init(void)
720static void __exit esp4_fini(void) 722static void __exit esp4_fini(void)
721{ 723{
722 if (inet_del_protocol(&esp4_protocol, IPPROTO_ESP) < 0) 724 if (inet_del_protocol(&esp4_protocol, IPPROTO_ESP) < 0)
723 printk(KERN_INFO "ip esp close: can't remove protocol\n"); 725 pr_info("%s: can't remove protocol\n", __func__);
724 if (xfrm_unregister_type(&esp_type, AF_INET) < 0) 726 if (xfrm_unregister_type(&esp_type, AF_INET) < 0)
725 printk(KERN_INFO "ip esp close: can't remove xfrm type\n"); 727 pr_info("%s: can't remove xfrm type\n", __func__);
726} 728}
727 729
728module_init(esp4_init); 730module_init(esp4_init);
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 92fc5f69f5d..76e72bacc21 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -695,7 +695,7 @@ void fib_add_ifaddr(struct in_ifaddr *ifa)
695 if (ifa->ifa_flags & IFA_F_SECONDARY) { 695 if (ifa->ifa_flags & IFA_F_SECONDARY) {
696 prim = inet_ifa_byprefix(in_dev, prefix, mask); 696 prim = inet_ifa_byprefix(in_dev, prefix, mask);
697 if (prim == NULL) { 697 if (prim == NULL) {
698 printk(KERN_WARNING "fib_add_ifaddr: bug: prim == NULL\n"); 698 pr_warn("%s: bug: prim == NULL\n", __func__);
699 return; 699 return;
700 } 700 }
701 } 701 }
@@ -749,11 +749,11 @@ void fib_del_ifaddr(struct in_ifaddr *ifa, struct in_ifaddr *iprim)
749 if (ifa->ifa_flags & IFA_F_SECONDARY) { 749 if (ifa->ifa_flags & IFA_F_SECONDARY) {
750 prim = inet_ifa_byprefix(in_dev, any, ifa->ifa_mask); 750 prim = inet_ifa_byprefix(in_dev, any, ifa->ifa_mask);
751 if (prim == NULL) { 751 if (prim == NULL) {
752 printk(KERN_WARNING "fib_del_ifaddr: bug: prim == NULL\n"); 752 pr_warn("%s: bug: prim == NULL\n", __func__);
753 return; 753 return;
754 } 754 }
755 if (iprim && iprim != prim) { 755 if (iprim && iprim != prim) {
756 printk(KERN_WARNING "fib_del_ifaddr: bug: iprim != prim\n"); 756 pr_warn("%s: bug: iprim != prim\n", __func__);
757 return; 757 return;
758 } 758 }
759 } else if (!ipv4_is_zeronet(any) && 759 } else if (!ipv4_is_zeronet(any) &&
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index 80106d89d54..a8c5c1d6715 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -154,7 +154,7 @@ static void free_fib_info_rcu(struct rcu_head *head)
154void free_fib_info(struct fib_info *fi) 154void free_fib_info(struct fib_info *fi)
155{ 155{
156 if (fi->fib_dead == 0) { 156 if (fi->fib_dead == 0) {
157 pr_warning("Freeing alive fib_info %p\n", fi); 157 pr_warn("Freeing alive fib_info %p\n", fi);
158 return; 158 return;
159 } 159 }
160 change_nexthops(fi) { 160 change_nexthops(fi) {
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 2b555a5521e..da9b9cb2282 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -1170,9 +1170,8 @@ static struct list_head *fib_insert_node(struct trie *t, u32 key, int plen)
1170 } 1170 }
1171 1171
1172 if (tp && tp->pos + tp->bits > 32) 1172 if (tp && tp->pos + tp->bits > 32)
1173 pr_warning("fib_trie" 1173 pr_warn("fib_trie tp=%p pos=%d, bits=%d, key=%0x plen=%d\n",
1174 " tp=%p pos=%d, bits=%d, key=%0x plen=%d\n", 1174 tp, tp->pos, tp->bits, key, plen);
1175 tp, tp->pos, tp->bits, key, plen);
1176 1175
1177 /* Rebalance the trie */ 1176 /* Rebalance the trie */
1178 1177
diff --git a/net/ipv4/gre.c b/net/ipv4/gre.c
index 8cb1ebb7cd7..42a491055c7 100644
--- a/net/ipv4/gre.c
+++ b/net/ipv4/gre.c
@@ -10,6 +10,8 @@
10 * 10 *
11 */ 11 */
12 12
13#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
14
13#include <linux/module.h> 15#include <linux/module.h>
14#include <linux/kernel.h> 16#include <linux/kernel.h>
15#include <linux/kmod.h> 17#include <linux/kmod.h>
@@ -118,10 +120,10 @@ static const struct net_protocol net_gre_protocol = {
118 120
119static int __init gre_init(void) 121static int __init gre_init(void)
120{ 122{
121 pr_info("GRE over IPv4 demultiplexor driver"); 123 pr_info("GRE over IPv4 demultiplexor driver\n");
122 124
123 if (inet_add_protocol(&net_gre_protocol, IPPROTO_GRE) < 0) { 125 if (inet_add_protocol(&net_gre_protocol, IPPROTO_GRE) < 0) {
124 pr_err("gre: can't add protocol\n"); 126 pr_err("can't add protocol\n");
125 return -EAGAIN; 127 return -EAGAIN;
126 } 128 }
127 129
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index ab188ae12fd..9664d353ccd 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -62,6 +62,8 @@
62 * 62 *
63 */ 63 */
64 64
65#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
66
65#include <linux/module.h> 67#include <linux/module.h>
66#include <linux/types.h> 68#include <linux/types.h>
67#include <linux/jiffies.h> 69#include <linux/jiffies.h>
@@ -670,7 +672,7 @@ static void icmp_unreach(struct sk_buff *skb)
670 break; 672 break;
671 case ICMP_FRAG_NEEDED: 673 case ICMP_FRAG_NEEDED:
672 if (ipv4_config.no_pmtu_disc) { 674 if (ipv4_config.no_pmtu_disc) {
673 LIMIT_NETDEBUG(KERN_INFO "ICMP: %pI4: fragmentation needed and DF set.\n", 675 LIMIT_NETDEBUG(KERN_INFO pr_fmt("%pI4: fragmentation needed and DF set\n"),
674 &iph->daddr); 676 &iph->daddr);
675 } else { 677 } else {
676 info = ip_rt_frag_needed(net, iph, 678 info = ip_rt_frag_needed(net, iph,
@@ -681,7 +683,7 @@ static void icmp_unreach(struct sk_buff *skb)
681 } 683 }
682 break; 684 break;
683 case ICMP_SR_FAILED: 685 case ICMP_SR_FAILED:
684 LIMIT_NETDEBUG(KERN_INFO "ICMP: %pI4: Source Route Failed.\n", 686 LIMIT_NETDEBUG(KERN_INFO pr_fmt("%pI4: Source Route Failed\n"),
685 &iph->daddr); 687 &iph->daddr);
686 break; 688 break;
687 default: 689 default:
@@ -713,13 +715,10 @@ static void icmp_unreach(struct sk_buff *skb)
713 if (!net->ipv4.sysctl_icmp_ignore_bogus_error_responses && 715 if (!net->ipv4.sysctl_icmp_ignore_bogus_error_responses &&
714 inet_addr_type(net, iph->daddr) == RTN_BROADCAST) { 716 inet_addr_type(net, iph->daddr) == RTN_BROADCAST) {
715 if (net_ratelimit()) 717 if (net_ratelimit())
716 printk(KERN_WARNING "%pI4 sent an invalid ICMP " 718 pr_warn("%pI4 sent an invalid ICMP type %u, code %u error to a broadcast: %pI4 on %s\n",
717 "type %u, code %u " 719 &ip_hdr(skb)->saddr,
718 "error to a broadcast: %pI4 on %s\n", 720 icmph->type, icmph->code,
719 &ip_hdr(skb)->saddr, 721 &iph->daddr, skb->dev->name);
720 icmph->type, icmph->code,
721 &iph->daddr,
722 skb->dev->name);
723 goto out; 722 goto out;
724 } 723 }
725 724
@@ -946,8 +945,8 @@ static void icmp_address_reply(struct sk_buff *skb)
946 break; 945 break;
947 } 946 }
948 if (!ifa && net_ratelimit()) { 947 if (!ifa && net_ratelimit()) {
949 printk(KERN_INFO "Wrong address mask %pI4 from %s/%pI4\n", 948 pr_info("Wrong address mask %pI4 from %s/%pI4\n",
950 mp, dev->name, &ip_hdr(skb)->saddr); 949 mp, dev->name, &ip_hdr(skb)->saddr);
951 } 950 }
952 } 951 }
953} 952}
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index fcf281819cd..8d25a1c557e 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -960,9 +960,12 @@ static int inet_diag_rcv_msg_compat(struct sk_buff *skb, struct nlmsghdr *nlh)
960 inet_diag_bc_audit(nla_data(attr), nla_len(attr))) 960 inet_diag_bc_audit(nla_data(attr), nla_len(attr)))
961 return -EINVAL; 961 return -EINVAL;
962 } 962 }
963 963 {
964 return netlink_dump_start(sock_diag_nlsk, skb, nlh, 964 struct netlink_dump_control c = {
965 inet_diag_dump_compat, NULL, 0); 965 .dump = inet_diag_dump_compat,
966 };
967 return netlink_dump_start(sock_diag_nlsk, skb, nlh, &c);
968 }
966 } 969 }
967 970
968 return inet_diag_get_exact_compat(skb, nlh); 971 return inet_diag_get_exact_compat(skb, nlh);
@@ -985,9 +988,12 @@ static int inet_diag_handler_dump(struct sk_buff *skb, struct nlmsghdr *h)
985 inet_diag_bc_audit(nla_data(attr), nla_len(attr))) 988 inet_diag_bc_audit(nla_data(attr), nla_len(attr)))
986 return -EINVAL; 989 return -EINVAL;
987 } 990 }
988 991 {
989 return netlink_dump_start(sock_diag_nlsk, skb, h, 992 struct netlink_dump_control c = {
990 inet_diag_dump, NULL, 0); 993 .dump = inet_diag_dump,
994 };
995 return netlink_dump_start(sock_diag_nlsk, skb, h, &c);
996 }
991 } 997 }
992 998
993 return inet_diag_get_exact(skb, h, (struct inet_diag_req_v2 *)NLMSG_DATA(h)); 999 return inet_diag_get_exact(skb, h, (struct inet_diag_req_v2 *)NLMSG_DATA(h));
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index 1f23a57aa9e..3727e234c88 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -20,6 +20,8 @@
20 * Patrick McHardy : LRU queue of frag heads for evictor. 20 * Patrick McHardy : LRU queue of frag heads for evictor.
21 */ 21 */
22 22
23#define pr_fmt(fmt) "IPv4: " fmt
24
23#include <linux/compiler.h> 25#include <linux/compiler.h>
24#include <linux/module.h> 26#include <linux/module.h>
25#include <linux/types.h> 27#include <linux/types.h>
@@ -299,7 +301,7 @@ static inline struct ipq *ip_find(struct net *net, struct iphdr *iph, u32 user)
299 return container_of(q, struct ipq, q); 301 return container_of(q, struct ipq, q);
300 302
301out_nomem: 303out_nomem:
302 LIMIT_NETDEBUG(KERN_ERR "ip_frag_create: no memory left !\n"); 304 LIMIT_NETDEBUG(KERN_ERR pr_fmt("ip_frag_create: no memory left !\n"));
303 return NULL; 305 return NULL;
304} 306}
305 307
@@ -637,14 +639,13 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *prev,
637 return 0; 639 return 0;
638 640
639out_nomem: 641out_nomem:
640 LIMIT_NETDEBUG(KERN_ERR "IP: queue_glue: no memory for gluing " 642 LIMIT_NETDEBUG(KERN_ERR pr_fmt("queue_glue: no memory for gluing queue %p\n"),
641 "queue %p\n", qp); 643 qp);
642 err = -ENOMEM; 644 err = -ENOMEM;
643 goto out_fail; 645 goto out_fail;
644out_oversize: 646out_oversize:
645 if (net_ratelimit()) 647 if (net_ratelimit())
646 printk(KERN_INFO "Oversized IP packet from %pI4.\n", 648 pr_info("Oversized IP packet from %pI4\n", &qp->saddr);
647 &qp->saddr);
648out_fail: 649out_fail:
649 IP_INC_STATS_BH(net, IPSTATS_MIB_REASMFAILS); 650 IP_INC_STATS_BH(net, IPSTATS_MIB_REASMFAILS);
650 return err; 651 return err;
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 38673d2860e..b57532d4742 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -10,6 +10,8 @@
10 * 10 *
11 */ 11 */
12 12
13#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
14
13#include <linux/capability.h> 15#include <linux/capability.h>
14#include <linux/module.h> 16#include <linux/module.h>
15#include <linux/types.h> 17#include <linux/types.h>
@@ -730,15 +732,16 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev
730 732
731 if (skb->protocol == htons(ETH_P_IP)) { 733 if (skb->protocol == htons(ETH_P_IP)) {
732 rt = skb_rtable(skb); 734 rt = skb_rtable(skb);
733 if ((dst = rt->rt_gateway) == 0) 735 dst = rt->rt_gateway;
734 goto tx_error_icmp;
735 } 736 }
736#if IS_ENABLED(CONFIG_IPV6) 737#if IS_ENABLED(CONFIG_IPV6)
737 else if (skb->protocol == htons(ETH_P_IPV6)) { 738 else if (skb->protocol == htons(ETH_P_IPV6)) {
738 struct neighbour *neigh = dst_get_neighbour_noref(skb_dst(skb));
739 const struct in6_addr *addr6; 739 const struct in6_addr *addr6;
740 struct neighbour *neigh;
741 bool do_tx_error_icmp;
740 int addr_type; 742 int addr_type;
741 743
744 neigh = dst_neigh_lookup(skb_dst(skb), &ipv6_hdr(skb)->daddr);
742 if (neigh == NULL) 745 if (neigh == NULL)
743 goto tx_error; 746 goto tx_error;
744 747
@@ -751,9 +754,14 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev
751 } 754 }
752 755
753 if ((addr_type & IPV6_ADDR_COMPATv4) == 0) 756 if ((addr_type & IPV6_ADDR_COMPATv4) == 0)
757 do_tx_error_icmp = true;
758 else {
759 do_tx_error_icmp = false;
760 dst = addr6->s6_addr32[3];
761 }
762 neigh_release(neigh);
763 if (do_tx_error_icmp)
754 goto tx_error_icmp; 764 goto tx_error_icmp;
755
756 dst = addr6->s6_addr32[3];
757 } 765 }
758#endif 766#endif
759 else 767 else
@@ -914,9 +922,10 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev
914 __IPTUNNEL_XMIT(tstats, &dev->stats); 922 __IPTUNNEL_XMIT(tstats, &dev->stats);
915 return NETDEV_TX_OK; 923 return NETDEV_TX_OK;
916 924
925#if IS_ENABLED(CONFIG_IPV6)
917tx_error_icmp: 926tx_error_icmp:
918 dst_link_failure(skb); 927 dst_link_failure(skb);
919 928#endif
920tx_error: 929tx_error:
921 dev->stats.tx_errors++; 930 dev->stats.tx_errors++;
922 dev_kfree_skb(skb); 931 dev_kfree_skb(skb);
@@ -1529,7 +1538,7 @@ static int ipgre_newlink(struct net *src_net, struct net_device *dev, struct nla
1529 return -EEXIST; 1538 return -EEXIST;
1530 1539
1531 if (dev->type == ARPHRD_ETHER && !tb[IFLA_ADDRESS]) 1540 if (dev->type == ARPHRD_ETHER && !tb[IFLA_ADDRESS])
1532 random_ether_addr(dev->dev_addr); 1541 eth_hw_addr_random(dev);
1533 1542
1534 mtu = ipgre_tunnel_bind_dev(dev); 1543 mtu = ipgre_tunnel_bind_dev(dev);
1535 if (!tb[IFLA_MTU]) 1544 if (!tb[IFLA_MTU])
@@ -1709,7 +1718,7 @@ static int __init ipgre_init(void)
1709{ 1718{
1710 int err; 1719 int err;
1711 1720
1712 printk(KERN_INFO "GRE over IPv4 tunneling driver\n"); 1721 pr_info("GRE over IPv4 tunneling driver\n");
1713 1722
1714 err = register_pernet_device(&ipgre_net_ops); 1723 err = register_pernet_device(&ipgre_net_ops);
1715 if (err < 0) 1724 if (err < 0)
@@ -1717,7 +1726,7 @@ static int __init ipgre_init(void)
1717 1726
1718 err = gre_add_protocol(&ipgre_protocol, GREPROTO_CISCO); 1727 err = gre_add_protocol(&ipgre_protocol, GREPROTO_CISCO);
1719 if (err < 0) { 1728 if (err < 0) {
1720 printk(KERN_INFO "ipgre init: can't add protocol\n"); 1729 pr_info("%s: can't add protocol\n", __func__);
1721 goto add_proto_failed; 1730 goto add_proto_failed;
1722 } 1731 }
1723 1732
@@ -1746,7 +1755,7 @@ static void __exit ipgre_fini(void)
1746 rtnl_link_unregister(&ipgre_tap_ops); 1755 rtnl_link_unregister(&ipgre_tap_ops);
1747 rtnl_link_unregister(&ipgre_link_ops); 1756 rtnl_link_unregister(&ipgre_link_ops);
1748 if (gre_del_protocol(&ipgre_protocol, GREPROTO_CISCO) < 0) 1757 if (gre_del_protocol(&ipgre_protocol, GREPROTO_CISCO) < 0)
1749 printk(KERN_INFO "ipgre close: can't remove protocol\n"); 1758 pr_info("%s: can't remove protocol\n", __func__);
1750 unregister_pernet_device(&ipgre_net_ops); 1759 unregister_pernet_device(&ipgre_net_ops);
1751} 1760}
1752 1761
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index 073a9b01c40..f3f1108940f 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -113,6 +113,8 @@
113 * 2 of the License, or (at your option) any later version. 113 * 2 of the License, or (at your option) any later version.
114 */ 114 */
115 115
116#define pr_fmt(fmt) "IPv4: " fmt
117
116#include <asm/system.h> 118#include <asm/system.h>
117#include <linux/module.h> 119#include <linux/module.h>
118#include <linux/types.h> 120#include <linux/types.h>
@@ -148,7 +150,7 @@
148/* 150/*
149 * Process Router Attention IP option (RFC 2113) 151 * Process Router Attention IP option (RFC 2113)
150 */ 152 */
151int ip_call_ra_chain(struct sk_buff *skb) 153bool ip_call_ra_chain(struct sk_buff *skb)
152{ 154{
153 struct ip_ra_chain *ra; 155 struct ip_ra_chain *ra;
154 u8 protocol = ip_hdr(skb)->protocol; 156 u8 protocol = ip_hdr(skb)->protocol;
@@ -167,7 +169,7 @@ int ip_call_ra_chain(struct sk_buff *skb)
167 net_eq(sock_net(sk), dev_net(dev))) { 169 net_eq(sock_net(sk), dev_net(dev))) {
168 if (ip_is_fragment(ip_hdr(skb))) { 170 if (ip_is_fragment(ip_hdr(skb))) {
169 if (ip_defrag(skb, IP_DEFRAG_CALL_RA_CHAIN)) 171 if (ip_defrag(skb, IP_DEFRAG_CALL_RA_CHAIN))
170 return 1; 172 return true;
171 } 173 }
172 if (last) { 174 if (last) {
173 struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC); 175 struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC);
@@ -180,9 +182,9 @@ int ip_call_ra_chain(struct sk_buff *skb)
180 182
181 if (last) { 183 if (last) {
182 raw_rcv(last, skb); 184 raw_rcv(last, skb);
183 return 1; 185 return true;
184 } 186 }
185 return 0; 187 return false;
186} 188}
187 189
188static int ip_local_deliver_finish(struct sk_buff *skb) 190static int ip_local_deliver_finish(struct sk_buff *skb)
@@ -265,7 +267,7 @@ int ip_local_deliver(struct sk_buff *skb)
265 ip_local_deliver_finish); 267 ip_local_deliver_finish);
266} 268}
267 269
268static inline int ip_rcv_options(struct sk_buff *skb) 270static inline bool ip_rcv_options(struct sk_buff *skb)
269{ 271{
270 struct ip_options *opt; 272 struct ip_options *opt;
271 const struct iphdr *iph; 273 const struct iphdr *iph;
@@ -299,8 +301,8 @@ static inline int ip_rcv_options(struct sk_buff *skb)
299 if (!IN_DEV_SOURCE_ROUTE(in_dev)) { 301 if (!IN_DEV_SOURCE_ROUTE(in_dev)) {
300 if (IN_DEV_LOG_MARTIANS(in_dev) && 302 if (IN_DEV_LOG_MARTIANS(in_dev) &&
301 net_ratelimit()) 303 net_ratelimit())
302 printk(KERN_INFO "source route option %pI4 -> %pI4\n", 304 pr_info("source route option %pI4 -> %pI4\n",
303 &iph->saddr, &iph->daddr); 305 &iph->saddr, &iph->daddr);
304 goto drop; 306 goto drop;
305 } 307 }
306 } 308 }
@@ -309,9 +311,9 @@ static inline int ip_rcv_options(struct sk_buff *skb)
309 goto drop; 311 goto drop;
310 } 312 }
311 313
312 return 0; 314 return false;
313drop: 315drop:
314 return -1; 316 return true;
315} 317}
316 318
317static int ip_rcv_finish(struct sk_buff *skb) 319static int ip_rcv_finish(struct sk_buff *skb)
diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c
index 42dd1a90ede..a0d0d9d9b87 100644
--- a/net/ipv4/ip_options.c
+++ b/net/ipv4/ip_options.c
@@ -9,6 +9,8 @@
9 * 9 *
10 */ 10 */
11 11
12#define pr_fmt(fmt) "IPv4: " fmt
13
12#include <linux/capability.h> 14#include <linux/capability.h>
13#include <linux/module.h> 15#include <linux/module.h>
14#include <linux/slab.h> 16#include <linux/slab.h>
@@ -577,7 +579,7 @@ void ip_forward_options(struct sk_buff *skb)
577 ip_rt_get_source(&optptr[srrptr-1], skb, rt); 579 ip_rt_get_source(&optptr[srrptr-1], skb, rt);
578 optptr[2] = srrptr+4; 580 optptr[2] = srrptr+4;
579 } else if (net_ratelimit()) 581 } else if (net_ratelimit())
580 printk(KERN_CRIT "ip_forward(): Argh! Destination lost!\n"); 582 pr_crit("%s(): Argh! Destination lost!\n", __func__);
581 if (opt->ts_needaddr) { 583 if (opt->ts_needaddr) {
582 optptr = raw + opt->ts; 584 optptr = raw + opt->ts;
583 ip_rt_get_source(&optptr[optptr[2]-9], skb, rt); 585 ip_rt_get_source(&optptr[optptr[2]-9], skb, rt);
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index 5343d9ac510..2fd0fba7712 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -464,6 +464,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
464 (1<<IP_ROUTER_ALERT) | (1<<IP_FREEBIND) | 464 (1<<IP_ROUTER_ALERT) | (1<<IP_FREEBIND) |
465 (1<<IP_PASSSEC) | (1<<IP_TRANSPARENT) | 465 (1<<IP_PASSSEC) | (1<<IP_TRANSPARENT) |
466 (1<<IP_MINTTL) | (1<<IP_NODEFRAG))) || 466 (1<<IP_MINTTL) | (1<<IP_NODEFRAG))) ||
467 optname == IP_UNICAST_IF ||
467 optname == IP_MULTICAST_TTL || 468 optname == IP_MULTICAST_TTL ||
468 optname == IP_MULTICAST_ALL || 469 optname == IP_MULTICAST_ALL ||
469 optname == IP_MULTICAST_LOOP || 470 optname == IP_MULTICAST_LOOP ||
@@ -623,6 +624,35 @@ static int do_ip_setsockopt(struct sock *sk, int level,
623 goto e_inval; 624 goto e_inval;
624 inet->mc_loop = !!val; 625 inet->mc_loop = !!val;
625 break; 626 break;
627 case IP_UNICAST_IF:
628 {
629 struct net_device *dev = NULL;
630 int ifindex;
631
632 if (optlen != sizeof(int))
633 goto e_inval;
634
635 ifindex = (__force int)ntohl((__force __be32)val);
636 if (ifindex == 0) {
637 inet->uc_index = 0;
638 err = 0;
639 break;
640 }
641
642 dev = dev_get_by_index(sock_net(sk), ifindex);
643 err = -EADDRNOTAVAIL;
644 if (!dev)
645 break;
646 dev_put(dev);
647
648 err = -EINVAL;
649 if (sk->sk_bound_dev_if)
650 break;
651
652 inet->uc_index = ifindex;
653 err = 0;
654 break;
655 }
626 case IP_MULTICAST_IF: 656 case IP_MULTICAST_IF:
627 { 657 {
628 struct ip_mreqn mreq; 658 struct ip_mreqn mreq;
@@ -1173,6 +1203,9 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
1173 case IP_MULTICAST_LOOP: 1203 case IP_MULTICAST_LOOP:
1174 val = inet->mc_loop; 1204 val = inet->mc_loop;
1175 break; 1205 break;
1206 case IP_UNICAST_IF:
1207 val = (__force int)htonl((__u32) inet->uc_index);
1208 break;
1176 case IP_MULTICAST_IF: 1209 case IP_MULTICAST_IF:
1177 { 1210 {
1178 struct in_addr addr; 1211 struct in_addr addr;
@@ -1251,6 +1284,10 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
1251 int hlim = inet->mc_ttl; 1284 int hlim = inet->mc_ttl;
1252 put_cmsg(&msg, SOL_IP, IP_TTL, sizeof(hlim), &hlim); 1285 put_cmsg(&msg, SOL_IP, IP_TTL, sizeof(hlim), &hlim);
1253 } 1286 }
1287 if (inet->cmsg_flags & IP_CMSG_TOS) {
1288 int tos = inet->rcv_tos;
1289 put_cmsg(&msg, SOL_IP, IP_TOS, sizeof(tos), &tos);
1290 }
1254 len -= msg.msg_controllen; 1291 len -= msg.msg_controllen;
1255 return put_user(len, optlen); 1292 return put_user(len, optlen);
1256 } 1293 }
diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
index c857f6f49b0..63b64c45a82 100644
--- a/net/ipv4/ipcomp.c
+++ b/net/ipv4/ipcomp.c
@@ -156,11 +156,11 @@ static const struct net_protocol ipcomp4_protocol = {
156static int __init ipcomp4_init(void) 156static int __init ipcomp4_init(void)
157{ 157{
158 if (xfrm_register_type(&ipcomp_type, AF_INET) < 0) { 158 if (xfrm_register_type(&ipcomp_type, AF_INET) < 0) {
159 printk(KERN_INFO "ipcomp init: can't add xfrm type\n"); 159 pr_info("%s: can't add xfrm type\n", __func__);
160 return -EAGAIN; 160 return -EAGAIN;
161 } 161 }
162 if (inet_add_protocol(&ipcomp4_protocol, IPPROTO_COMP) < 0) { 162 if (inet_add_protocol(&ipcomp4_protocol, IPPROTO_COMP) < 0) {
163 printk(KERN_INFO "ipcomp init: can't add protocol\n"); 163 pr_info("%s: can't add protocol\n", __func__);
164 xfrm_unregister_type(&ipcomp_type, AF_INET); 164 xfrm_unregister_type(&ipcomp_type, AF_INET);
165 return -EAGAIN; 165 return -EAGAIN;
166 } 166 }
@@ -170,9 +170,9 @@ static int __init ipcomp4_init(void)
170static void __exit ipcomp4_fini(void) 170static void __exit ipcomp4_fini(void)
171{ 171{
172 if (inet_del_protocol(&ipcomp4_protocol, IPPROTO_COMP) < 0) 172 if (inet_del_protocol(&ipcomp4_protocol, IPPROTO_COMP) < 0)
173 printk(KERN_INFO "ip ipcomp close: can't remove protocol\n"); 173 pr_info("%s: can't remove protocol\n", __func__);
174 if (xfrm_unregister_type(&ipcomp_type, AF_INET) < 0) 174 if (xfrm_unregister_type(&ipcomp_type, AF_INET) < 0)
175 printk(KERN_INFO "ip ipcomp close: can't remove xfrm type\n"); 175 pr_info("%s: can't remove xfrm type\n", __func__);
176} 176}
177 177
178module_init(ipcomp4_init); 178module_init(ipcomp4_init);
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index 6e412a60a91..92ac7e7363a 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -214,7 +214,7 @@ static int __init ic_open_devs(void)
214 if (!(dev->flags & IFF_LOOPBACK)) 214 if (!(dev->flags & IFF_LOOPBACK))
215 continue; 215 continue;
216 if (dev_change_flags(dev, dev->flags | IFF_UP) < 0) 216 if (dev_change_flags(dev, dev->flags | IFF_UP) < 0)
217 printk(KERN_ERR "IP-Config: Failed to open %s\n", dev->name); 217 pr_err("IP-Config: Failed to open %s\n", dev->name);
218 } 218 }
219 219
220 for_each_netdev(&init_net, dev) { 220 for_each_netdev(&init_net, dev) {
@@ -223,7 +223,8 @@ static int __init ic_open_devs(void)
223 if (dev->mtu >= 364) 223 if (dev->mtu >= 364)
224 able |= IC_BOOTP; 224 able |= IC_BOOTP;
225 else 225 else
226 printk(KERN_WARNING "DHCP/BOOTP: Ignoring device %s, MTU %d too small", dev->name, dev->mtu); 226 pr_warn("DHCP/BOOTP: Ignoring device %s, MTU %d too small",
227 dev->name, dev->mtu);
227 if (!(dev->flags & IFF_NOARP)) 228 if (!(dev->flags & IFF_NOARP))
228 able |= IC_RARP; 229 able |= IC_RARP;
229 able &= ic_proto_enabled; 230 able &= ic_proto_enabled;
@@ -231,7 +232,8 @@ static int __init ic_open_devs(void)
231 continue; 232 continue;
232 oflags = dev->flags; 233 oflags = dev->flags;
233 if (dev_change_flags(dev, oflags | IFF_UP) < 0) { 234 if (dev_change_flags(dev, oflags | IFF_UP) < 0) {
234 printk(KERN_ERR "IP-Config: Failed to open %s\n", dev->name); 235 pr_err("IP-Config: Failed to open %s\n",
236 dev->name);
235 continue; 237 continue;
236 } 238 }
237 if (!(d = kmalloc(sizeof(struct ic_device), GFP_KERNEL))) { 239 if (!(d = kmalloc(sizeof(struct ic_device), GFP_KERNEL))) {
@@ -273,9 +275,10 @@ have_carrier:
273 275
274 if (!ic_first_dev) { 276 if (!ic_first_dev) {
275 if (user_dev_name[0]) 277 if (user_dev_name[0])
276 printk(KERN_ERR "IP-Config: Device `%s' not found.\n", user_dev_name); 278 pr_err("IP-Config: Device `%s' not found\n",
279 user_dev_name);
277 else 280 else
278 printk(KERN_ERR "IP-Config: No network devices available.\n"); 281 pr_err("IP-Config: No network devices available\n");
279 return -ENODEV; 282 return -ENODEV;
280 } 283 }
281 return 0; 284 return 0;
@@ -359,17 +362,20 @@ static int __init ic_setup_if(void)
359 strcpy(ir.ifr_ifrn.ifrn_name, ic_dev->name); 362 strcpy(ir.ifr_ifrn.ifrn_name, ic_dev->name);
360 set_sockaddr(sin, ic_myaddr, 0); 363 set_sockaddr(sin, ic_myaddr, 0);
361 if ((err = ic_devinet_ioctl(SIOCSIFADDR, &ir)) < 0) { 364 if ((err = ic_devinet_ioctl(SIOCSIFADDR, &ir)) < 0) {
362 printk(KERN_ERR "IP-Config: Unable to set interface address (%d).\n", err); 365 pr_err("IP-Config: Unable to set interface address (%d)\n",
366 err);
363 return -1; 367 return -1;
364 } 368 }
365 set_sockaddr(sin, ic_netmask, 0); 369 set_sockaddr(sin, ic_netmask, 0);
366 if ((err = ic_devinet_ioctl(SIOCSIFNETMASK, &ir)) < 0) { 370 if ((err = ic_devinet_ioctl(SIOCSIFNETMASK, &ir)) < 0) {
367 printk(KERN_ERR "IP-Config: Unable to set interface netmask (%d).\n", err); 371 pr_err("IP-Config: Unable to set interface netmask (%d)\n",
372 err);
368 return -1; 373 return -1;
369 } 374 }
370 set_sockaddr(sin, ic_myaddr | ~ic_netmask, 0); 375 set_sockaddr(sin, ic_myaddr | ~ic_netmask, 0);
371 if ((err = ic_devinet_ioctl(SIOCSIFBRDADDR, &ir)) < 0) { 376 if ((err = ic_devinet_ioctl(SIOCSIFBRDADDR, &ir)) < 0) {
372 printk(KERN_ERR "IP-Config: Unable to set interface broadcast address (%d).\n", err); 377 pr_err("IP-Config: Unable to set interface broadcast address (%d)\n",
378 err);
373 return -1; 379 return -1;
374 } 380 }
375 /* Handle the case where we need non-standard MTU on the boot link (a network 381 /* Handle the case where we need non-standard MTU on the boot link (a network
@@ -380,8 +386,8 @@ static int __init ic_setup_if(void)
380 strcpy(ir.ifr_name, ic_dev->name); 386 strcpy(ir.ifr_name, ic_dev->name);
381 ir.ifr_mtu = ic_dev_mtu; 387 ir.ifr_mtu = ic_dev_mtu;
382 if ((err = ic_dev_ioctl(SIOCSIFMTU, &ir)) < 0) 388 if ((err = ic_dev_ioctl(SIOCSIFMTU, &ir)) < 0)
383 printk(KERN_ERR "IP-Config: Unable to set interface mtu to %d (%d).\n", 389 pr_err("IP-Config: Unable to set interface mtu to %d (%d)\n",
384 ic_dev_mtu, err); 390 ic_dev_mtu, err);
385 } 391 }
386 return 0; 392 return 0;
387} 393}
@@ -396,7 +402,7 @@ static int __init ic_setup_routes(void)
396 402
397 memset(&rm, 0, sizeof(rm)); 403 memset(&rm, 0, sizeof(rm));
398 if ((ic_gateway ^ ic_myaddr) & ic_netmask) { 404 if ((ic_gateway ^ ic_myaddr) & ic_netmask) {
399 printk(KERN_ERR "IP-Config: Gateway not on directly connected network.\n"); 405 pr_err("IP-Config: Gateway not on directly connected network\n");
400 return -1; 406 return -1;
401 } 407 }
402 set_sockaddr((struct sockaddr_in *) &rm.rt_dst, 0, 0); 408 set_sockaddr((struct sockaddr_in *) &rm.rt_dst, 0, 0);
@@ -404,7 +410,8 @@ static int __init ic_setup_routes(void)
404 set_sockaddr((struct sockaddr_in *) &rm.rt_gateway, ic_gateway, 0); 410 set_sockaddr((struct sockaddr_in *) &rm.rt_gateway, ic_gateway, 0);
405 rm.rt_flags = RTF_UP | RTF_GATEWAY; 411 rm.rt_flags = RTF_UP | RTF_GATEWAY;
406 if ((err = ic_route_ioctl(SIOCADDRT, &rm)) < 0) { 412 if ((err = ic_route_ioctl(SIOCADDRT, &rm)) < 0) {
407 printk(KERN_ERR "IP-Config: Cannot add default route (%d).\n", err); 413 pr_err("IP-Config: Cannot add default route (%d)\n",
414 err);
408 return -1; 415 return -1;
409 } 416 }
410 } 417 }
@@ -437,8 +444,8 @@ static int __init ic_defaults(void)
437 else if (IN_CLASSC(ntohl(ic_myaddr))) 444 else if (IN_CLASSC(ntohl(ic_myaddr)))
438 ic_netmask = htonl(IN_CLASSC_NET); 445 ic_netmask = htonl(IN_CLASSC_NET);
439 else { 446 else {
440 printk(KERN_ERR "IP-Config: Unable to guess netmask for address %pI4\n", 447 pr_err("IP-Config: Unable to guess netmask for address %pI4\n",
441 &ic_myaddr); 448 &ic_myaddr);
442 return -1; 449 return -1;
443 } 450 }
444 printk("IP-Config: Guessing netmask %pI4\n", &ic_netmask); 451 printk("IP-Config: Guessing netmask %pI4\n", &ic_netmask);
@@ -688,8 +695,8 @@ ic_dhcp_init_options(u8 *options)
688 e += len; 695 e += len;
689 } 696 }
690 if (*vendor_class_identifier) { 697 if (*vendor_class_identifier) {
691 printk(KERN_INFO "DHCP: sending class identifier \"%s\"\n", 698 pr_info("DHCP: sending class identifier \"%s\"\n",
692 vendor_class_identifier); 699 vendor_class_identifier);
693 *e++ = 60; /* Class-identifier */ 700 *e++ = 60; /* Class-identifier */
694 len = strlen(vendor_class_identifier); 701 len = strlen(vendor_class_identifier);
695 *e++ = len; 702 *e++ = len;
@@ -949,8 +956,7 @@ static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, str
949 /* Fragments are not supported */ 956 /* Fragments are not supported */
950 if (ip_is_fragment(h)) { 957 if (ip_is_fragment(h)) {
951 if (net_ratelimit()) 958 if (net_ratelimit())
952 printk(KERN_ERR "DHCP/BOOTP: Ignoring fragmented " 959 pr_err("DHCP/BOOTP: Ignoring fragmented reply\n");
953 "reply.\n");
954 goto drop; 960 goto drop;
955 } 961 }
956 962
@@ -999,8 +1005,7 @@ static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, str
999 if (b->op != BOOTP_REPLY || 1005 if (b->op != BOOTP_REPLY ||
1000 b->xid != d->xid) { 1006 b->xid != d->xid) {
1001 if (net_ratelimit()) 1007 if (net_ratelimit())
1002 printk(KERN_ERR "DHCP/BOOTP: Reply not for us, " 1008 pr_err("DHCP/BOOTP: Reply not for us, op[%x] xid[%x]\n",
1003 "op[%x] xid[%x]\n",
1004 b->op, b->xid); 1009 b->op, b->xid);
1005 goto drop_unlock; 1010 goto drop_unlock;
1006 } 1011 }
@@ -1008,7 +1013,7 @@ static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, str
1008 /* Is it a reply for the device we are configuring? */ 1013 /* Is it a reply for the device we are configuring? */
1009 if (b->xid != ic_dev_xid) { 1014 if (b->xid != ic_dev_xid) {
1010 if (net_ratelimit()) 1015 if (net_ratelimit())
1011 printk(KERN_ERR "DHCP/BOOTP: Ignoring delayed packet\n"); 1016 pr_err("DHCP/BOOTP: Ignoring delayed packet\n");
1012 goto drop_unlock; 1017 goto drop_unlock;
1013 } 1018 }
1014 1019
@@ -1146,17 +1151,17 @@ static int __init ic_dynamic(void)
1146 * are missing, and without DHCP/BOOTP/RARP we are unable to get it. 1151 * are missing, and without DHCP/BOOTP/RARP we are unable to get it.
1147 */ 1152 */
1148 if (!ic_proto_enabled) { 1153 if (!ic_proto_enabled) {
1149 printk(KERN_ERR "IP-Config: Incomplete network configuration information.\n"); 1154 pr_err("IP-Config: Incomplete network configuration information\n");
1150 return -1; 1155 return -1;
1151 } 1156 }
1152 1157
1153#ifdef IPCONFIG_BOOTP 1158#ifdef IPCONFIG_BOOTP
1154 if ((ic_proto_enabled ^ ic_proto_have_if) & IC_BOOTP) 1159 if ((ic_proto_enabled ^ ic_proto_have_if) & IC_BOOTP)
1155 printk(KERN_ERR "DHCP/BOOTP: No suitable device found.\n"); 1160 pr_err("DHCP/BOOTP: No suitable device found\n");
1156#endif 1161#endif
1157#ifdef IPCONFIG_RARP 1162#ifdef IPCONFIG_RARP
1158 if ((ic_proto_enabled ^ ic_proto_have_if) & IC_RARP) 1163 if ((ic_proto_enabled ^ ic_proto_have_if) & IC_RARP)
1159 printk(KERN_ERR "RARP: No suitable device found.\n"); 1164 pr_err("RARP: No suitable device found\n");
1160#endif 1165#endif
1161 1166
1162 if (!ic_proto_have_if) 1167 if (!ic_proto_have_if)
@@ -1183,11 +1188,11 @@ static int __init ic_dynamic(void)
1183 * [Actually we could now, but the nothing else running note still 1188 * [Actually we could now, but the nothing else running note still
1184 * applies.. - AC] 1189 * applies.. - AC]
1185 */ 1190 */
1186 printk(KERN_NOTICE "Sending %s%s%s requests .", 1191 pr_notice("Sending %s%s%s requests .",
1187 do_bootp 1192 do_bootp
1188 ? ((ic_proto_enabled & IC_USE_DHCP) ? "DHCP" : "BOOTP") : "", 1193 ? ((ic_proto_enabled & IC_USE_DHCP) ? "DHCP" : "BOOTP") : "",
1189 (do_bootp && do_rarp) ? " and " : "", 1194 (do_bootp && do_rarp) ? " and " : "",
1190 do_rarp ? "RARP" : ""); 1195 do_rarp ? "RARP" : "");
1191 1196
1192 start_jiffies = jiffies; 1197 start_jiffies = jiffies;
1193 d = ic_first_dev; 1198 d = ic_first_dev;
@@ -1216,13 +1221,13 @@ static int __init ic_dynamic(void)
1216 (ic_proto_enabled & IC_USE_DHCP) && 1221 (ic_proto_enabled & IC_USE_DHCP) &&
1217 ic_dhcp_msgtype != DHCPACK) { 1222 ic_dhcp_msgtype != DHCPACK) {
1218 ic_got_reply = 0; 1223 ic_got_reply = 0;
1219 printk(KERN_CONT ","); 1224 pr_cont(",");
1220 continue; 1225 continue;
1221 } 1226 }
1222#endif /* IPCONFIG_DHCP */ 1227#endif /* IPCONFIG_DHCP */
1223 1228
1224 if (ic_got_reply) { 1229 if (ic_got_reply) {
1225 printk(KERN_CONT " OK\n"); 1230 pr_cont(" OK\n");
1226 break; 1231 break;
1227 } 1232 }
1228 1233
@@ -1230,7 +1235,7 @@ static int __init ic_dynamic(void)
1230 continue; 1235 continue;
1231 1236
1232 if (! --retries) { 1237 if (! --retries) {
1233 printk(KERN_CONT " timed out!\n"); 1238 pr_cont(" timed out!\n");
1234 break; 1239 break;
1235 } 1240 }
1236 1241
@@ -1240,7 +1245,7 @@ static int __init ic_dynamic(void)
1240 if (timeout > CONF_TIMEOUT_MAX) 1245 if (timeout > CONF_TIMEOUT_MAX)
1241 timeout = CONF_TIMEOUT_MAX; 1246 timeout = CONF_TIMEOUT_MAX;
1242 1247
1243 printk(KERN_CONT "."); 1248 pr_cont(".");
1244 } 1249 }
1245 1250
1246#ifdef IPCONFIG_BOOTP 1251#ifdef IPCONFIG_BOOTP
@@ -1260,8 +1265,8 @@ static int __init ic_dynamic(void)
1260 printk("IP-Config: Got %s answer from %pI4, ", 1265 printk("IP-Config: Got %s answer from %pI4, ",
1261 ((ic_got_reply & IC_RARP) ? "RARP" 1266 ((ic_got_reply & IC_RARP) ? "RARP"
1262 : (ic_proto_enabled & IC_USE_DHCP) ? "DHCP" : "BOOTP"), 1267 : (ic_proto_enabled & IC_USE_DHCP) ? "DHCP" : "BOOTP"),
1263 &ic_servaddr); 1268 &ic_servaddr);
1264 printk(KERN_CONT "my address is %pI4\n", &ic_myaddr); 1269 pr_cont("my address is %pI4\n", &ic_myaddr);
1265 1270
1266 return 0; 1271 return 0;
1267} 1272}
@@ -1437,24 +1442,22 @@ static int __init ip_auto_config(void)
1437 */ 1442 */
1438#ifdef CONFIG_ROOT_NFS 1443#ifdef CONFIG_ROOT_NFS
1439 if (ROOT_DEV == Root_NFS) { 1444 if (ROOT_DEV == Root_NFS) {
1440 printk(KERN_ERR 1445 pr_err("IP-Config: Retrying forever (NFS root)...\n");
1441 "IP-Config: Retrying forever (NFS root)...\n");
1442 goto try_try_again; 1446 goto try_try_again;
1443 } 1447 }
1444#endif 1448#endif
1445 1449
1446 if (--retries) { 1450 if (--retries) {
1447 printk(KERN_ERR 1451 pr_err("IP-Config: Reopening network devices...\n");
1448 "IP-Config: Reopening network devices...\n");
1449 goto try_try_again; 1452 goto try_try_again;
1450 } 1453 }
1451 1454
1452 /* Oh, well. At least we tried. */ 1455 /* Oh, well. At least we tried. */
1453 printk(KERN_ERR "IP-Config: Auto-configuration of network failed.\n"); 1456 pr_err("IP-Config: Auto-configuration of network failed\n");
1454 return -1; 1457 return -1;
1455 } 1458 }
1456#else /* !DYNAMIC */ 1459#else /* !DYNAMIC */
1457 printk(KERN_ERR "IP-Config: Incomplete network configuration information.\n"); 1460 pr_err("IP-Config: Incomplete network configuration information\n");
1458 ic_close_devs(); 1461 ic_close_devs();
1459 return -1; 1462 return -1;
1460#endif /* IPCONFIG_DYNAMIC */ 1463#endif /* IPCONFIG_DYNAMIC */
@@ -1492,19 +1495,16 @@ static int __init ip_auto_config(void)
1492 /* 1495 /*
1493 * Clue in the operator. 1496 * Clue in the operator.
1494 */ 1497 */
1495 printk("IP-Config: Complete:\n"); 1498 pr_info("IP-Config: Complete:\n");
1496 printk(" device=%s", ic_dev->name); 1499 pr_info(" device=%s, addr=%pI4, mask=%pI4, gw=%pI4\n",
1497 printk(KERN_CONT ", addr=%pI4", &ic_myaddr); 1500 ic_dev->name, &ic_myaddr, &ic_netmask, &ic_gateway);
1498 printk(KERN_CONT ", mask=%pI4", &ic_netmask); 1501 pr_info(" host=%s, domain=%s, nis-domain=%s\n",
1499 printk(KERN_CONT ", gw=%pI4", &ic_gateway); 1502 utsname()->nodename, ic_domain, utsname()->domainname);
1500 printk(KERN_CONT ",\n host=%s, domain=%s, nis-domain=%s", 1503 pr_info(" bootserver=%pI4, rootserver=%pI4, rootpath=%s",
1501 utsname()->nodename, ic_domain, utsname()->domainname); 1504 &ic_servaddr, &root_server_addr, root_server_path);
1502 printk(KERN_CONT ",\n bootserver=%pI4", &ic_servaddr);
1503 printk(KERN_CONT ", rootserver=%pI4", &root_server_addr);
1504 printk(KERN_CONT ", rootpath=%s", root_server_path);
1505 if (ic_dev_mtu) 1505 if (ic_dev_mtu)
1506 printk(KERN_CONT ", mtu=%d", ic_dev_mtu); 1506 pr_cont(", mtu=%d", ic_dev_mtu);
1507 printk(KERN_CONT "\n"); 1507 pr_cont("\n");
1508#endif /* !SILENT */ 1508#endif /* !SILENT */
1509 1509
1510 return 0; 1510 return 0;
@@ -1637,8 +1637,8 @@ static int __init vendor_class_identifier_setup(char *addrs)
1637 if (strlcpy(vendor_class_identifier, addrs, 1637 if (strlcpy(vendor_class_identifier, addrs,
1638 sizeof(vendor_class_identifier)) 1638 sizeof(vendor_class_identifier))
1639 >= sizeof(vendor_class_identifier)) 1639 >= sizeof(vendor_class_identifier))
1640 printk(KERN_WARNING "DHCP: vendorclass too long, truncated to \"%s\"", 1640 pr_warn("DHCP: vendorclass too long, truncated to \"%s\"",
1641 vendor_class_identifier); 1641 vendor_class_identifier);
1642 return 1; 1642 return 1;
1643} 1643}
1644 1644
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
index 22a19931530..ae1413e3f2f 100644
--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -454,8 +454,7 @@ static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
454 dev->stats.tx_fifo_errors++; 454 dev->stats.tx_fifo_errors++;
455 goto tx_error; 455 goto tx_error;
456 } 456 }
457 if ((dst = rt->rt_gateway) == 0) 457 dst = rt->rt_gateway;
458 goto tx_error_icmp;
459 } 458 }
460 459
461 rt = ip_route_output_ports(dev_net(dev), &fl4, NULL, 460 rt = ip_route_output_ports(dev_net(dev), &fl4, NULL,
@@ -893,7 +892,7 @@ static int __init ipip_init(void)
893 err = xfrm4_tunnel_register(&ipip_handler, AF_INET); 892 err = xfrm4_tunnel_register(&ipip_handler, AF_INET);
894 if (err < 0) { 893 if (err < 0) {
895 unregister_pernet_device(&ipip_net_ops); 894 unregister_pernet_device(&ipip_net_ops);
896 printk(KERN_INFO "ipip init: can't register tunnel\n"); 895 pr_info("%s: can't register tunnel\n", __func__);
897 } 896 }
898 return err; 897 return err;
899} 898}
@@ -901,7 +900,7 @@ static int __init ipip_init(void)
901static void __exit ipip_fini(void) 900static void __exit ipip_fini(void)
902{ 901{
903 if (xfrm4_tunnel_deregister(&ipip_handler, AF_INET)) 902 if (xfrm4_tunnel_deregister(&ipip_handler, AF_INET))
904 printk(KERN_INFO "ipip close: can't deregister tunnel\n"); 903 pr_info("%s: can't deregister tunnel\n", __func__);
905 904
906 unregister_pernet_device(&ipip_net_ops); 905 unregister_pernet_device(&ipip_net_ops);
907} 906}
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 7bc2db6db8d..0518a4fb177 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -951,7 +951,7 @@ static int ipmr_cache_report(struct mr_table *mrt,
951 rcu_read_unlock(); 951 rcu_read_unlock();
952 if (ret < 0) { 952 if (ret < 0) {
953 if (net_ratelimit()) 953 if (net_ratelimit())
954 printk(KERN_WARNING "mroute: pending queue full, dropping entries.\n"); 954 pr_warn("mroute: pending queue full, dropping entries\n");
955 kfree_skb(skb); 955 kfree_skb(skb);
956 } 956 }
957 957
@@ -2538,7 +2538,7 @@ int __init ip_mr_init(void)
2538 goto reg_notif_fail; 2538 goto reg_notif_fail;
2539#ifdef CONFIG_IP_PIMSM_V2 2539#ifdef CONFIG_IP_PIMSM_V2
2540 if (inet_add_protocol(&pim_protocol, IPPROTO_PIM) < 0) { 2540 if (inet_add_protocol(&pim_protocol, IPPROTO_PIM) < 0) {
2541 printk(KERN_ERR "ip_mr_init: can't add PIM protocol\n"); 2541 pr_err("%s: can't add PIM protocol\n", __func__);
2542 err = -EAGAIN; 2542 err = -EAGAIN;
2543 goto add_proto_fail; 2543 goto add_proto_fail;
2544 } 2544 }
diff --git a/net/ipv4/netfilter/Kconfig b/net/ipv4/netfilter/Kconfig
index 74dfc9e5211..fcc543cd987 100644
--- a/net/ipv4/netfilter/Kconfig
+++ b/net/ipv4/netfilter/Kconfig
@@ -123,15 +123,6 @@ config IP_NF_TARGET_REJECT
123 123
124 To compile it as a module, choose M here. If unsure, say N. 124 To compile it as a module, choose M here. If unsure, say N.
125 125
126config IP_NF_TARGET_LOG
127 tristate "LOG target support"
128 default m if NETFILTER_ADVANCED=n
129 help
130 This option adds a `LOG' target, which allows you to create rules in
131 any iptables table which records the packet header to the syslog.
132
133 To compile it as a module, choose M here. If unsure, say N.
134
135config IP_NF_TARGET_ULOG 126config IP_NF_TARGET_ULOG
136 tristate "ULOG target support" 127 tristate "ULOG target support"
137 default m if NETFILTER_ADVANCED=n 128 default m if NETFILTER_ADVANCED=n
diff --git a/net/ipv4/netfilter/Makefile b/net/ipv4/netfilter/Makefile
index 213a462b739..240b68469a7 100644
--- a/net/ipv4/netfilter/Makefile
+++ b/net/ipv4/netfilter/Makefile
@@ -54,7 +54,6 @@ obj-$(CONFIG_IP_NF_MATCH_RPFILTER) += ipt_rpfilter.o
54# targets 54# targets
55obj-$(CONFIG_IP_NF_TARGET_CLUSTERIP) += ipt_CLUSTERIP.o 55obj-$(CONFIG_IP_NF_TARGET_CLUSTERIP) += ipt_CLUSTERIP.o
56obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o 56obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o
57obj-$(CONFIG_IP_NF_TARGET_LOG) += ipt_LOG.o
58obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += ipt_MASQUERADE.o 57obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += ipt_MASQUERADE.o
59obj-$(CONFIG_IP_NF_TARGET_NETMAP) += ipt_NETMAP.o 58obj-$(CONFIG_IP_NF_TARGET_NETMAP) += ipt_NETMAP.o
60obj-$(CONFIG_IP_NF_TARGET_REDIRECT) += ipt_REDIRECT.o 59obj-$(CONFIG_IP_NF_TARGET_REDIRECT) += ipt_REDIRECT.o
diff --git a/net/ipv4/netfilter/ipt_LOG.c b/net/ipv4/netfilter/ipt_LOG.c
deleted file mode 100644
index d76d6c9ed94..00000000000
--- a/net/ipv4/netfilter/ipt_LOG.c
+++ /dev/null
@@ -1,516 +0,0 @@
1/*
2 * This is a module which is used for logging packets.
3 */
4
5/* (C) 1999-2001 Paul `Rusty' Russell
6 * (C) 2002-2004 Netfilter Core Team <coreteam@netfilter.org>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13#include <linux/module.h>
14#include <linux/spinlock.h>
15#include <linux/skbuff.h>
16#include <linux/if_arp.h>
17#include <linux/ip.h>
18#include <net/icmp.h>
19#include <net/udp.h>
20#include <net/tcp.h>
21#include <net/route.h>
22
23#include <linux/netfilter.h>
24#include <linux/netfilter/x_tables.h>
25#include <linux/netfilter_ipv4/ipt_LOG.h>
26#include <net/netfilter/nf_log.h>
27#include <net/netfilter/xt_log.h>
28
29MODULE_LICENSE("GPL");
30MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
31MODULE_DESCRIPTION("Xtables: IPv4 packet logging to syslog");
32
33/* One level of recursion won't kill us */
34static void dump_packet(struct sbuff *m,
35 const struct nf_loginfo *info,
36 const struct sk_buff *skb,
37 unsigned int iphoff)
38{
39 struct iphdr _iph;
40 const struct iphdr *ih;
41 unsigned int logflags;
42
43 if (info->type == NF_LOG_TYPE_LOG)
44 logflags = info->u.log.logflags;
45 else
46 logflags = NF_LOG_MASK;
47
48 ih = skb_header_pointer(skb, iphoff, sizeof(_iph), &_iph);
49 if (ih == NULL) {
50 sb_add(m, "TRUNCATED");
51 return;
52 }
53
54 /* Important fields:
55 * TOS, len, DF/MF, fragment offset, TTL, src, dst, options. */
56 /* Max length: 40 "SRC=255.255.255.255 DST=255.255.255.255 " */
57 sb_add(m, "SRC=%pI4 DST=%pI4 ",
58 &ih->saddr, &ih->daddr);
59
60 /* Max length: 46 "LEN=65535 TOS=0xFF PREC=0xFF TTL=255 ID=65535 " */
61 sb_add(m, "LEN=%u TOS=0x%02X PREC=0x%02X TTL=%u ID=%u ",
62 ntohs(ih->tot_len), ih->tos & IPTOS_TOS_MASK,
63 ih->tos & IPTOS_PREC_MASK, ih->ttl, ntohs(ih->id));
64
65 /* Max length: 6 "CE DF MF " */
66 if (ntohs(ih->frag_off) & IP_CE)
67 sb_add(m, "CE ");
68 if (ntohs(ih->frag_off) & IP_DF)
69 sb_add(m, "DF ");
70 if (ntohs(ih->frag_off) & IP_MF)
71 sb_add(m, "MF ");
72
73 /* Max length: 11 "FRAG:65535 " */
74 if (ntohs(ih->frag_off) & IP_OFFSET)
75 sb_add(m, "FRAG:%u ", ntohs(ih->frag_off) & IP_OFFSET);
76
77 if ((logflags & IPT_LOG_IPOPT) &&
78 ih->ihl * 4 > sizeof(struct iphdr)) {
79 const unsigned char *op;
80 unsigned char _opt[4 * 15 - sizeof(struct iphdr)];
81 unsigned int i, optsize;
82
83 optsize = ih->ihl * 4 - sizeof(struct iphdr);
84 op = skb_header_pointer(skb, iphoff+sizeof(_iph),
85 optsize, _opt);
86 if (op == NULL) {
87 sb_add(m, "TRUNCATED");
88 return;
89 }
90
91 /* Max length: 127 "OPT (" 15*4*2chars ") " */
92 sb_add(m, "OPT (");
93 for (i = 0; i < optsize; i++)
94 sb_add(m, "%02X", op[i]);
95 sb_add(m, ") ");
96 }
97
98 switch (ih->protocol) {
99 case IPPROTO_TCP: {
100 struct tcphdr _tcph;
101 const struct tcphdr *th;
102
103 /* Max length: 10 "PROTO=TCP " */
104 sb_add(m, "PROTO=TCP ");
105
106 if (ntohs(ih->frag_off) & IP_OFFSET)
107 break;
108
109 /* Max length: 25 "INCOMPLETE [65535 bytes] " */
110 th = skb_header_pointer(skb, iphoff + ih->ihl * 4,
111 sizeof(_tcph), &_tcph);
112 if (th == NULL) {
113 sb_add(m, "INCOMPLETE [%u bytes] ",
114 skb->len - iphoff - ih->ihl*4);
115 break;
116 }
117
118 /* Max length: 20 "SPT=65535 DPT=65535 " */
119 sb_add(m, "SPT=%u DPT=%u ",
120 ntohs(th->source), ntohs(th->dest));
121 /* Max length: 30 "SEQ=4294967295 ACK=4294967295 " */
122 if (logflags & IPT_LOG_TCPSEQ)
123 sb_add(m, "SEQ=%u ACK=%u ",
124 ntohl(th->seq), ntohl(th->ack_seq));
125 /* Max length: 13 "WINDOW=65535 " */
126 sb_add(m, "WINDOW=%u ", ntohs(th->window));
127 /* Max length: 9 "RES=0x3F " */
128 sb_add(m, "RES=0x%02x ", (u8)(ntohl(tcp_flag_word(th) & TCP_RESERVED_BITS) >> 22));
129 /* Max length: 32 "CWR ECE URG ACK PSH RST SYN FIN " */
130 if (th->cwr)
131 sb_add(m, "CWR ");
132 if (th->ece)
133 sb_add(m, "ECE ");
134 if (th->urg)
135 sb_add(m, "URG ");
136 if (th->ack)
137 sb_add(m, "ACK ");
138 if (th->psh)
139 sb_add(m, "PSH ");
140 if (th->rst)
141 sb_add(m, "RST ");
142 if (th->syn)
143 sb_add(m, "SYN ");
144 if (th->fin)
145 sb_add(m, "FIN ");
146 /* Max length: 11 "URGP=65535 " */
147 sb_add(m, "URGP=%u ", ntohs(th->urg_ptr));
148
149 if ((logflags & IPT_LOG_TCPOPT) &&
150 th->doff * 4 > sizeof(struct tcphdr)) {
151 unsigned char _opt[4 * 15 - sizeof(struct tcphdr)];
152 const unsigned char *op;
153 unsigned int i, optsize;
154
155 optsize = th->doff * 4 - sizeof(struct tcphdr);
156 op = skb_header_pointer(skb,
157 iphoff+ih->ihl*4+sizeof(_tcph),
158 optsize, _opt);
159 if (op == NULL) {
160 sb_add(m, "TRUNCATED");
161 return;
162 }
163
164 /* Max length: 127 "OPT (" 15*4*2chars ") " */
165 sb_add(m, "OPT (");
166 for (i = 0; i < optsize; i++)
167 sb_add(m, "%02X", op[i]);
168 sb_add(m, ") ");
169 }
170 break;
171 }
172 case IPPROTO_UDP:
173 case IPPROTO_UDPLITE: {
174 struct udphdr _udph;
175 const struct udphdr *uh;
176
177 if (ih->protocol == IPPROTO_UDP)
178 /* Max length: 10 "PROTO=UDP " */
179 sb_add(m, "PROTO=UDP " );
180 else /* Max length: 14 "PROTO=UDPLITE " */
181 sb_add(m, "PROTO=UDPLITE ");
182
183 if (ntohs(ih->frag_off) & IP_OFFSET)
184 break;
185
186 /* Max length: 25 "INCOMPLETE [65535 bytes] " */
187 uh = skb_header_pointer(skb, iphoff+ih->ihl*4,
188 sizeof(_udph), &_udph);
189 if (uh == NULL) {
190 sb_add(m, "INCOMPLETE [%u bytes] ",
191 skb->len - iphoff - ih->ihl*4);
192 break;
193 }
194
195 /* Max length: 20 "SPT=65535 DPT=65535 " */
196 sb_add(m, "SPT=%u DPT=%u LEN=%u ",
197 ntohs(uh->source), ntohs(uh->dest),
198 ntohs(uh->len));
199 break;
200 }
201 case IPPROTO_ICMP: {
202 struct icmphdr _icmph;
203 const struct icmphdr *ich;
204 static const size_t required_len[NR_ICMP_TYPES+1]
205 = { [ICMP_ECHOREPLY] = 4,
206 [ICMP_DEST_UNREACH]
207 = 8 + sizeof(struct iphdr),
208 [ICMP_SOURCE_QUENCH]
209 = 8 + sizeof(struct iphdr),
210 [ICMP_REDIRECT]
211 = 8 + sizeof(struct iphdr),
212 [ICMP_ECHO] = 4,
213 [ICMP_TIME_EXCEEDED]
214 = 8 + sizeof(struct iphdr),
215 [ICMP_PARAMETERPROB]
216 = 8 + sizeof(struct iphdr),
217 [ICMP_TIMESTAMP] = 20,
218 [ICMP_TIMESTAMPREPLY] = 20,
219 [ICMP_ADDRESS] = 12,
220 [ICMP_ADDRESSREPLY] = 12 };
221
222 /* Max length: 11 "PROTO=ICMP " */
223 sb_add(m, "PROTO=ICMP ");
224
225 if (ntohs(ih->frag_off) & IP_OFFSET)
226 break;
227
228 /* Max length: 25 "INCOMPLETE [65535 bytes] " */
229 ich = skb_header_pointer(skb, iphoff + ih->ihl * 4,
230 sizeof(_icmph), &_icmph);
231 if (ich == NULL) {
232 sb_add(m, "INCOMPLETE [%u bytes] ",
233 skb->len - iphoff - ih->ihl*4);
234 break;
235 }
236
237 /* Max length: 18 "TYPE=255 CODE=255 " */
238 sb_add(m, "TYPE=%u CODE=%u ", ich->type, ich->code);
239
240 /* Max length: 25 "INCOMPLETE [65535 bytes] " */
241 if (ich->type <= NR_ICMP_TYPES &&
242 required_len[ich->type] &&
243 skb->len-iphoff-ih->ihl*4 < required_len[ich->type]) {
244 sb_add(m, "INCOMPLETE [%u bytes] ",
245 skb->len - iphoff - ih->ihl*4);
246 break;
247 }
248
249 switch (ich->type) {
250 case ICMP_ECHOREPLY:
251 case ICMP_ECHO:
252 /* Max length: 19 "ID=65535 SEQ=65535 " */
253 sb_add(m, "ID=%u SEQ=%u ",
254 ntohs(ich->un.echo.id),
255 ntohs(ich->un.echo.sequence));
256 break;
257
258 case ICMP_PARAMETERPROB:
259 /* Max length: 14 "PARAMETER=255 " */
260 sb_add(m, "PARAMETER=%u ",
261 ntohl(ich->un.gateway) >> 24);
262 break;
263 case ICMP_REDIRECT:
264 /* Max length: 24 "GATEWAY=255.255.255.255 " */
265 sb_add(m, "GATEWAY=%pI4 ", &ich->un.gateway);
266 /* Fall through */
267 case ICMP_DEST_UNREACH:
268 case ICMP_SOURCE_QUENCH:
269 case ICMP_TIME_EXCEEDED:
270 /* Max length: 3+maxlen */
271 if (!iphoff) { /* Only recurse once. */
272 sb_add(m, "[");
273 dump_packet(m, info, skb,
274 iphoff + ih->ihl*4+sizeof(_icmph));
275 sb_add(m, "] ");
276 }
277
278 /* Max length: 10 "MTU=65535 " */
279 if (ich->type == ICMP_DEST_UNREACH &&
280 ich->code == ICMP_FRAG_NEEDED)
281 sb_add(m, "MTU=%u ", ntohs(ich->un.frag.mtu));
282 }
283 break;
284 }
285 /* Max Length */
286 case IPPROTO_AH: {
287 struct ip_auth_hdr _ahdr;
288 const struct ip_auth_hdr *ah;
289
290 if (ntohs(ih->frag_off) & IP_OFFSET)
291 break;
292
293 /* Max length: 9 "PROTO=AH " */
294 sb_add(m, "PROTO=AH ");
295
296 /* Max length: 25 "INCOMPLETE [65535 bytes] " */
297 ah = skb_header_pointer(skb, iphoff+ih->ihl*4,
298 sizeof(_ahdr), &_ahdr);
299 if (ah == NULL) {
300 sb_add(m, "INCOMPLETE [%u bytes] ",
301 skb->len - iphoff - ih->ihl*4);
302 break;
303 }
304
305 /* Length: 15 "SPI=0xF1234567 " */
306 sb_add(m, "SPI=0x%x ", ntohl(ah->spi));
307 break;
308 }
309 case IPPROTO_ESP: {
310 struct ip_esp_hdr _esph;
311 const struct ip_esp_hdr *eh;
312
313 /* Max length: 10 "PROTO=ESP " */
314 sb_add(m, "PROTO=ESP ");
315
316 if (ntohs(ih->frag_off) & IP_OFFSET)
317 break;
318
319 /* Max length: 25 "INCOMPLETE [65535 bytes] " */
320 eh = skb_header_pointer(skb, iphoff+ih->ihl*4,
321 sizeof(_esph), &_esph);
322 if (eh == NULL) {
323 sb_add(m, "INCOMPLETE [%u bytes] ",
324 skb->len - iphoff - ih->ihl*4);
325 break;
326 }
327
328 /* Length: 15 "SPI=0xF1234567 " */
329 sb_add(m, "SPI=0x%x ", ntohl(eh->spi));
330 break;
331 }
332 /* Max length: 10 "PROTO 255 " */
333 default:
334 sb_add(m, "PROTO=%u ", ih->protocol);
335 }
336
337 /* Max length: 15 "UID=4294967295 " */
338 if ((logflags & IPT_LOG_UID) && !iphoff && skb->sk) {
339 read_lock_bh(&skb->sk->sk_callback_lock);
340 if (skb->sk->sk_socket && skb->sk->sk_socket->file)
341 sb_add(m, "UID=%u GID=%u ",
342 skb->sk->sk_socket->file->f_cred->fsuid,
343 skb->sk->sk_socket->file->f_cred->fsgid);
344 read_unlock_bh(&skb->sk->sk_callback_lock);
345 }
346
347 /* Max length: 16 "MARK=0xFFFFFFFF " */
348 if (!iphoff && skb->mark)
349 sb_add(m, "MARK=0x%x ", skb->mark);
350
351 /* Proto Max log string length */
352 /* IP: 40+46+6+11+127 = 230 */
353 /* TCP: 10+max(25,20+30+13+9+32+11+127) = 252 */
354 /* UDP: 10+max(25,20) = 35 */
355 /* UDPLITE: 14+max(25,20) = 39 */
356 /* ICMP: 11+max(25, 18+25+max(19,14,24+3+n+10,3+n+10)) = 91+n */
357 /* ESP: 10+max(25)+15 = 50 */
358 /* AH: 9+max(25)+15 = 49 */
359 /* unknown: 10 */
360
361 /* (ICMP allows recursion one level deep) */
362 /* maxlen = IP + ICMP + IP + max(TCP,UDP,ICMP,unknown) */
363 /* maxlen = 230+ 91 + 230 + 252 = 803 */
364}
365
366static void dump_mac_header(struct sbuff *m,
367 const struct nf_loginfo *info,
368 const struct sk_buff *skb)
369{
370 struct net_device *dev = skb->dev;
371 unsigned int logflags = 0;
372
373 if (info->type == NF_LOG_TYPE_LOG)
374 logflags = info->u.log.logflags;
375
376 if (!(logflags & IPT_LOG_MACDECODE))
377 goto fallback;
378
379 switch (dev->type) {
380 case ARPHRD_ETHER:
381 sb_add(m, "MACSRC=%pM MACDST=%pM MACPROTO=%04x ",
382 eth_hdr(skb)->h_source, eth_hdr(skb)->h_dest,
383 ntohs(eth_hdr(skb)->h_proto));
384 return;
385 default:
386 break;
387 }
388
389fallback:
390 sb_add(m, "MAC=");
391 if (dev->hard_header_len &&
392 skb->mac_header != skb->network_header) {
393 const unsigned char *p = skb_mac_header(skb);
394 unsigned int i;
395
396 sb_add(m, "%02x", *p++);
397 for (i = 1; i < dev->hard_header_len; i++, p++)
398 sb_add(m, ":%02x", *p);
399 }
400 sb_add(m, " ");
401}
402
403static struct nf_loginfo default_loginfo = {
404 .type = NF_LOG_TYPE_LOG,
405 .u = {
406 .log = {
407 .level = 5,
408 .logflags = NF_LOG_MASK,
409 },
410 },
411};
412
413static void
414ipt_log_packet(u_int8_t pf,
415 unsigned int hooknum,
416 const struct sk_buff *skb,
417 const struct net_device *in,
418 const struct net_device *out,
419 const struct nf_loginfo *loginfo,
420 const char *prefix)
421{
422 struct sbuff *m = sb_open();
423
424 if (!loginfo)
425 loginfo = &default_loginfo;
426
427 sb_add(m, "<%d>%sIN=%s OUT=%s ", loginfo->u.log.level,
428 prefix,
429 in ? in->name : "",
430 out ? out->name : "");
431#ifdef CONFIG_BRIDGE_NETFILTER
432 if (skb->nf_bridge) {
433 const struct net_device *physindev;
434 const struct net_device *physoutdev;
435
436 physindev = skb->nf_bridge->physindev;
437 if (physindev && in != physindev)
438 sb_add(m, "PHYSIN=%s ", physindev->name);
439 physoutdev = skb->nf_bridge->physoutdev;
440 if (physoutdev && out != physoutdev)
441 sb_add(m, "PHYSOUT=%s ", physoutdev->name);
442 }
443#endif
444
445 if (in != NULL)
446 dump_mac_header(m, loginfo, skb);
447
448 dump_packet(m, loginfo, skb, 0);
449
450 sb_close(m);
451}
452
453static unsigned int
454log_tg(struct sk_buff *skb, const struct xt_action_param *par)
455{
456 const struct ipt_log_info *loginfo = par->targinfo;
457 struct nf_loginfo li;
458
459 li.type = NF_LOG_TYPE_LOG;
460 li.u.log.level = loginfo->level;
461 li.u.log.logflags = loginfo->logflags;
462
463 ipt_log_packet(NFPROTO_IPV4, par->hooknum, skb, par->in, par->out, &li,
464 loginfo->prefix);
465 return XT_CONTINUE;
466}
467
468static int log_tg_check(const struct xt_tgchk_param *par)
469{
470 const struct ipt_log_info *loginfo = par->targinfo;
471
472 if (loginfo->level >= 8) {
473 pr_debug("level %u >= 8\n", loginfo->level);
474 return -EINVAL;
475 }
476 if (loginfo->prefix[sizeof(loginfo->prefix)-1] != '\0') {
477 pr_debug("prefix is not null-terminated\n");
478 return -EINVAL;
479 }
480 return 0;
481}
482
483static struct xt_target log_tg_reg __read_mostly = {
484 .name = "LOG",
485 .family = NFPROTO_IPV4,
486 .target = log_tg,
487 .targetsize = sizeof(struct ipt_log_info),
488 .checkentry = log_tg_check,
489 .me = THIS_MODULE,
490};
491
492static struct nf_logger ipt_log_logger __read_mostly = {
493 .name = "ipt_LOG",
494 .logfn = &ipt_log_packet,
495 .me = THIS_MODULE,
496};
497
498static int __init log_tg_init(void)
499{
500 int ret;
501
502 ret = xt_register_target(&log_tg_reg);
503 if (ret < 0)
504 return ret;
505 nf_log_register(NFPROTO_IPV4, &ipt_log_logger);
506 return 0;
507}
508
509static void __exit log_tg_exit(void)
510{
511 nf_log_unregister(&ipt_log_logger);
512 xt_unregister_target(&log_tg_reg);
513}
514
515module_init(log_tg_init);
516module_exit(log_tg_exit);
diff --git a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
index ab5b27a2916..7cbe9cb261c 100644
--- a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
+++ b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
@@ -75,25 +75,31 @@ static int icmp_print_tuple(struct seq_file *s,
75 ntohs(tuple->src.u.icmp.id)); 75 ntohs(tuple->src.u.icmp.id));
76} 76}
77 77
78static unsigned int *icmp_get_timeouts(struct net *net)
79{
80 return &nf_ct_icmp_timeout;
81}
82
78/* Returns verdict for packet, or -1 for invalid. */ 83/* Returns verdict for packet, or -1 for invalid. */
79static int icmp_packet(struct nf_conn *ct, 84static int icmp_packet(struct nf_conn *ct,
80 const struct sk_buff *skb, 85 const struct sk_buff *skb,
81 unsigned int dataoff, 86 unsigned int dataoff,
82 enum ip_conntrack_info ctinfo, 87 enum ip_conntrack_info ctinfo,
83 u_int8_t pf, 88 u_int8_t pf,
84 unsigned int hooknum) 89 unsigned int hooknum,
90 unsigned int *timeout)
85{ 91{
86 /* Do not immediately delete the connection after the first 92 /* Do not immediately delete the connection after the first
87 successful reply to avoid excessive conntrackd traffic 93 successful reply to avoid excessive conntrackd traffic
88 and also to handle correctly ICMP echo reply duplicates. */ 94 and also to handle correctly ICMP echo reply duplicates. */
89 nf_ct_refresh_acct(ct, ctinfo, skb, nf_ct_icmp_timeout); 95 nf_ct_refresh_acct(ct, ctinfo, skb, *timeout);
90 96
91 return NF_ACCEPT; 97 return NF_ACCEPT;
92} 98}
93 99
94/* Called when a new connection for this protocol found. */ 100/* Called when a new connection for this protocol found. */
95static bool icmp_new(struct nf_conn *ct, const struct sk_buff *skb, 101static bool icmp_new(struct nf_conn *ct, const struct sk_buff *skb,
96 unsigned int dataoff) 102 unsigned int dataoff, unsigned int *timeouts)
97{ 103{
98 static const u_int8_t valid_new[] = { 104 static const u_int8_t valid_new[] = {
99 [ICMP_ECHO] = 1, 105 [ICMP_ECHO] = 1,
@@ -263,6 +269,44 @@ static int icmp_nlattr_tuple_size(void)
263} 269}
264#endif 270#endif
265 271
272#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT)
273
274#include <linux/netfilter/nfnetlink.h>
275#include <linux/netfilter/nfnetlink_cttimeout.h>
276
277static int icmp_timeout_nlattr_to_obj(struct nlattr *tb[], void *data)
278{
279 unsigned int *timeout = data;
280
281 if (tb[CTA_TIMEOUT_ICMP_TIMEOUT]) {
282 *timeout =
283 ntohl(nla_get_be32(tb[CTA_TIMEOUT_ICMP_TIMEOUT])) * HZ;
284 } else {
285 /* Set default ICMP timeout. */
286 *timeout = nf_ct_icmp_timeout;
287 }
288 return 0;
289}
290
291static int
292icmp_timeout_obj_to_nlattr(struct sk_buff *skb, const void *data)
293{
294 const unsigned int *timeout = data;
295
296 NLA_PUT_BE32(skb, CTA_TIMEOUT_ICMP_TIMEOUT, htonl(*timeout / HZ));
297
298 return 0;
299
300nla_put_failure:
301 return -ENOSPC;
302}
303
304static const struct nla_policy
305icmp_timeout_nla_policy[CTA_TIMEOUT_ICMP_MAX+1] = {
306 [CTA_TIMEOUT_ICMP_TIMEOUT] = { .type = NLA_U32 },
307};
308#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */
309
266#ifdef CONFIG_SYSCTL 310#ifdef CONFIG_SYSCTL
267static struct ctl_table_header *icmp_sysctl_header; 311static struct ctl_table_header *icmp_sysctl_header;
268static struct ctl_table icmp_sysctl_table[] = { 312static struct ctl_table icmp_sysctl_table[] = {
@@ -298,6 +342,7 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_icmp __read_mostly =
298 .invert_tuple = icmp_invert_tuple, 342 .invert_tuple = icmp_invert_tuple,
299 .print_tuple = icmp_print_tuple, 343 .print_tuple = icmp_print_tuple,
300 .packet = icmp_packet, 344 .packet = icmp_packet,
345 .get_timeouts = icmp_get_timeouts,
301 .new = icmp_new, 346 .new = icmp_new,
302 .error = icmp_error, 347 .error = icmp_error,
303 .destroy = NULL, 348 .destroy = NULL,
@@ -308,6 +353,15 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_icmp __read_mostly =
308 .nlattr_to_tuple = icmp_nlattr_to_tuple, 353 .nlattr_to_tuple = icmp_nlattr_to_tuple,
309 .nla_policy = icmp_nla_policy, 354 .nla_policy = icmp_nla_policy,
310#endif 355#endif
356#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT)
357 .ctnl_timeout = {
358 .nlattr_to_obj = icmp_timeout_nlattr_to_obj,
359 .obj_to_nlattr = icmp_timeout_obj_to_nlattr,
360 .nlattr_max = CTA_TIMEOUT_ICMP_MAX,
361 .obj_size = sizeof(unsigned int),
362 .nla_policy = icmp_timeout_nla_policy,
363 },
364#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */
311#ifdef CONFIG_SYSCTL 365#ifdef CONFIG_SYSCTL
312 .ctl_table_header = &icmp_sysctl_header, 366 .ctl_table_header = &icmp_sysctl_header,
313 .ctl_table = icmp_sysctl_table, 367 .ctl_table = icmp_sysctl_table,
diff --git a/net/ipv4/netfilter/nf_nat_core.c b/net/ipv4/netfilter/nf_nat_core.c
index a708933dc23..abb52adf5ac 100644
--- a/net/ipv4/netfilter/nf_nat_core.c
+++ b/net/ipv4/netfilter/nf_nat_core.c
@@ -686,6 +686,11 @@ static struct pernet_operations nf_nat_net_ops = {
686 .exit = nf_nat_net_exit, 686 .exit = nf_nat_net_exit,
687}; 687};
688 688
689static struct nf_ct_helper_expectfn follow_master_nat = {
690 .name = "nat-follow-master",
691 .expectfn = nf_nat_follow_master,
692};
693
689static int __init nf_nat_init(void) 694static int __init nf_nat_init(void)
690{ 695{
691 size_t i; 696 size_t i;
@@ -717,6 +722,8 @@ static int __init nf_nat_init(void)
717 722
718 l3proto = nf_ct_l3proto_find_get((u_int16_t)AF_INET); 723 l3proto = nf_ct_l3proto_find_get((u_int16_t)AF_INET);
719 724
725 nf_ct_helper_expectfn_register(&follow_master_nat);
726
720 BUG_ON(nf_nat_seq_adjust_hook != NULL); 727 BUG_ON(nf_nat_seq_adjust_hook != NULL);
721 RCU_INIT_POINTER(nf_nat_seq_adjust_hook, nf_nat_seq_adjust); 728 RCU_INIT_POINTER(nf_nat_seq_adjust_hook, nf_nat_seq_adjust);
722 BUG_ON(nfnetlink_parse_nat_setup_hook != NULL); 729 BUG_ON(nfnetlink_parse_nat_setup_hook != NULL);
@@ -736,6 +743,7 @@ static void __exit nf_nat_cleanup(void)
736 unregister_pernet_subsys(&nf_nat_net_ops); 743 unregister_pernet_subsys(&nf_nat_net_ops);
737 nf_ct_l3proto_put(l3proto); 744 nf_ct_l3proto_put(l3proto);
738 nf_ct_extend_unregister(&nat_extend); 745 nf_ct_extend_unregister(&nat_extend);
746 nf_ct_helper_expectfn_unregister(&follow_master_nat);
739 RCU_INIT_POINTER(nf_nat_seq_adjust_hook, NULL); 747 RCU_INIT_POINTER(nf_nat_seq_adjust_hook, NULL);
740 RCU_INIT_POINTER(nfnetlink_parse_nat_setup_hook, NULL); 748 RCU_INIT_POINTER(nfnetlink_parse_nat_setup_hook, NULL);
741 RCU_INIT_POINTER(nf_ct_nat_offset, NULL); 749 RCU_INIT_POINTER(nf_ct_nat_offset, NULL);
diff --git a/net/ipv4/netfilter/nf_nat_h323.c b/net/ipv4/netfilter/nf_nat_h323.c
index dc1dd912baf..82536701e3a 100644
--- a/net/ipv4/netfilter/nf_nat_h323.c
+++ b/net/ipv4/netfilter/nf_nat_h323.c
@@ -568,6 +568,16 @@ static int nat_callforwarding(struct sk_buff *skb, struct nf_conn *ct,
568 return 0; 568 return 0;
569} 569}
570 570
571static struct nf_ct_helper_expectfn q931_nat = {
572 .name = "Q.931",
573 .expectfn = ip_nat_q931_expect,
574};
575
576static struct nf_ct_helper_expectfn callforwarding_nat = {
577 .name = "callforwarding",
578 .expectfn = ip_nat_callforwarding_expect,
579};
580
571/****************************************************************************/ 581/****************************************************************************/
572static int __init init(void) 582static int __init init(void)
573{ 583{
@@ -590,6 +600,8 @@ static int __init init(void)
590 RCU_INIT_POINTER(nat_h245_hook, nat_h245); 600 RCU_INIT_POINTER(nat_h245_hook, nat_h245);
591 RCU_INIT_POINTER(nat_callforwarding_hook, nat_callforwarding); 601 RCU_INIT_POINTER(nat_callforwarding_hook, nat_callforwarding);
592 RCU_INIT_POINTER(nat_q931_hook, nat_q931); 602 RCU_INIT_POINTER(nat_q931_hook, nat_q931);
603 nf_ct_helper_expectfn_register(&q931_nat);
604 nf_ct_helper_expectfn_register(&callforwarding_nat);
593 return 0; 605 return 0;
594} 606}
595 607
@@ -605,6 +617,8 @@ static void __exit fini(void)
605 RCU_INIT_POINTER(nat_h245_hook, NULL); 617 RCU_INIT_POINTER(nat_h245_hook, NULL);
606 RCU_INIT_POINTER(nat_callforwarding_hook, NULL); 618 RCU_INIT_POINTER(nat_callforwarding_hook, NULL);
607 RCU_INIT_POINTER(nat_q931_hook, NULL); 619 RCU_INIT_POINTER(nat_q931_hook, NULL);
620 nf_ct_helper_expectfn_unregister(&q931_nat);
621 nf_ct_helper_expectfn_unregister(&callforwarding_nat);
608 synchronize_rcu(); 622 synchronize_rcu();
609} 623}
610 624
diff --git a/net/ipv4/netfilter/nf_nat_sip.c b/net/ipv4/netfilter/nf_nat_sip.c
index d0319f96269..57932c43960 100644
--- a/net/ipv4/netfilter/nf_nat_sip.c
+++ b/net/ipv4/netfilter/nf_nat_sip.c
@@ -526,6 +526,11 @@ err1:
526 return NF_DROP; 526 return NF_DROP;
527} 527}
528 528
529static struct nf_ct_helper_expectfn sip_nat = {
530 .name = "sip",
531 .expectfn = ip_nat_sip_expected,
532};
533
529static void __exit nf_nat_sip_fini(void) 534static void __exit nf_nat_sip_fini(void)
530{ 535{
531 RCU_INIT_POINTER(nf_nat_sip_hook, NULL); 536 RCU_INIT_POINTER(nf_nat_sip_hook, NULL);
@@ -535,6 +540,7 @@ static void __exit nf_nat_sip_fini(void)
535 RCU_INIT_POINTER(nf_nat_sdp_port_hook, NULL); 540 RCU_INIT_POINTER(nf_nat_sdp_port_hook, NULL);
536 RCU_INIT_POINTER(nf_nat_sdp_session_hook, NULL); 541 RCU_INIT_POINTER(nf_nat_sdp_session_hook, NULL);
537 RCU_INIT_POINTER(nf_nat_sdp_media_hook, NULL); 542 RCU_INIT_POINTER(nf_nat_sdp_media_hook, NULL);
543 nf_ct_helper_expectfn_unregister(&sip_nat);
538 synchronize_rcu(); 544 synchronize_rcu();
539} 545}
540 546
@@ -554,6 +560,7 @@ static int __init nf_nat_sip_init(void)
554 RCU_INIT_POINTER(nf_nat_sdp_port_hook, ip_nat_sdp_port); 560 RCU_INIT_POINTER(nf_nat_sdp_port_hook, ip_nat_sdp_port);
555 RCU_INIT_POINTER(nf_nat_sdp_session_hook, ip_nat_sdp_session); 561 RCU_INIT_POINTER(nf_nat_sdp_session_hook, ip_nat_sdp_session);
556 RCU_INIT_POINTER(nf_nat_sdp_media_hook, ip_nat_sdp_media); 562 RCU_INIT_POINTER(nf_nat_sdp_media_hook, ip_nat_sdp_media);
563 nf_ct_helper_expectfn_register(&sip_nat);
557 return 0; 564 return 0;
558} 565}
559 566
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index b072386cee2..ab6b36e6da1 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -156,7 +156,7 @@ static struct sock *ping_v4_lookup(struct net *net, __be32 saddr, __be32 daddr,
156 struct hlist_nulls_node *hnode; 156 struct hlist_nulls_node *hnode;
157 157
158 pr_debug("try to find: num = %d, daddr = %pI4, dif = %d\n", 158 pr_debug("try to find: num = %d, daddr = %pI4, dif = %d\n",
159 (int)ident, &daddr, dif); 159 (int)ident, &daddr, dif);
160 read_lock_bh(&ping_table.lock); 160 read_lock_bh(&ping_table.lock);
161 161
162 ping_portaddr_for_each_entry(sk, hnode, hslot) { 162 ping_portaddr_for_each_entry(sk, hnode, hslot) {
@@ -229,7 +229,7 @@ static int ping_init_sock(struct sock *sk)
229static void ping_close(struct sock *sk, long timeout) 229static void ping_close(struct sock *sk, long timeout)
230{ 230{
231 pr_debug("ping_close(sk=%p,sk->num=%u)\n", 231 pr_debug("ping_close(sk=%p,sk->num=%u)\n",
232 inet_sk(sk), inet_sk(sk)->inet_num); 232 inet_sk(sk), inet_sk(sk)->inet_num);
233 pr_debug("isk->refcnt = %d\n", sk->sk_refcnt.counter); 233 pr_debug("isk->refcnt = %d\n", sk->sk_refcnt.counter);
234 234
235 sk_common_release(sk); 235 sk_common_release(sk);
@@ -252,7 +252,7 @@ static int ping_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
252 return -EINVAL; 252 return -EINVAL;
253 253
254 pr_debug("ping_v4_bind(sk=%p,sa_addr=%08x,sa_port=%d)\n", 254 pr_debug("ping_v4_bind(sk=%p,sa_addr=%08x,sa_port=%d)\n",
255 sk, addr->sin_addr.s_addr, ntohs(addr->sin_port)); 255 sk, addr->sin_addr.s_addr, ntohs(addr->sin_port));
256 256
257 chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr); 257 chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
258 if (addr->sin_addr.s_addr == htonl(INADDR_ANY)) 258 if (addr->sin_addr.s_addr == htonl(INADDR_ANY))
@@ -280,9 +280,9 @@ static int ping_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
280 } 280 }
281 281
282 pr_debug("after bind(): num = %d, daddr = %pI4, dif = %d\n", 282 pr_debug("after bind(): num = %d, daddr = %pI4, dif = %d\n",
283 (int)isk->inet_num, 283 (int)isk->inet_num,
284 &isk->inet_rcv_saddr, 284 &isk->inet_rcv_saddr,
285 (int)sk->sk_bound_dev_if); 285 (int)sk->sk_bound_dev_if);
286 286
287 err = 0; 287 err = 0;
288 if (isk->inet_rcv_saddr) 288 if (isk->inet_rcv_saddr)
@@ -335,7 +335,7 @@ void ping_err(struct sk_buff *skb, u32 info)
335 return; 335 return;
336 336
337 pr_debug("ping_err(type=%04x,code=%04x,id=%04x,seq=%04x)\n", type, 337 pr_debug("ping_err(type=%04x,code=%04x,id=%04x,seq=%04x)\n", type,
338 code, ntohs(icmph->un.echo.id), ntohs(icmph->un.echo.sequence)); 338 code, ntohs(icmph->un.echo.id), ntohs(icmph->un.echo.sequence));
339 339
340 sk = ping_v4_lookup(net, iph->daddr, iph->saddr, 340 sk = ping_v4_lookup(net, iph->daddr, iph->saddr,
341 ntohs(icmph->un.echo.id), skb->dev->ifindex); 341 ntohs(icmph->un.echo.id), skb->dev->ifindex);
@@ -556,7 +556,8 @@ static int ping_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
556 ipc.oif = inet->mc_index; 556 ipc.oif = inet->mc_index;
557 if (!saddr) 557 if (!saddr)
558 saddr = inet->mc_addr; 558 saddr = inet->mc_addr;
559 } 559 } else if (!ipc.oif)
560 ipc.oif = inet->uc_index;
560 561
561 flowi4_init_output(&fl4, ipc.oif, sk->sk_mark, tos, 562 flowi4_init_output(&fl4, ipc.oif, sk->sk_mark, tos,
562 RT_SCOPE_UNIVERSE, sk->sk_protocol, 563 RT_SCOPE_UNIVERSE, sk->sk_protocol,
@@ -678,7 +679,7 @@ out:
678static int ping_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) 679static int ping_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
679{ 680{
680 pr_debug("ping_queue_rcv_skb(sk=%p,sk->num=%d,skb=%p)\n", 681 pr_debug("ping_queue_rcv_skb(sk=%p,sk->num=%d,skb=%p)\n",
681 inet_sk(sk), inet_sk(sk)->inet_num, skb); 682 inet_sk(sk), inet_sk(sk)->inet_num, skb);
682 if (sock_queue_rcv_skb(sk, skb) < 0) { 683 if (sock_queue_rcv_skb(sk, skb) < 0) {
683 kfree_skb(skb); 684 kfree_skb(skb);
684 pr_debug("ping_queue_rcv_skb -> failed\n"); 685 pr_debug("ping_queue_rcv_skb -> failed\n");
@@ -704,7 +705,7 @@ void ping_rcv(struct sk_buff *skb)
704 /* We assume the packet has already been checked by icmp_rcv */ 705 /* We assume the packet has already been checked by icmp_rcv */
705 706
706 pr_debug("ping_rcv(skb=%p,id=%04x,seq=%04x)\n", 707 pr_debug("ping_rcv(skb=%p,id=%04x,seq=%04x)\n",
707 skb, ntohs(icmph->un.echo.id), ntohs(icmph->un.echo.sequence)); 708 skb, ntohs(icmph->un.echo.id), ntohs(icmph->un.echo.sequence));
708 709
709 /* Push ICMP header back */ 710 /* Push ICMP header back */
710 skb_push(skb, skb->data - (u8 *)icmph); 711 skb_push(skb, skb->data - (u8 *)icmph);
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c
index 6afc807ee2a..8af0d44e4e2 100644
--- a/net/ipv4/proc.c
+++ b/net/ipv4/proc.c
@@ -256,6 +256,8 @@ static const struct snmp_mib snmp4_net_list[] = {
256 SNMP_MIB_ITEM("TCPTimeWaitOverflow", LINUX_MIB_TCPTIMEWAITOVERFLOW), 256 SNMP_MIB_ITEM("TCPTimeWaitOverflow", LINUX_MIB_TCPTIMEWAITOVERFLOW),
257 SNMP_MIB_ITEM("TCPReqQFullDoCookies", LINUX_MIB_TCPREQQFULLDOCOOKIES), 257 SNMP_MIB_ITEM("TCPReqQFullDoCookies", LINUX_MIB_TCPREQQFULLDOCOOKIES),
258 SNMP_MIB_ITEM("TCPReqQFullDrop", LINUX_MIB_TCPREQQFULLDROP), 258 SNMP_MIB_ITEM("TCPReqQFullDrop", LINUX_MIB_TCPREQQFULLDROP),
259 SNMP_MIB_ITEM("TCPRetransFail", LINUX_MIB_TCPRETRANSFAIL),
260 SNMP_MIB_ITEM("TCPRcvCoalesce", LINUX_MIB_TCPRCVCOALESCE),
259 SNMP_MIB_SENTINEL 261 SNMP_MIB_SENTINEL
260}; 262};
261 263
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 3ccda5ae8a2..bbd604c68e6 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -491,11 +491,8 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
491 if (msg->msg_namelen < sizeof(*usin)) 491 if (msg->msg_namelen < sizeof(*usin))
492 goto out; 492 goto out;
493 if (usin->sin_family != AF_INET) { 493 if (usin->sin_family != AF_INET) {
494 static int complained; 494 pr_info_once("%s: %s forgot to set AF_INET. Fix it!\n",
495 if (!complained++) 495 __func__, current->comm);
496 printk(KERN_INFO "%s forgot to set AF_INET in "
497 "raw sendmsg. Fix it!\n",
498 current->comm);
499 err = -EAFNOSUPPORT; 496 err = -EAFNOSUPPORT;
500 if (usin->sin_family) 497 if (usin->sin_family)
501 goto out; 498 goto out;
@@ -563,7 +560,8 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
563 ipc.oif = inet->mc_index; 560 ipc.oif = inet->mc_index;
564 if (!saddr) 561 if (!saddr)
565 saddr = inet->mc_addr; 562 saddr = inet->mc_addr;
566 } 563 } else if (!ipc.oif)
564 ipc.oif = inet->uc_index;
567 565
568 flowi4_init_output(&fl4, ipc.oif, sk->sk_mark, tos, 566 flowi4_init_output(&fl4, ipc.oif, sk->sk_mark, tos,
569 RT_SCOPE_UNIVERSE, 567 RT_SCOPE_UNIVERSE,
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 01977479617..12ccf880eb8 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -62,6 +62,8 @@
62 * 2 of the License, or (at your option) any later version. 62 * 2 of the License, or (at your option) any later version.
63 */ 63 */
64 64
65#define pr_fmt(fmt) "IPv4: " fmt
66
65#include <linux/module.h> 67#include <linux/module.h>
66#include <asm/uaccess.h> 68#include <asm/uaccess.h>
67#include <asm/system.h> 69#include <asm/system.h>
@@ -959,7 +961,7 @@ void rt_cache_flush_batch(struct net *net)
959static void rt_emergency_hash_rebuild(struct net *net) 961static void rt_emergency_hash_rebuild(struct net *net)
960{ 962{
961 if (net_ratelimit()) 963 if (net_ratelimit())
962 printk(KERN_WARNING "Route hash chain too long!\n"); 964 pr_warn("Route hash chain too long!\n");
963 rt_cache_invalidate(net); 965 rt_cache_invalidate(net);
964} 966}
965 967
@@ -1083,7 +1085,7 @@ static int rt_garbage_collect(struct dst_ops *ops)
1083 if (dst_entries_get_slow(&ipv4_dst_ops) < ip_rt_max_size) 1085 if (dst_entries_get_slow(&ipv4_dst_ops) < ip_rt_max_size)
1084 goto out; 1086 goto out;
1085 if (net_ratelimit()) 1087 if (net_ratelimit())
1086 printk(KERN_WARNING "dst cache overflow\n"); 1088 pr_warn("dst cache overflow\n");
1087 RT_CACHE_STAT_INC(gc_dst_overflow); 1089 RT_CACHE_STAT_INC(gc_dst_overflow);
1088 return 1; 1090 return 1;
1089 1091
@@ -1116,12 +1118,17 @@ static struct neighbour *ipv4_neigh_lookup(const struct dst_entry *dst, const vo
1116 static const __be32 inaddr_any = 0; 1118 static const __be32 inaddr_any = 0;
1117 struct net_device *dev = dst->dev; 1119 struct net_device *dev = dst->dev;
1118 const __be32 *pkey = daddr; 1120 const __be32 *pkey = daddr;
1121 const struct rtable *rt;
1119 struct neighbour *n; 1122 struct neighbour *n;
1120 1123
1124 rt = (const struct rtable *) dst;
1125
1121 if (dev->flags & (IFF_LOOPBACK | IFF_POINTOPOINT)) 1126 if (dev->flags & (IFF_LOOPBACK | IFF_POINTOPOINT))
1122 pkey = &inaddr_any; 1127 pkey = &inaddr_any;
1128 else if (rt->rt_gateway)
1129 pkey = (const __be32 *) &rt->rt_gateway;
1123 1130
1124 n = __ipv4_neigh_lookup(&arp_tbl, dev, *(__force u32 *)pkey); 1131 n = __ipv4_neigh_lookup(dev, *(__force u32 *)pkey);
1125 if (n) 1132 if (n)
1126 return n; 1133 return n;
1127 return neigh_create(&arp_tbl, pkey, dev); 1134 return neigh_create(&arp_tbl, pkey, dev);
@@ -1176,8 +1183,7 @@ restart:
1176 int err = rt_bind_neighbour(rt); 1183 int err = rt_bind_neighbour(rt);
1177 if (err) { 1184 if (err) {
1178 if (net_ratelimit()) 1185 if (net_ratelimit())
1179 printk(KERN_WARNING 1186 pr_warn("Neighbour table failure & not caching routes\n");
1180 "Neighbour table failure & not caching routes.\n");
1181 ip_rt_put(rt); 1187 ip_rt_put(rt);
1182 return ERR_PTR(err); 1188 return ERR_PTR(err);
1183 } 1189 }
@@ -1253,7 +1259,7 @@ restart:
1253 struct net *net = dev_net(rt->dst.dev); 1259 struct net *net = dev_net(rt->dst.dev);
1254 int num = ++net->ipv4.current_rt_cache_rebuild_count; 1260 int num = ++net->ipv4.current_rt_cache_rebuild_count;
1255 if (!rt_caching(net)) { 1261 if (!rt_caching(net)) {
1256 printk(KERN_WARNING "%s: %d rebuilds is over limit, route caching disabled\n", 1262 pr_warn("%s: %d rebuilds is over limit, route caching disabled\n",
1257 rt->dst.dev->name, num); 1263 rt->dst.dev->name, num);
1258 } 1264 }
1259 rt_emergency_hash_rebuild(net); 1265 rt_emergency_hash_rebuild(net);
@@ -1294,7 +1300,7 @@ restart:
1294 } 1300 }
1295 1301
1296 if (net_ratelimit()) 1302 if (net_ratelimit())
1297 printk(KERN_WARNING "ipv4: Neighbour table overflow.\n"); 1303 pr_warn("Neighbour table overflow\n");
1298 rt_drop(rt); 1304 rt_drop(rt);
1299 return ERR_PTR(-ENOBUFS); 1305 return ERR_PTR(-ENOBUFS);
1300 } 1306 }
@@ -1498,10 +1504,10 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
1498reject_redirect: 1504reject_redirect:
1499#ifdef CONFIG_IP_ROUTE_VERBOSE 1505#ifdef CONFIG_IP_ROUTE_VERBOSE
1500 if (IN_DEV_LOG_MARTIANS(in_dev) && net_ratelimit()) 1506 if (IN_DEV_LOG_MARTIANS(in_dev) && net_ratelimit())
1501 printk(KERN_INFO "Redirect from %pI4 on %s about %pI4 ignored.\n" 1507 pr_info("Redirect from %pI4 on %s about %pI4 ignored\n"
1502 " Advised path = %pI4 -> %pI4\n", 1508 " Advised path = %pI4 -> %pI4\n",
1503 &old_gw, dev->name, &new_gw, 1509 &old_gw, dev->name, &new_gw,
1504 &saddr, &daddr); 1510 &saddr, &daddr);
1505#endif 1511#endif
1506 ; 1512 ;
1507} 1513}
@@ -1613,8 +1619,8 @@ void ip_rt_send_redirect(struct sk_buff *skb)
1613 if (log_martians && 1619 if (log_martians &&
1614 peer->rate_tokens == ip_rt_redirect_number && 1620 peer->rate_tokens == ip_rt_redirect_number &&
1615 net_ratelimit()) 1621 net_ratelimit())
1616 printk(KERN_WARNING "host %pI4/if%d ignores redirects for %pI4 to %pI4.\n", 1622 pr_warn("host %pI4/if%d ignores redirects for %pI4 to %pI4\n",
1617 &ip_hdr(skb)->saddr, rt->rt_iif, 1623 &ip_hdr(skb)->saddr, rt->rt_iif,
1618 &rt->rt_dst, &rt->rt_gateway); 1624 &rt->rt_dst, &rt->rt_gateway);
1619#endif 1625#endif
1620 } 1626 }
@@ -2100,18 +2106,13 @@ static void ip_handle_martian_source(struct net_device *dev,
2100 * RFC1812 recommendation, if source is martian, 2106 * RFC1812 recommendation, if source is martian,
2101 * the only hint is MAC header. 2107 * the only hint is MAC header.
2102 */ 2108 */
2103 printk(KERN_WARNING "martian source %pI4 from %pI4, on dev %s\n", 2109 pr_warn("martian source %pI4 from %pI4, on dev %s\n",
2104 &daddr, &saddr, dev->name); 2110 &daddr, &saddr, dev->name);
2105 if (dev->hard_header_len && skb_mac_header_was_set(skb)) { 2111 if (dev->hard_header_len && skb_mac_header_was_set(skb)) {
2106 int i; 2112 print_hex_dump(KERN_WARNING, "ll header: ",
2107 const unsigned char *p = skb_mac_header(skb); 2113 DUMP_PREFIX_OFFSET, 16, 1,
2108 printk(KERN_WARNING "ll header: "); 2114 skb_mac_header(skb),
2109 for (i = 0; i < dev->hard_header_len; i++, p++) { 2115 dev->hard_header_len, true);
2110 printk("%02x", *p);
2111 if (i < (dev->hard_header_len - 1))
2112 printk(":");
2113 }
2114 printk("\n");
2115 } 2116 }
2116 } 2117 }
2117#endif 2118#endif
@@ -2135,8 +2136,7 @@ static int __mkroute_input(struct sk_buff *skb,
2135 out_dev = __in_dev_get_rcu(FIB_RES_DEV(*res)); 2136 out_dev = __in_dev_get_rcu(FIB_RES_DEV(*res));
2136 if (out_dev == NULL) { 2137 if (out_dev == NULL) {
2137 if (net_ratelimit()) 2138 if (net_ratelimit())
2138 printk(KERN_CRIT "Bug in ip_route_input" \ 2139 pr_crit("Bug in ip_route_input_slow(). Please report.\n");
2139 "_slow(). Please, report\n");
2140 return -EINVAL; 2140 return -EINVAL;
2141 } 2141 }
2142 2142
@@ -2408,7 +2408,7 @@ martian_destination:
2408 RT_CACHE_STAT_INC(in_martian_dst); 2408 RT_CACHE_STAT_INC(in_martian_dst);
2409#ifdef CONFIG_IP_ROUTE_VERBOSE 2409#ifdef CONFIG_IP_ROUTE_VERBOSE
2410 if (IN_DEV_LOG_MARTIANS(in_dev) && net_ratelimit()) 2410 if (IN_DEV_LOG_MARTIANS(in_dev) && net_ratelimit())
2411 printk(KERN_WARNING "martian destination %pI4 from %pI4, dev %s\n", 2411 pr_warn("martian destination %pI4 from %pI4, dev %s\n",
2412 &daddr, &saddr, dev->name); 2412 &daddr, &saddr, dev->name);
2413#endif 2413#endif
2414 2414
@@ -3485,7 +3485,7 @@ int __init ip_rt_init(void)
3485 net_random() % ip_rt_gc_interval + ip_rt_gc_interval); 3485 net_random() % ip_rt_gc_interval + ip_rt_gc_interval);
3486 3486
3487 if (ip_rt_proc_init()) 3487 if (ip_rt_proc_init())
3488 printk(KERN_ERR "Unable to create route proc files\n"); 3488 pr_err("Unable to create route proc files\n");
3489#ifdef CONFIG_XFRM 3489#ifdef CONFIG_XFRM
3490 xfrm_init(); 3490 xfrm_init();
3491 xfrm4_init(ip_rt_max_size); 3491 xfrm4_init(ip_rt_max_size);
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 22ef5f9fd2f..cfd7edda0a8 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -245,6 +245,8 @@
245 * TCP_CLOSE socket is finished 245 * TCP_CLOSE socket is finished
246 */ 246 */
247 247
248#define pr_fmt(fmt) "TCP: " fmt
249
248#include <linux/kernel.h> 250#include <linux/kernel.h>
249#include <linux/module.h> 251#include <linux/module.h>
250#include <linux/types.h> 252#include <linux/types.h>
@@ -1675,7 +1677,8 @@ do_prequeue:
1675 1677
1676 if (tp->ucopy.dma_cookie < 0) { 1678 if (tp->ucopy.dma_cookie < 0) {
1677 1679
1678 printk(KERN_ALERT "dma_cookie < 0\n"); 1680 pr_alert("%s: dma_cookie < 0\n",
1681 __func__);
1679 1682
1680 /* Exception. Bailout! */ 1683 /* Exception. Bailout! */
1681 if (!copied) 1684 if (!copied)
@@ -1884,9 +1887,9 @@ bool tcp_check_oom(struct sock *sk, int shift)
1884 out_of_socket_memory = tcp_out_of_memory(sk); 1887 out_of_socket_memory = tcp_out_of_memory(sk);
1885 1888
1886 if (too_many_orphans && net_ratelimit()) 1889 if (too_many_orphans && net_ratelimit())
1887 pr_info("TCP: too many orphaned sockets\n"); 1890 pr_info("too many orphaned sockets\n");
1888 if (out_of_socket_memory && net_ratelimit()) 1891 if (out_of_socket_memory && net_ratelimit())
1889 pr_info("TCP: out of memory -- consider tuning tcp_mem\n"); 1892 pr_info("out of memory -- consider tuning tcp_mem\n");
1890 return too_many_orphans || out_of_socket_memory; 1893 return too_many_orphans || out_of_socket_memory;
1891} 1894}
1892 1895
@@ -3311,9 +3314,8 @@ void __init tcp_init(void)
3311 sysctl_tcp_rmem[1] = 87380; 3314 sysctl_tcp_rmem[1] = 87380;
3312 sysctl_tcp_rmem[2] = max(87380, max_share); 3315 sysctl_tcp_rmem[2] = max(87380, max_share);
3313 3316
3314 printk(KERN_INFO "TCP: Hash tables configured " 3317 pr_info("Hash tables configured (established %u bind %u)\n",
3315 "(established %u bind %u)\n", 3318 tcp_hashinfo.ehash_mask + 1, tcp_hashinfo.bhash_size);
3316 tcp_hashinfo.ehash_mask + 1, tcp_hashinfo.bhash_size);
3317 3319
3318 tcp_register_congestion_control(&tcp_reno); 3320 tcp_register_congestion_control(&tcp_reno);
3319 3321
diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c
index fc6d475f488..272a84593c8 100644
--- a/net/ipv4/tcp_cong.c
+++ b/net/ipv4/tcp_cong.c
@@ -6,6 +6,8 @@
6 * Copyright (C) 2005 Stephen Hemminger <shemminger@osdl.org> 6 * Copyright (C) 2005 Stephen Hemminger <shemminger@osdl.org>
7 */ 7 */
8 8
9#define pr_fmt(fmt) "TCP: " fmt
10
9#include <linux/module.h> 11#include <linux/module.h>
10#include <linux/mm.h> 12#include <linux/mm.h>
11#include <linux/types.h> 13#include <linux/types.h>
@@ -41,18 +43,17 @@ int tcp_register_congestion_control(struct tcp_congestion_ops *ca)
41 43
42 /* all algorithms must implement ssthresh and cong_avoid ops */ 44 /* all algorithms must implement ssthresh and cong_avoid ops */
43 if (!ca->ssthresh || !ca->cong_avoid) { 45 if (!ca->ssthresh || !ca->cong_avoid) {
44 printk(KERN_ERR "TCP %s does not implement required ops\n", 46 pr_err("%s does not implement required ops\n", ca->name);
45 ca->name);
46 return -EINVAL; 47 return -EINVAL;
47 } 48 }
48 49
49 spin_lock(&tcp_cong_list_lock); 50 spin_lock(&tcp_cong_list_lock);
50 if (tcp_ca_find(ca->name)) { 51 if (tcp_ca_find(ca->name)) {
51 printk(KERN_NOTICE "TCP %s already registered\n", ca->name); 52 pr_notice("%s already registered\n", ca->name);
52 ret = -EEXIST; 53 ret = -EEXIST;
53 } else { 54 } else {
54 list_add_tail_rcu(&ca->list, &tcp_cong_list); 55 list_add_tail_rcu(&ca->list, &tcp_cong_list);
55 printk(KERN_INFO "TCP %s registered\n", ca->name); 56 pr_info("%s registered\n", ca->name);
56 } 57 }
57 spin_unlock(&tcp_cong_list_lock); 58 spin_unlock(&tcp_cong_list_lock);
58 59
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index b5e315f1364..e886e2f7fa8 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -61,6 +61,8 @@
61 * Pasi Sarolahti: F-RTO for dealing with spurious RTOs 61 * Pasi Sarolahti: F-RTO for dealing with spurious RTOs
62 */ 62 */
63 63
64#define pr_fmt(fmt) "TCP: " fmt
65
64#include <linux/mm.h> 66#include <linux/mm.h>
65#include <linux/slab.h> 67#include <linux/slab.h>
66#include <linux/module.h> 68#include <linux/module.h>
@@ -3867,9 +3869,9 @@ void tcp_parse_options(const struct sk_buff *skb, struct tcp_options_received *o
3867 opt_rx->wscale_ok = 1; 3869 opt_rx->wscale_ok = 1;
3868 if (snd_wscale > 14) { 3870 if (snd_wscale > 14) {
3869 if (net_ratelimit()) 3871 if (net_ratelimit())
3870 printk(KERN_INFO "tcp_parse_options: Illegal window " 3872 pr_info("%s: Illegal window scaling value %d >14 received\n",
3871 "scaling value %d >14 received.\n", 3873 __func__,
3872 snd_wscale); 3874 snd_wscale);
3873 snd_wscale = 14; 3875 snd_wscale = 14;
3874 } 3876 }
3875 opt_rx->snd_wscale = snd_wscale; 3877 opt_rx->snd_wscale = snd_wscale;
@@ -4191,7 +4193,7 @@ static void tcp_fin(struct sock *sk)
4191 /* Only TCP_LISTEN and TCP_CLOSE are left, in these 4193 /* Only TCP_LISTEN and TCP_CLOSE are left, in these
4192 * cases we should never reach this piece of code. 4194 * cases we should never reach this piece of code.
4193 */ 4195 */
4194 printk(KERN_ERR "%s: Impossible, sk->sk_state=%d\n", 4196 pr_err("%s: Impossible, sk->sk_state=%d\n",
4195 __func__, sk->sk_state); 4197 __func__, sk->sk_state);
4196 break; 4198 break;
4197 } 4199 }
@@ -4444,6 +4446,137 @@ static inline int tcp_try_rmem_schedule(struct sock *sk, unsigned int size)
4444 return 0; 4446 return 0;
4445} 4447}
4446 4448
4449static void tcp_data_queue_ofo(struct sock *sk, struct sk_buff *skb)
4450{
4451 struct tcp_sock *tp = tcp_sk(sk);
4452 struct sk_buff *skb1;
4453 u32 seq, end_seq;
4454
4455 TCP_ECN_check_ce(tp, skb);
4456
4457 if (tcp_try_rmem_schedule(sk, skb->truesize)) {
4458 /* TODO: should increment a counter */
4459 __kfree_skb(skb);
4460 return;
4461 }
4462
4463 /* Disable header prediction. */
4464 tp->pred_flags = 0;
4465 inet_csk_schedule_ack(sk);
4466
4467 SOCK_DEBUG(sk, "out of order segment: rcv_next %X seq %X - %X\n",
4468 tp->rcv_nxt, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq);
4469
4470 skb1 = skb_peek_tail(&tp->out_of_order_queue);
4471 if (!skb1) {
4472 /* Initial out of order segment, build 1 SACK. */
4473 if (tcp_is_sack(tp)) {
4474 tp->rx_opt.num_sacks = 1;
4475 tp->selective_acks[0].start_seq = TCP_SKB_CB(skb)->seq;
4476 tp->selective_acks[0].end_seq =
4477 TCP_SKB_CB(skb)->end_seq;
4478 }
4479 __skb_queue_head(&tp->out_of_order_queue, skb);
4480 goto end;
4481 }
4482
4483 seq = TCP_SKB_CB(skb)->seq;
4484 end_seq = TCP_SKB_CB(skb)->end_seq;
4485
4486 if (seq == TCP_SKB_CB(skb1)->end_seq) {
4487 /* Packets in ofo can stay in queue a long time.
4488 * Better try to coalesce them right now
4489 * to avoid future tcp_collapse_ofo_queue(),
4490 * probably the most expensive function in tcp stack.
4491 */
4492 if (skb->len <= skb_tailroom(skb1) && !tcp_hdr(skb)->fin) {
4493 NET_INC_STATS_BH(sock_net(sk),
4494 LINUX_MIB_TCPRCVCOALESCE);
4495 BUG_ON(skb_copy_bits(skb, 0,
4496 skb_put(skb1, skb->len),
4497 skb->len));
4498 TCP_SKB_CB(skb1)->end_seq = end_seq;
4499 TCP_SKB_CB(skb1)->ack_seq = TCP_SKB_CB(skb)->ack_seq;
4500 __kfree_skb(skb);
4501 skb = NULL;
4502 } else {
4503 __skb_queue_after(&tp->out_of_order_queue, skb1, skb);
4504 }
4505
4506 if (!tp->rx_opt.num_sacks ||
4507 tp->selective_acks[0].end_seq != seq)
4508 goto add_sack;
4509
4510 /* Common case: data arrive in order after hole. */
4511 tp->selective_acks[0].end_seq = end_seq;
4512 goto end;
4513 }
4514
4515 /* Find place to insert this segment. */
4516 while (1) {
4517 if (!after(TCP_SKB_CB(skb1)->seq, seq))
4518 break;
4519 if (skb_queue_is_first(&tp->out_of_order_queue, skb1)) {
4520 skb1 = NULL;
4521 break;
4522 }
4523 skb1 = skb_queue_prev(&tp->out_of_order_queue, skb1);
4524 }
4525
4526 /* Do skb overlap to previous one? */
4527 if (skb1 && before(seq, TCP_SKB_CB(skb1)->end_seq)) {
4528 if (!after(end_seq, TCP_SKB_CB(skb1)->end_seq)) {
4529 /* All the bits are present. Drop. */
4530 __kfree_skb(skb);
4531 skb = NULL;
4532 tcp_dsack_set(sk, seq, end_seq);
4533 goto add_sack;
4534 }
4535 if (after(seq, TCP_SKB_CB(skb1)->seq)) {
4536 /* Partial overlap. */
4537 tcp_dsack_set(sk, seq,
4538 TCP_SKB_CB(skb1)->end_seq);
4539 } else {
4540 if (skb_queue_is_first(&tp->out_of_order_queue,
4541 skb1))
4542 skb1 = NULL;
4543 else
4544 skb1 = skb_queue_prev(
4545 &tp->out_of_order_queue,
4546 skb1);
4547 }
4548 }
4549 if (!skb1)
4550 __skb_queue_head(&tp->out_of_order_queue, skb);
4551 else
4552 __skb_queue_after(&tp->out_of_order_queue, skb1, skb);
4553
4554 /* And clean segments covered by new one as whole. */
4555 while (!skb_queue_is_last(&tp->out_of_order_queue, skb)) {
4556 skb1 = skb_queue_next(&tp->out_of_order_queue, skb);
4557
4558 if (!after(end_seq, TCP_SKB_CB(skb1)->seq))
4559 break;
4560 if (before(end_seq, TCP_SKB_CB(skb1)->end_seq)) {
4561 tcp_dsack_extend(sk, TCP_SKB_CB(skb1)->seq,
4562 end_seq);
4563 break;
4564 }
4565 __skb_unlink(skb1, &tp->out_of_order_queue);
4566 tcp_dsack_extend(sk, TCP_SKB_CB(skb1)->seq,
4567 TCP_SKB_CB(skb1)->end_seq);
4568 __kfree_skb(skb1);
4569 }
4570
4571add_sack:
4572 if (tcp_is_sack(tp))
4573 tcp_sack_new_ofo_skb(sk, seq, end_seq);
4574end:
4575 if (skb)
4576 skb_set_owner_r(skb, sk);
4577}
4578
4579
4447static void tcp_data_queue(struct sock *sk, struct sk_buff *skb) 4580static void tcp_data_queue(struct sock *sk, struct sk_buff *skb)
4448{ 4581{
4449 const struct tcphdr *th = tcp_hdr(skb); 4582 const struct tcphdr *th = tcp_hdr(skb);
@@ -4559,105 +4692,7 @@ drop:
4559 goto queue_and_out; 4692 goto queue_and_out;
4560 } 4693 }
4561 4694
4562 TCP_ECN_check_ce(tp, skb); 4695 tcp_data_queue_ofo(sk, skb);
4563
4564 if (tcp_try_rmem_schedule(sk, skb->truesize))
4565 goto drop;
4566
4567 /* Disable header prediction. */
4568 tp->pred_flags = 0;
4569 inet_csk_schedule_ack(sk);
4570
4571 SOCK_DEBUG(sk, "out of order segment: rcv_next %X seq %X - %X\n",
4572 tp->rcv_nxt, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq);
4573
4574 skb_set_owner_r(skb, sk);
4575
4576 if (!skb_peek(&tp->out_of_order_queue)) {
4577 /* Initial out of order segment, build 1 SACK. */
4578 if (tcp_is_sack(tp)) {
4579 tp->rx_opt.num_sacks = 1;
4580 tp->selective_acks[0].start_seq = TCP_SKB_CB(skb)->seq;
4581 tp->selective_acks[0].end_seq =
4582 TCP_SKB_CB(skb)->end_seq;
4583 }
4584 __skb_queue_head(&tp->out_of_order_queue, skb);
4585 } else {
4586 struct sk_buff *skb1 = skb_peek_tail(&tp->out_of_order_queue);
4587 u32 seq = TCP_SKB_CB(skb)->seq;
4588 u32 end_seq = TCP_SKB_CB(skb)->end_seq;
4589
4590 if (seq == TCP_SKB_CB(skb1)->end_seq) {
4591 __skb_queue_after(&tp->out_of_order_queue, skb1, skb);
4592
4593 if (!tp->rx_opt.num_sacks ||
4594 tp->selective_acks[0].end_seq != seq)
4595 goto add_sack;
4596
4597 /* Common case: data arrive in order after hole. */
4598 tp->selective_acks[0].end_seq = end_seq;
4599 return;
4600 }
4601
4602 /* Find place to insert this segment. */
4603 while (1) {
4604 if (!after(TCP_SKB_CB(skb1)->seq, seq))
4605 break;
4606 if (skb_queue_is_first(&tp->out_of_order_queue, skb1)) {
4607 skb1 = NULL;
4608 break;
4609 }
4610 skb1 = skb_queue_prev(&tp->out_of_order_queue, skb1);
4611 }
4612
4613 /* Do skb overlap to previous one? */
4614 if (skb1 && before(seq, TCP_SKB_CB(skb1)->end_seq)) {
4615 if (!after(end_seq, TCP_SKB_CB(skb1)->end_seq)) {
4616 /* All the bits are present. Drop. */
4617 __kfree_skb(skb);
4618 tcp_dsack_set(sk, seq, end_seq);
4619 goto add_sack;
4620 }
4621 if (after(seq, TCP_SKB_CB(skb1)->seq)) {
4622 /* Partial overlap. */
4623 tcp_dsack_set(sk, seq,
4624 TCP_SKB_CB(skb1)->end_seq);
4625 } else {
4626 if (skb_queue_is_first(&tp->out_of_order_queue,
4627 skb1))
4628 skb1 = NULL;
4629 else
4630 skb1 = skb_queue_prev(
4631 &tp->out_of_order_queue,
4632 skb1);
4633 }
4634 }
4635 if (!skb1)
4636 __skb_queue_head(&tp->out_of_order_queue, skb);
4637 else
4638 __skb_queue_after(&tp->out_of_order_queue, skb1, skb);
4639
4640 /* And clean segments covered by new one as whole. */
4641 while (!skb_queue_is_last(&tp->out_of_order_queue, skb)) {
4642 skb1 = skb_queue_next(&tp->out_of_order_queue, skb);
4643
4644 if (!after(end_seq, TCP_SKB_CB(skb1)->seq))
4645 break;
4646 if (before(end_seq, TCP_SKB_CB(skb1)->end_seq)) {
4647 tcp_dsack_extend(sk, TCP_SKB_CB(skb1)->seq,
4648 end_seq);
4649 break;
4650 }
4651 __skb_unlink(skb1, &tp->out_of_order_queue);
4652 tcp_dsack_extend(sk, TCP_SKB_CB(skb1)->seq,
4653 TCP_SKB_CB(skb1)->end_seq);
4654 __kfree_skb(skb1);
4655 }
4656
4657add_sack:
4658 if (tcp_is_sack(tp))
4659 tcp_sack_new_ofo_skb(sk, seq, end_seq);
4660 }
4661} 4696}
4662 4697
4663static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb, 4698static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index fd54c5f8a25..3a25cf743f8 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -50,6 +50,7 @@
50 * a single port at the same time. 50 * a single port at the same time.
51 */ 51 */
52 52
53#define pr_fmt(fmt) "TCP: " fmt
53 54
54#include <linux/bottom_half.h> 55#include <linux/bottom_half.h>
55#include <linux/types.h> 56#include <linux/types.h>
@@ -90,16 +91,8 @@ EXPORT_SYMBOL(sysctl_tcp_low_latency);
90 91
91 92
92#ifdef CONFIG_TCP_MD5SIG 93#ifdef CONFIG_TCP_MD5SIG
93static struct tcp_md5sig_key *tcp_v4_md5_do_lookup(struct sock *sk, 94static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
94 __be32 addr);
95static int tcp_v4_md5_hash_hdr(char *md5_hash, struct tcp_md5sig_key *key,
96 __be32 daddr, __be32 saddr, const struct tcphdr *th); 95 __be32 daddr, __be32 saddr, const struct tcphdr *th);
97#else
98static inline
99struct tcp_md5sig_key *tcp_v4_md5_do_lookup(struct sock *sk, __be32 addr)
100{
101 return NULL;
102}
103#endif 96#endif
104 97
105struct inet_hashinfo tcp_hashinfo; 98struct inet_hashinfo tcp_hashinfo;
@@ -601,6 +594,10 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb)
601 struct ip_reply_arg arg; 594 struct ip_reply_arg arg;
602#ifdef CONFIG_TCP_MD5SIG 595#ifdef CONFIG_TCP_MD5SIG
603 struct tcp_md5sig_key *key; 596 struct tcp_md5sig_key *key;
597 const __u8 *hash_location = NULL;
598 unsigned char newhash[16];
599 int genhash;
600 struct sock *sk1 = NULL;
604#endif 601#endif
605 struct net *net; 602 struct net *net;
606 603
@@ -631,7 +628,36 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb)
631 arg.iov[0].iov_len = sizeof(rep.th); 628 arg.iov[0].iov_len = sizeof(rep.th);
632 629
633#ifdef CONFIG_TCP_MD5SIG 630#ifdef CONFIG_TCP_MD5SIG
634 key = sk ? tcp_v4_md5_do_lookup(sk, ip_hdr(skb)->saddr) : NULL; 631 hash_location = tcp_parse_md5sig_option(th);
632 if (!sk && hash_location) {
633 /*
634 * active side is lost. Try to find listening socket through
635 * source port, and then find md5 key through listening socket.
636 * we are not loose security here:
637 * Incoming packet is checked with md5 hash with finding key,
638 * no RST generated if md5 hash doesn't match.
639 */
640 sk1 = __inet_lookup_listener(dev_net(skb_dst(skb)->dev),
641 &tcp_hashinfo, ip_hdr(skb)->daddr,
642 ntohs(th->source), inet_iif(skb));
643 /* don't send rst if it can't find key */
644 if (!sk1)
645 return;
646 rcu_read_lock();
647 key = tcp_md5_do_lookup(sk1, (union tcp_md5_addr *)
648 &ip_hdr(skb)->saddr, AF_INET);
649 if (!key)
650 goto release_sk1;
651
652 genhash = tcp_v4_md5_hash_skb(newhash, key, NULL, NULL, skb);
653 if (genhash || memcmp(hash_location, newhash, 16) != 0)
654 goto release_sk1;
655 } else {
656 key = sk ? tcp_md5_do_lookup(sk, (union tcp_md5_addr *)
657 &ip_hdr(skb)->saddr,
658 AF_INET) : NULL;
659 }
660
635 if (key) { 661 if (key) {
636 rep.opt[0] = htonl((TCPOPT_NOP << 24) | 662 rep.opt[0] = htonl((TCPOPT_NOP << 24) |
637 (TCPOPT_NOP << 16) | 663 (TCPOPT_NOP << 16) |
@@ -664,6 +690,14 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb)
664 690
665 TCP_INC_STATS_BH(net, TCP_MIB_OUTSEGS); 691 TCP_INC_STATS_BH(net, TCP_MIB_OUTSEGS);
666 TCP_INC_STATS_BH(net, TCP_MIB_OUTRSTS); 692 TCP_INC_STATS_BH(net, TCP_MIB_OUTRSTS);
693
694#ifdef CONFIG_TCP_MD5SIG
695release_sk1:
696 if (sk1) {
697 rcu_read_unlock();
698 sock_put(sk1);
699 }
700#endif
667} 701}
668 702
669/* The code following below sending ACKs in SYN-RECV and TIME-WAIT states 703/* The code following below sending ACKs in SYN-RECV and TIME-WAIT states
@@ -764,7 +798,8 @@ static void tcp_v4_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
764 tcp_rsk(req)->rcv_isn + 1, req->rcv_wnd, 798 tcp_rsk(req)->rcv_isn + 1, req->rcv_wnd,
765 req->ts_recent, 799 req->ts_recent,
766 0, 800 0,
767 tcp_v4_md5_do_lookup(sk, ip_hdr(skb)->daddr), 801 tcp_md5_do_lookup(sk, (union tcp_md5_addr *)&ip_hdr(skb)->daddr,
802 AF_INET),
768 inet_rsk(req)->no_srccheck ? IP_REPLY_ARG_NOSRCCHECK : 0, 803 inet_rsk(req)->no_srccheck ? IP_REPLY_ARG_NOSRCCHECK : 0,
769 ip_hdr(skb)->tos); 804 ip_hdr(skb)->tos);
770} 805}
@@ -842,8 +877,7 @@ int tcp_syn_flood_action(struct sock *sk,
842 lopt = inet_csk(sk)->icsk_accept_queue.listen_opt; 877 lopt = inet_csk(sk)->icsk_accept_queue.listen_opt;
843 if (!lopt->synflood_warned) { 878 if (!lopt->synflood_warned) {
844 lopt->synflood_warned = 1; 879 lopt->synflood_warned = 1;
845 pr_info("%s: Possible SYN flooding on port %d. %s. " 880 pr_info("%s: Possible SYN flooding on port %d. %s. Check SNMP counters.\n",
846 " Check SNMP counters.\n",
847 proto, ntohs(tcp_hdr(skb)->dest), msg); 881 proto, ntohs(tcp_hdr(skb)->dest), msg);
848 } 882 }
849 return want_cookie; 883 return want_cookie;
@@ -881,153 +915,138 @@ static struct ip_options_rcu *tcp_v4_save_options(struct sock *sk,
881 */ 915 */
882 916
883/* Find the Key structure for an address. */ 917/* Find the Key structure for an address. */
884static struct tcp_md5sig_key * 918struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk,
885 tcp_v4_md5_do_lookup(struct sock *sk, __be32 addr) 919 const union tcp_md5_addr *addr,
920 int family)
886{ 921{
887 struct tcp_sock *tp = tcp_sk(sk); 922 struct tcp_sock *tp = tcp_sk(sk);
888 int i; 923 struct tcp_md5sig_key *key;
889 924 struct hlist_node *pos;
890 if (!tp->md5sig_info || !tp->md5sig_info->entries4) 925 unsigned int size = sizeof(struct in_addr);
926 struct tcp_md5sig_info *md5sig;
927
928 /* caller either holds rcu_read_lock() or socket lock */
929 md5sig = rcu_dereference_check(tp->md5sig_info,
930 sock_owned_by_user(sk) ||
931 lockdep_is_held(&sk->sk_lock.slock));
932 if (!md5sig)
891 return NULL; 933 return NULL;
892 for (i = 0; i < tp->md5sig_info->entries4; i++) { 934#if IS_ENABLED(CONFIG_IPV6)
893 if (tp->md5sig_info->keys4[i].addr == addr) 935 if (family == AF_INET6)
894 return &tp->md5sig_info->keys4[i].base; 936 size = sizeof(struct in6_addr);
937#endif
938 hlist_for_each_entry_rcu(key, pos, &md5sig->head, node) {
939 if (key->family != family)
940 continue;
941 if (!memcmp(&key->addr, addr, size))
942 return key;
895 } 943 }
896 return NULL; 944 return NULL;
897} 945}
946EXPORT_SYMBOL(tcp_md5_do_lookup);
898 947
899struct tcp_md5sig_key *tcp_v4_md5_lookup(struct sock *sk, 948struct tcp_md5sig_key *tcp_v4_md5_lookup(struct sock *sk,
900 struct sock *addr_sk) 949 struct sock *addr_sk)
901{ 950{
902 return tcp_v4_md5_do_lookup(sk, inet_sk(addr_sk)->inet_daddr); 951 union tcp_md5_addr *addr;
952
953 addr = (union tcp_md5_addr *)&inet_sk(addr_sk)->inet_daddr;
954 return tcp_md5_do_lookup(sk, addr, AF_INET);
903} 955}
904EXPORT_SYMBOL(tcp_v4_md5_lookup); 956EXPORT_SYMBOL(tcp_v4_md5_lookup);
905 957
906static struct tcp_md5sig_key *tcp_v4_reqsk_md5_lookup(struct sock *sk, 958static struct tcp_md5sig_key *tcp_v4_reqsk_md5_lookup(struct sock *sk,
907 struct request_sock *req) 959 struct request_sock *req)
908{ 960{
909 return tcp_v4_md5_do_lookup(sk, inet_rsk(req)->rmt_addr); 961 union tcp_md5_addr *addr;
962
963 addr = (union tcp_md5_addr *)&inet_rsk(req)->rmt_addr;
964 return tcp_md5_do_lookup(sk, addr, AF_INET);
910} 965}
911 966
912/* This can be called on a newly created socket, from other files */ 967/* This can be called on a newly created socket, from other files */
913int tcp_v4_md5_do_add(struct sock *sk, __be32 addr, 968int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr,
914 u8 *newkey, u8 newkeylen) 969 int family, const u8 *newkey, u8 newkeylen, gfp_t gfp)
915{ 970{
916 /* Add Key to the list */ 971 /* Add Key to the list */
917 struct tcp_md5sig_key *key; 972 struct tcp_md5sig_key *key;
918 struct tcp_sock *tp = tcp_sk(sk); 973 struct tcp_sock *tp = tcp_sk(sk);
919 struct tcp4_md5sig_key *keys; 974 struct tcp_md5sig_info *md5sig;
920 975
921 key = tcp_v4_md5_do_lookup(sk, addr); 976 key = tcp_md5_do_lookup(sk, (union tcp_md5_addr *)&addr, AF_INET);
922 if (key) { 977 if (key) {
923 /* Pre-existing entry - just update that one. */ 978 /* Pre-existing entry - just update that one. */
924 kfree(key->key); 979 memcpy(key->key, newkey, newkeylen);
925 key->key = newkey;
926 key->keylen = newkeylen; 980 key->keylen = newkeylen;
927 } else { 981 return 0;
928 struct tcp_md5sig_info *md5sig; 982 }
929
930 if (!tp->md5sig_info) {
931 tp->md5sig_info = kzalloc(sizeof(*tp->md5sig_info),
932 GFP_ATOMIC);
933 if (!tp->md5sig_info) {
934 kfree(newkey);
935 return -ENOMEM;
936 }
937 sk_nocaps_add(sk, NETIF_F_GSO_MASK);
938 }
939 983
940 md5sig = tp->md5sig_info; 984 md5sig = rcu_dereference_protected(tp->md5sig_info,
941 if (md5sig->entries4 == 0 && 985 sock_owned_by_user(sk));
942 tcp_alloc_md5sig_pool(sk) == NULL) { 986 if (!md5sig) {
943 kfree(newkey); 987 md5sig = kmalloc(sizeof(*md5sig), gfp);
988 if (!md5sig)
944 return -ENOMEM; 989 return -ENOMEM;
945 }
946
947 if (md5sig->alloced4 == md5sig->entries4) {
948 keys = kmalloc((sizeof(*keys) *
949 (md5sig->entries4 + 1)), GFP_ATOMIC);
950 if (!keys) {
951 kfree(newkey);
952 if (md5sig->entries4 == 0)
953 tcp_free_md5sig_pool();
954 return -ENOMEM;
955 }
956 990
957 if (md5sig->entries4) 991 sk_nocaps_add(sk, NETIF_F_GSO_MASK);
958 memcpy(keys, md5sig->keys4, 992 INIT_HLIST_HEAD(&md5sig->head);
959 sizeof(*keys) * md5sig->entries4); 993 rcu_assign_pointer(tp->md5sig_info, md5sig);
994 }
960 995
961 /* Free old key list, and reference new one */ 996 key = sock_kmalloc(sk, sizeof(*key), gfp);
962 kfree(md5sig->keys4); 997 if (!key)
963 md5sig->keys4 = keys; 998 return -ENOMEM;
964 md5sig->alloced4++; 999 if (hlist_empty(&md5sig->head) && !tcp_alloc_md5sig_pool(sk)) {
965 } 1000 sock_kfree_s(sk, key, sizeof(*key));
966 md5sig->entries4++; 1001 return -ENOMEM;
967 md5sig->keys4[md5sig->entries4 - 1].addr = addr;
968 md5sig->keys4[md5sig->entries4 - 1].base.key = newkey;
969 md5sig->keys4[md5sig->entries4 - 1].base.keylen = newkeylen;
970 } 1002 }
971 return 0;
972}
973EXPORT_SYMBOL(tcp_v4_md5_do_add);
974 1003
975static int tcp_v4_md5_add_func(struct sock *sk, struct sock *addr_sk, 1004 memcpy(key->key, newkey, newkeylen);
976 u8 *newkey, u8 newkeylen) 1005 key->keylen = newkeylen;
977{ 1006 key->family = family;
978 return tcp_v4_md5_do_add(sk, inet_sk(addr_sk)->inet_daddr, 1007 memcpy(&key->addr, addr,
979 newkey, newkeylen); 1008 (family == AF_INET6) ? sizeof(struct in6_addr) :
1009 sizeof(struct in_addr));
1010 hlist_add_head_rcu(&key->node, &md5sig->head);
1011 return 0;
980} 1012}
1013EXPORT_SYMBOL(tcp_md5_do_add);
981 1014
982int tcp_v4_md5_do_del(struct sock *sk, __be32 addr) 1015int tcp_md5_do_del(struct sock *sk, const union tcp_md5_addr *addr, int family)
983{ 1016{
984 struct tcp_sock *tp = tcp_sk(sk); 1017 struct tcp_sock *tp = tcp_sk(sk);
985 int i; 1018 struct tcp_md5sig_key *key;
986 1019 struct tcp_md5sig_info *md5sig;
987 for (i = 0; i < tp->md5sig_info->entries4; i++) { 1020
988 if (tp->md5sig_info->keys4[i].addr == addr) { 1021 key = tcp_md5_do_lookup(sk, (union tcp_md5_addr *)&addr, AF_INET);
989 /* Free the key */ 1022 if (!key)
990 kfree(tp->md5sig_info->keys4[i].base.key); 1023 return -ENOENT;
991 tp->md5sig_info->entries4--; 1024 hlist_del_rcu(&key->node);
992 1025 atomic_sub(sizeof(*key), &sk->sk_omem_alloc);
993 if (tp->md5sig_info->entries4 == 0) { 1026 kfree_rcu(key, rcu);
994 kfree(tp->md5sig_info->keys4); 1027 md5sig = rcu_dereference_protected(tp->md5sig_info,
995 tp->md5sig_info->keys4 = NULL; 1028 sock_owned_by_user(sk));
996 tp->md5sig_info->alloced4 = 0; 1029 if (hlist_empty(&md5sig->head))
997 tcp_free_md5sig_pool(); 1030 tcp_free_md5sig_pool();
998 } else if (tp->md5sig_info->entries4 != i) { 1031 return 0;
999 /* Need to do some manipulation */
1000 memmove(&tp->md5sig_info->keys4[i],
1001 &tp->md5sig_info->keys4[i+1],
1002 (tp->md5sig_info->entries4 - i) *
1003 sizeof(struct tcp4_md5sig_key));
1004 }
1005 return 0;
1006 }
1007 }
1008 return -ENOENT;
1009} 1032}
1010EXPORT_SYMBOL(tcp_v4_md5_do_del); 1033EXPORT_SYMBOL(tcp_md5_do_del);
1011 1034
1012static void tcp_v4_clear_md5_list(struct sock *sk) 1035void tcp_clear_md5_list(struct sock *sk)
1013{ 1036{
1014 struct tcp_sock *tp = tcp_sk(sk); 1037 struct tcp_sock *tp = tcp_sk(sk);
1038 struct tcp_md5sig_key *key;
1039 struct hlist_node *pos, *n;
1040 struct tcp_md5sig_info *md5sig;
1015 1041
1016 /* Free each key, then the set of key keys, 1042 md5sig = rcu_dereference_protected(tp->md5sig_info, 1);
1017 * the crypto element, and then decrement our 1043
1018 * hold on the last resort crypto. 1044 if (!hlist_empty(&md5sig->head))
1019 */
1020 if (tp->md5sig_info->entries4) {
1021 int i;
1022 for (i = 0; i < tp->md5sig_info->entries4; i++)
1023 kfree(tp->md5sig_info->keys4[i].base.key);
1024 tp->md5sig_info->entries4 = 0;
1025 tcp_free_md5sig_pool(); 1045 tcp_free_md5sig_pool();
1026 } 1046 hlist_for_each_entry_safe(key, pos, n, &md5sig->head, node) {
1027 if (tp->md5sig_info->keys4) { 1047 hlist_del_rcu(&key->node);
1028 kfree(tp->md5sig_info->keys4); 1048 atomic_sub(sizeof(*key), &sk->sk_omem_alloc);
1029 tp->md5sig_info->keys4 = NULL; 1049 kfree_rcu(key, rcu);
1030 tp->md5sig_info->alloced4 = 0;
1031 } 1050 }
1032} 1051}
1033 1052
@@ -1036,7 +1055,6 @@ static int tcp_v4_parse_md5_keys(struct sock *sk, char __user *optval,
1036{ 1055{
1037 struct tcp_md5sig cmd; 1056 struct tcp_md5sig cmd;
1038 struct sockaddr_in *sin = (struct sockaddr_in *)&cmd.tcpm_addr; 1057 struct sockaddr_in *sin = (struct sockaddr_in *)&cmd.tcpm_addr;
1039 u8 *newkey;
1040 1058
1041 if (optlen < sizeof(cmd)) 1059 if (optlen < sizeof(cmd))
1042 return -EINVAL; 1060 return -EINVAL;
@@ -1047,32 +1065,16 @@ static int tcp_v4_parse_md5_keys(struct sock *sk, char __user *optval,
1047 if (sin->sin_family != AF_INET) 1065 if (sin->sin_family != AF_INET)
1048 return -EINVAL; 1066 return -EINVAL;
1049 1067
1050 if (!cmd.tcpm_key || !cmd.tcpm_keylen) { 1068 if (!cmd.tcpm_key || !cmd.tcpm_keylen)
1051 if (!tcp_sk(sk)->md5sig_info) 1069 return tcp_md5_do_del(sk, (union tcp_md5_addr *)&sin->sin_addr.s_addr,
1052 return -ENOENT; 1070 AF_INET);
1053 return tcp_v4_md5_do_del(sk, sin->sin_addr.s_addr);
1054 }
1055 1071
1056 if (cmd.tcpm_keylen > TCP_MD5SIG_MAXKEYLEN) 1072 if (cmd.tcpm_keylen > TCP_MD5SIG_MAXKEYLEN)
1057 return -EINVAL; 1073 return -EINVAL;
1058 1074
1059 if (!tcp_sk(sk)->md5sig_info) { 1075 return tcp_md5_do_add(sk, (union tcp_md5_addr *)&sin->sin_addr.s_addr,
1060 struct tcp_sock *tp = tcp_sk(sk); 1076 AF_INET, cmd.tcpm_key, cmd.tcpm_keylen,
1061 struct tcp_md5sig_info *p; 1077 GFP_KERNEL);
1062
1063 p = kzalloc(sizeof(*p), sk->sk_allocation);
1064 if (!p)
1065 return -EINVAL;
1066
1067 tp->md5sig_info = p;
1068 sk_nocaps_add(sk, NETIF_F_GSO_MASK);
1069 }
1070
1071 newkey = kmemdup(cmd.tcpm_key, cmd.tcpm_keylen, sk->sk_allocation);
1072 if (!newkey)
1073 return -ENOMEM;
1074 return tcp_v4_md5_do_add(sk, sin->sin_addr.s_addr,
1075 newkey, cmd.tcpm_keylen);
1076} 1078}
1077 1079
1078static int tcp_v4_md5_hash_pseudoheader(struct tcp_md5sig_pool *hp, 1080static int tcp_v4_md5_hash_pseudoheader(struct tcp_md5sig_pool *hp,
@@ -1098,7 +1100,7 @@ static int tcp_v4_md5_hash_pseudoheader(struct tcp_md5sig_pool *hp,
1098 return crypto_hash_update(&hp->md5_desc, &sg, sizeof(*bp)); 1100 return crypto_hash_update(&hp->md5_desc, &sg, sizeof(*bp));
1099} 1101}
1100 1102
1101static int tcp_v4_md5_hash_hdr(char *md5_hash, struct tcp_md5sig_key *key, 1103static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
1102 __be32 daddr, __be32 saddr, const struct tcphdr *th) 1104 __be32 daddr, __be32 saddr, const struct tcphdr *th)
1103{ 1105{
1104 struct tcp_md5sig_pool *hp; 1106 struct tcp_md5sig_pool *hp;
@@ -1198,7 +1200,8 @@ static int tcp_v4_inbound_md5_hash(struct sock *sk, const struct sk_buff *skb)
1198 int genhash; 1200 int genhash;
1199 unsigned char newhash[16]; 1201 unsigned char newhash[16];
1200 1202
1201 hash_expected = tcp_v4_md5_do_lookup(sk, iph->saddr); 1203 hash_expected = tcp_md5_do_lookup(sk, (union tcp_md5_addr *)&iph->saddr,
1204 AF_INET);
1202 hash_location = tcp_parse_md5sig_option(th); 1205 hash_location = tcp_parse_md5sig_option(th);
1203 1206
1204 /* We've parsed the options - do we have a hash? */ 1207 /* We've parsed the options - do we have a hash? */
@@ -1224,10 +1227,10 @@ static int tcp_v4_inbound_md5_hash(struct sock *sk, const struct sk_buff *skb)
1224 1227
1225 if (genhash || memcmp(hash_location, newhash, 16) != 0) { 1228 if (genhash || memcmp(hash_location, newhash, 16) != 0) {
1226 if (net_ratelimit()) { 1229 if (net_ratelimit()) {
1227 printk(KERN_INFO "MD5 Hash failed for (%pI4, %d)->(%pI4, %d)%s\n", 1230 pr_info("MD5 Hash failed for (%pI4, %d)->(%pI4, %d)%s\n",
1228 &iph->saddr, ntohs(th->source), 1231 &iph->saddr, ntohs(th->source),
1229 &iph->daddr, ntohs(th->dest), 1232 &iph->daddr, ntohs(th->dest),
1230 genhash ? " tcp_v4_calc_md5_hash failed" : ""); 1233 genhash ? " tcp_v4_calc_md5_hash failed" : "");
1231 } 1234 }
1232 return 1; 1235 return 1;
1233 } 1236 }
@@ -1396,7 +1399,7 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
1396 * to destinations, already remembered 1399 * to destinations, already remembered
1397 * to the moment of synflood. 1400 * to the moment of synflood.
1398 */ 1401 */
1399 LIMIT_NETDEBUG(KERN_DEBUG "TCP: drop open request from %pI4/%u\n", 1402 LIMIT_NETDEBUG(KERN_DEBUG pr_fmt("drop open request from %pI4/%u\n"),
1400 &saddr, ntohs(tcp_hdr(skb)->source)); 1403 &saddr, ntohs(tcp_hdr(skb)->source));
1401 goto drop_and_release; 1404 goto drop_and_release;
1402 } 1405 }
@@ -1461,6 +1464,7 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1461 ireq->opt = NULL; 1464 ireq->opt = NULL;
1462 newinet->mc_index = inet_iif(skb); 1465 newinet->mc_index = inet_iif(skb);
1463 newinet->mc_ttl = ip_hdr(skb)->ttl; 1466 newinet->mc_ttl = ip_hdr(skb)->ttl;
1467 newinet->rcv_tos = ip_hdr(skb)->tos;
1464 inet_csk(newsk)->icsk_ext_hdr_len = 0; 1468 inet_csk(newsk)->icsk_ext_hdr_len = 0;
1465 if (inet_opt) 1469 if (inet_opt)
1466 inet_csk(newsk)->icsk_ext_hdr_len = inet_opt->opt.optlen; 1470 inet_csk(newsk)->icsk_ext_hdr_len = inet_opt->opt.optlen;
@@ -1490,7 +1494,8 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1490 1494
1491#ifdef CONFIG_TCP_MD5SIG 1495#ifdef CONFIG_TCP_MD5SIG
1492 /* Copy over the MD5 key from the original socket */ 1496 /* Copy over the MD5 key from the original socket */
1493 key = tcp_v4_md5_do_lookup(sk, newinet->inet_daddr); 1497 key = tcp_md5_do_lookup(sk, (union tcp_md5_addr *)&newinet->inet_daddr,
1498 AF_INET);
1494 if (key != NULL) { 1499 if (key != NULL) {
1495 /* 1500 /*
1496 * We're using one, so create a matching key 1501 * We're using one, so create a matching key
@@ -1498,10 +1503,8 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1498 * memory, then we end up not copying the key 1503 * memory, then we end up not copying the key
1499 * across. Shucks. 1504 * across. Shucks.
1500 */ 1505 */
1501 char *newkey = kmemdup(key->key, key->keylen, GFP_ATOMIC); 1506 tcp_md5_do_add(newsk, (union tcp_md5_addr *)&newinet->inet_daddr,
1502 if (newkey != NULL) 1507 AF_INET, key->key, key->keylen, GFP_ATOMIC);
1503 tcp_v4_md5_do_add(newsk, newinet->inet_daddr,
1504 newkey, key->keylen);
1505 sk_nocaps_add(newsk, NETIF_F_GSO_MASK); 1508 sk_nocaps_add(newsk, NETIF_F_GSO_MASK);
1506 } 1509 }
1507#endif 1510#endif
@@ -1862,7 +1865,6 @@ EXPORT_SYMBOL(ipv4_specific);
1862static const struct tcp_sock_af_ops tcp_sock_ipv4_specific = { 1865static const struct tcp_sock_af_ops tcp_sock_ipv4_specific = {
1863 .md5_lookup = tcp_v4_md5_lookup, 1866 .md5_lookup = tcp_v4_md5_lookup,
1864 .calc_md5_hash = tcp_v4_md5_hash_skb, 1867 .calc_md5_hash = tcp_v4_md5_hash_skb,
1865 .md5_add = tcp_v4_md5_add_func,
1866 .md5_parse = tcp_v4_parse_md5_keys, 1868 .md5_parse = tcp_v4_parse_md5_keys,
1867}; 1869};
1868#endif 1870#endif
@@ -1951,8 +1953,8 @@ void tcp_v4_destroy_sock(struct sock *sk)
1951#ifdef CONFIG_TCP_MD5SIG 1953#ifdef CONFIG_TCP_MD5SIG
1952 /* Clean up the MD5 key list, if any */ 1954 /* Clean up the MD5 key list, if any */
1953 if (tp->md5sig_info) { 1955 if (tp->md5sig_info) {
1954 tcp_v4_clear_md5_list(sk); 1956 tcp_clear_md5_list(sk);
1955 kfree(tp->md5sig_info); 1957 kfree_rcu(tp->md5sig_info, rcu);
1956 tp->md5sig_info = NULL; 1958 tp->md5sig_info = NULL;
1957 } 1959 }
1958#endif 1960#endif
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 550e755747e..3cabafb5cdd 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -359,13 +359,11 @@ void tcp_time_wait(struct sock *sk, int state, int timeo)
359 */ 359 */
360 do { 360 do {
361 struct tcp_md5sig_key *key; 361 struct tcp_md5sig_key *key;
362 memset(tcptw->tw_md5_key, 0, sizeof(tcptw->tw_md5_key)); 362 tcptw->tw_md5_key = NULL;
363 tcptw->tw_md5_keylen = 0;
364 key = tp->af_specific->md5_lookup(sk, sk); 363 key = tp->af_specific->md5_lookup(sk, sk);
365 if (key != NULL) { 364 if (key != NULL) {
366 memcpy(&tcptw->tw_md5_key, key->key, key->keylen); 365 tcptw->tw_md5_key = kmemdup(key, sizeof(*key), GFP_ATOMIC);
367 tcptw->tw_md5_keylen = key->keylen; 366 if (tcptw->tw_md5_key && tcp_alloc_md5sig_pool(sk) == NULL)
368 if (tcp_alloc_md5sig_pool(sk) == NULL)
369 BUG(); 367 BUG();
370 } 368 }
371 } while (0); 369 } while (0);
@@ -405,8 +403,10 @@ void tcp_twsk_destructor(struct sock *sk)
405{ 403{
406#ifdef CONFIG_TCP_MD5SIG 404#ifdef CONFIG_TCP_MD5SIG
407 struct tcp_timewait_sock *twsk = tcp_twsk(sk); 405 struct tcp_timewait_sock *twsk = tcp_twsk(sk);
408 if (twsk->tw_md5_keylen) 406 if (twsk->tw_md5_key) {
409 tcp_free_md5sig_pool(); 407 tcp_free_md5sig_pool();
408 kfree_rcu(twsk->tw_md5_key, rcu);
409 }
410#endif 410#endif
411} 411}
412EXPORT_SYMBOL_GPL(tcp_twsk_destructor); 412EXPORT_SYMBOL_GPL(tcp_twsk_destructor);
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 4ff3b6dc74f..364784a9193 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2306,8 +2306,10 @@ begin_fwd:
2306 if (sacked & (TCPCB_SACKED_ACKED|TCPCB_SACKED_RETRANS)) 2306 if (sacked & (TCPCB_SACKED_ACKED|TCPCB_SACKED_RETRANS))
2307 continue; 2307 continue;
2308 2308
2309 if (tcp_retransmit_skb(sk, skb)) 2309 if (tcp_retransmit_skb(sk, skb)) {
2310 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPRETRANSFAIL);
2310 return; 2311 return;
2312 }
2311 NET_INC_STATS_BH(sock_net(sk), mib_idx); 2313 NET_INC_STATS_BH(sock_net(sk), mib_idx);
2312 2314
2313 if (inet_csk(sk)->icsk_ca_state == TCP_CA_Recovery) 2315 if (inet_csk(sk)->icsk_ca_state == TCP_CA_Recovery)
diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
index 85ee7eb7e38..a981cdc0a6e 100644
--- a/net/ipv4/tcp_probe.c
+++ b/net/ipv4/tcp_probe.c
@@ -18,6 +18,8 @@
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 19 */
20 20
21#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
22
21#include <linux/kernel.h> 23#include <linux/kernel.h>
22#include <linux/kprobes.h> 24#include <linux/kprobes.h>
23#include <linux/socket.h> 25#include <linux/socket.h>
@@ -239,7 +241,7 @@ static __init int tcpprobe_init(void)
239 if (ret) 241 if (ret)
240 goto err1; 242 goto err1;
241 243
242 pr_info("TCP probe registered (port=%d) bufsize=%u\n", port, bufsize); 244 pr_info("probe registered (port=%d) bufsize=%u\n", port, bufsize);
243 return 0; 245 return 0;
244 err1: 246 err1:
245 proc_net_remove(&init_net, procname); 247 proc_net_remove(&init_net, procname);
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index cd2e0723266..34d4a02c2f1 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -333,16 +333,18 @@ void tcp_retransmit_timer(struct sock *sk)
333 */ 333 */
334 struct inet_sock *inet = inet_sk(sk); 334 struct inet_sock *inet = inet_sk(sk);
335 if (sk->sk_family == AF_INET) { 335 if (sk->sk_family == AF_INET) {
336 LIMIT_NETDEBUG(KERN_DEBUG "TCP: Peer %pI4:%u/%u unexpectedly shrunk window %u:%u (repaired)\n", 336 LIMIT_NETDEBUG(KERN_DEBUG pr_fmt("Peer %pI4:%u/%u unexpectedly shrunk window %u:%u (repaired)\n"),
337 &inet->inet_daddr, ntohs(inet->inet_dport), 337 &inet->inet_daddr,
338 inet->inet_num, tp->snd_una, tp->snd_nxt); 338 ntohs(inet->inet_dport), inet->inet_num,
339 tp->snd_una, tp->snd_nxt);
339 } 340 }
340#if IS_ENABLED(CONFIG_IPV6) 341#if IS_ENABLED(CONFIG_IPV6)
341 else if (sk->sk_family == AF_INET6) { 342 else if (sk->sk_family == AF_INET6) {
342 struct ipv6_pinfo *np = inet6_sk(sk); 343 struct ipv6_pinfo *np = inet6_sk(sk);
343 LIMIT_NETDEBUG(KERN_DEBUG "TCP: Peer %pI6:%u/%u unexpectedly shrunk window %u:%u (repaired)\n", 344 LIMIT_NETDEBUG(KERN_DEBUG pr_fmt("Peer %pI6:%u/%u unexpectedly shrunk window %u:%u (repaired)\n"),
344 &np->daddr, ntohs(inet->inet_dport), 345 &np->daddr,
345 inet->inet_num, tp->snd_una, tp->snd_nxt); 346 ntohs(inet->inet_dport), inet->inet_num,
347 tp->snd_una, tp->snd_nxt);
346 } 348 }
347#endif 349#endif
348 if (tcp_time_stamp - tp->rcv_tstamp > TCP_RTO_MAX) { 350 if (tcp_time_stamp - tp->rcv_tstamp > TCP_RTO_MAX) {
diff --git a/net/ipv4/tunnel4.c b/net/ipv4/tunnel4.c
index 01775983b99..0d017183062 100644
--- a/net/ipv4/tunnel4.c
+++ b/net/ipv4/tunnel4.c
@@ -164,12 +164,12 @@ static const struct net_protocol tunnel64_protocol = {
164static int __init tunnel4_init(void) 164static int __init tunnel4_init(void)
165{ 165{
166 if (inet_add_protocol(&tunnel4_protocol, IPPROTO_IPIP)) { 166 if (inet_add_protocol(&tunnel4_protocol, IPPROTO_IPIP)) {
167 printk(KERN_ERR "tunnel4 init: can't add protocol\n"); 167 pr_err("%s: can't add protocol\n", __func__);
168 return -EAGAIN; 168 return -EAGAIN;
169 } 169 }
170#if IS_ENABLED(CONFIG_IPV6) 170#if IS_ENABLED(CONFIG_IPV6)
171 if (inet_add_protocol(&tunnel64_protocol, IPPROTO_IPV6)) { 171 if (inet_add_protocol(&tunnel64_protocol, IPPROTO_IPV6)) {
172 printk(KERN_ERR "tunnel64 init: can't add protocol\n"); 172 pr_err("tunnel64 init: can't add protocol\n");
173 inet_del_protocol(&tunnel4_protocol, IPPROTO_IPIP); 173 inet_del_protocol(&tunnel4_protocol, IPPROTO_IPIP);
174 return -EAGAIN; 174 return -EAGAIN;
175 } 175 }
@@ -181,10 +181,10 @@ static void __exit tunnel4_fini(void)
181{ 181{
182#if IS_ENABLED(CONFIG_IPV6) 182#if IS_ENABLED(CONFIG_IPV6)
183 if (inet_del_protocol(&tunnel64_protocol, IPPROTO_IPV6)) 183 if (inet_del_protocol(&tunnel64_protocol, IPPROTO_IPV6))
184 printk(KERN_ERR "tunnel64 close: can't remove protocol\n"); 184 pr_err("tunnel64 close: can't remove protocol\n");
185#endif 185#endif
186 if (inet_del_protocol(&tunnel4_protocol, IPPROTO_IPIP)) 186 if (inet_del_protocol(&tunnel4_protocol, IPPROTO_IPIP))
187 printk(KERN_ERR "tunnel4 close: can't remove protocol\n"); 187 pr_err("tunnel4 close: can't remove protocol\n");
188} 188}
189 189
190module_init(tunnel4_init); 190module_init(tunnel4_init);
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 5d075b5f70f..d6f5feeb3ea 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -77,6 +77,8 @@
77 * 2 of the License, or (at your option) any later version. 77 * 2 of the License, or (at your option) any later version.
78 */ 78 */
79 79
80#define pr_fmt(fmt) "UDP: " fmt
81
80#include <asm/system.h> 82#include <asm/system.h>
81#include <asm/uaccess.h> 83#include <asm/uaccess.h>
82#include <asm/ioctls.h> 84#include <asm/ioctls.h>
@@ -917,7 +919,8 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
917 if (!saddr) 919 if (!saddr)
918 saddr = inet->mc_addr; 920 saddr = inet->mc_addr;
919 connected = 0; 921 connected = 0;
920 } 922 } else if (!ipc.oif)
923 ipc.oif = inet->uc_index;
921 924
922 if (connected) 925 if (connected)
923 rt = (struct rtable *)sk_dst_check(sk, 0); 926 rt = (struct rtable *)sk_dst_check(sk, 0);
@@ -974,7 +977,7 @@ back_from_confirm:
974 /* ... which is an evident application bug. --ANK */ 977 /* ... which is an evident application bug. --ANK */
975 release_sock(sk); 978 release_sock(sk);
976 979
977 LIMIT_NETDEBUG(KERN_DEBUG "udp cork app bug 2\n"); 980 LIMIT_NETDEBUG(KERN_DEBUG pr_fmt("cork app bug 2\n"));
978 err = -EINVAL; 981 err = -EINVAL;
979 goto out; 982 goto out;
980 } 983 }
@@ -1053,7 +1056,7 @@ int udp_sendpage(struct sock *sk, struct page *page, int offset,
1053 if (unlikely(!up->pending)) { 1056 if (unlikely(!up->pending)) {
1054 release_sock(sk); 1057 release_sock(sk);
1055 1058
1056 LIMIT_NETDEBUG(KERN_DEBUG "udp cork app bug 3\n"); 1059 LIMIT_NETDEBUG(KERN_DEBUG pr_fmt("udp cork app bug 3\n"));
1057 return -EINVAL; 1060 return -EINVAL;
1058 } 1061 }
1059 1062
@@ -1166,7 +1169,7 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
1166 struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name; 1169 struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name;
1167 struct sk_buff *skb; 1170 struct sk_buff *skb;
1168 unsigned int ulen, copied; 1171 unsigned int ulen, copied;
1169 int peeked; 1172 int peeked, off = 0;
1170 int err; 1173 int err;
1171 int is_udplite = IS_UDPLITE(sk); 1174 int is_udplite = IS_UDPLITE(sk);
1172 bool slow; 1175 bool slow;
@@ -1182,7 +1185,7 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
1182 1185
1183try_again: 1186try_again:
1184 skb = __skb_recv_datagram(sk, flags | (noblock ? MSG_DONTWAIT : 0), 1187 skb = __skb_recv_datagram(sk, flags | (noblock ? MSG_DONTWAIT : 0),
1185 &peeked, &err); 1188 &peeked, &off, &err);
1186 if (!skb) 1189 if (!skb)
1187 goto out; 1190 goto out;
1188 1191
@@ -1446,9 +1449,8 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
1446 * provided by the application." 1449 * provided by the application."
1447 */ 1450 */
1448 if (up->pcrlen == 0) { /* full coverage was set */ 1451 if (up->pcrlen == 0) { /* full coverage was set */
1449 LIMIT_NETDEBUG(KERN_WARNING "UDPLITE: partial coverage " 1452 LIMIT_NETDEBUG(KERN_WARNING "UDPLite: partial coverage %d while full coverage %d requested\n",
1450 "%d while full coverage %d requested\n", 1453 UDP_SKB_CB(skb)->cscov, skb->len);
1451 UDP_SKB_CB(skb)->cscov, skb->len);
1452 goto drop; 1454 goto drop;
1453 } 1455 }
1454 /* The next case involves violating the min. coverage requested 1456 /* The next case involves violating the min. coverage requested
@@ -1458,9 +1460,8 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
1458 * Therefore the above ...()->partial_cov statement is essential. 1460 * Therefore the above ...()->partial_cov statement is essential.
1459 */ 1461 */
1460 if (UDP_SKB_CB(skb)->cscov < up->pcrlen) { 1462 if (UDP_SKB_CB(skb)->cscov < up->pcrlen) {
1461 LIMIT_NETDEBUG(KERN_WARNING 1463 LIMIT_NETDEBUG(KERN_WARNING "UDPLite: coverage %d too small, need min %d\n",
1462 "UDPLITE: coverage %d too small, need min %d\n", 1464 UDP_SKB_CB(skb)->cscov, up->pcrlen);
1463 UDP_SKB_CB(skb)->cscov, up->pcrlen);
1464 goto drop; 1465 goto drop;
1465 } 1466 }
1466 } 1467 }
@@ -1688,13 +1689,10 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
1688 1689
1689short_packet: 1690short_packet:
1690 LIMIT_NETDEBUG(KERN_DEBUG "UDP%s: short packet: From %pI4:%u %d/%d to %pI4:%u\n", 1691 LIMIT_NETDEBUG(KERN_DEBUG "UDP%s: short packet: From %pI4:%u %d/%d to %pI4:%u\n",
1691 proto == IPPROTO_UDPLITE ? "-Lite" : "", 1692 proto == IPPROTO_UDPLITE ? "Lite" : "",
1692 &saddr, 1693 &saddr, ntohs(uh->source),
1693 ntohs(uh->source), 1694 ulen, skb->len,
1694 ulen, 1695 &daddr, ntohs(uh->dest));
1695 skb->len,
1696 &daddr,
1697 ntohs(uh->dest));
1698 goto drop; 1696 goto drop;
1699 1697
1700csum_error: 1698csum_error:
@@ -1703,11 +1701,8 @@ csum_error:
1703 * the network is concerned, anyway) as per 4.1.3.4 (MUST). 1701 * the network is concerned, anyway) as per 4.1.3.4 (MUST).
1704 */ 1702 */
1705 LIMIT_NETDEBUG(KERN_DEBUG "UDP%s: bad checksum. From %pI4:%u to %pI4:%u ulen %d\n", 1703 LIMIT_NETDEBUG(KERN_DEBUG "UDP%s: bad checksum. From %pI4:%u to %pI4:%u ulen %d\n",
1706 proto == IPPROTO_UDPLITE ? "-Lite" : "", 1704 proto == IPPROTO_UDPLITE ? "Lite" : "",
1707 &saddr, 1705 &saddr, ntohs(uh->source), &daddr, ntohs(uh->dest),
1708 ntohs(uh->source),
1709 &daddr,
1710 ntohs(uh->dest),
1711 ulen); 1706 ulen);
1712drop: 1707drop:
1713 UDP_INC_STATS_BH(net, UDP_MIB_INERRORS, proto == IPPROTO_UDPLITE); 1708 UDP_INC_STATS_BH(net, UDP_MIB_INERRORS, proto == IPPROTO_UDPLITE);
diff --git a/net/ipv4/udplite.c b/net/ipv4/udplite.c
index 12e9499a1a6..2c46acd4cc3 100644
--- a/net/ipv4/udplite.c
+++ b/net/ipv4/udplite.c
@@ -10,6 +10,9 @@
10 * as published by the Free Software Foundation; either version 10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version. 11 * 2 of the License, or (at your option) any later version.
12 */ 12 */
13
14#define pr_fmt(fmt) "UDPLite: " fmt
15
13#include <linux/export.h> 16#include <linux/export.h>
14#include "udp_impl.h" 17#include "udp_impl.h"
15 18
@@ -129,11 +132,11 @@ void __init udplite4_register(void)
129 inet_register_protosw(&udplite4_protosw); 132 inet_register_protosw(&udplite4_protosw);
130 133
131 if (udplite4_proc_init()) 134 if (udplite4_proc_init())
132 printk(KERN_ERR "%s: Cannot register /proc!\n", __func__); 135 pr_err("%s: Cannot register /proc!\n", __func__);
133 return; 136 return;
134 137
135out_unregister_proto: 138out_unregister_proto:
136 proto_unregister(&udplite_prot); 139 proto_unregister(&udplite_prot);
137out_register_err: 140out_register_err:
138 printk(KERN_CRIT "%s: Cannot add UDP-Lite protocol.\n", __func__); 141 pr_crit("%s: Cannot add UDP-Lite protocol\n", __func__);
139} 142}
diff --git a/net/ipv4/xfrm4_tunnel.c b/net/ipv4/xfrm4_tunnel.c
index 9247d9d70e9..05a5df2febc 100644
--- a/net/ipv4/xfrm4_tunnel.c
+++ b/net/ipv4/xfrm4_tunnel.c
@@ -3,6 +3,8 @@
3 * Copyright (C) 2003 David S. Miller (davem@redhat.com) 3 * Copyright (C) 2003 David S. Miller (davem@redhat.com)
4 */ 4 */
5 5
6#define pr_fmt(fmt) "IPsec: " fmt
7
6#include <linux/skbuff.h> 8#include <linux/skbuff.h>
7#include <linux/module.h> 9#include <linux/module.h>
8#include <linux/mutex.h> 10#include <linux/mutex.h>
@@ -75,18 +77,18 @@ static struct xfrm_tunnel xfrm64_tunnel_handler __read_mostly = {
75static int __init ipip_init(void) 77static int __init ipip_init(void)
76{ 78{
77 if (xfrm_register_type(&ipip_type, AF_INET) < 0) { 79 if (xfrm_register_type(&ipip_type, AF_INET) < 0) {
78 printk(KERN_INFO "ipip init: can't add xfrm type\n"); 80 pr_info("%s: can't add xfrm type\n", __func__);
79 return -EAGAIN; 81 return -EAGAIN;
80 } 82 }
81 83
82 if (xfrm4_tunnel_register(&xfrm_tunnel_handler, AF_INET)) { 84 if (xfrm4_tunnel_register(&xfrm_tunnel_handler, AF_INET)) {
83 printk(KERN_INFO "ipip init: can't add xfrm handler for AF_INET\n"); 85 pr_info("%s: can't add xfrm handler for AF_INET\n", __func__);
84 xfrm_unregister_type(&ipip_type, AF_INET); 86 xfrm_unregister_type(&ipip_type, AF_INET);
85 return -EAGAIN; 87 return -EAGAIN;
86 } 88 }
87#if IS_ENABLED(CONFIG_IPV6) 89#if IS_ENABLED(CONFIG_IPV6)
88 if (xfrm4_tunnel_register(&xfrm64_tunnel_handler, AF_INET6)) { 90 if (xfrm4_tunnel_register(&xfrm64_tunnel_handler, AF_INET6)) {
89 printk(KERN_INFO "ipip init: can't add xfrm handler for AF_INET6\n"); 91 pr_info("%s: can't add xfrm handler for AF_INET6\n", __func__);
90 xfrm4_tunnel_deregister(&xfrm_tunnel_handler, AF_INET); 92 xfrm4_tunnel_deregister(&xfrm_tunnel_handler, AF_INET);
91 xfrm_unregister_type(&ipip_type, AF_INET); 93 xfrm_unregister_type(&ipip_type, AF_INET);
92 return -EAGAIN; 94 return -EAGAIN;
@@ -99,12 +101,14 @@ static void __exit ipip_fini(void)
99{ 101{
100#if IS_ENABLED(CONFIG_IPV6) 102#if IS_ENABLED(CONFIG_IPV6)
101 if (xfrm4_tunnel_deregister(&xfrm64_tunnel_handler, AF_INET6)) 103 if (xfrm4_tunnel_deregister(&xfrm64_tunnel_handler, AF_INET6))
102 printk(KERN_INFO "ipip close: can't remove xfrm handler for AF_INET6\n"); 104 pr_info("%s: can't remove xfrm handler for AF_INET6\n",
105 __func__);
103#endif 106#endif
104 if (xfrm4_tunnel_deregister(&xfrm_tunnel_handler, AF_INET)) 107 if (xfrm4_tunnel_deregister(&xfrm_tunnel_handler, AF_INET))
105 printk(KERN_INFO "ipip close: can't remove xfrm handler for AF_INET\n"); 108 pr_info("%s: can't remove xfrm handler for AF_INET\n",
109 __func__);
106 if (xfrm_unregister_type(&ipip_type, AF_INET) < 0) 110 if (xfrm_unregister_type(&ipip_type, AF_INET) < 0)
107 printk(KERN_INFO "ipip close: can't remove xfrm type\n"); 111 pr_info("%s: can't remove xfrm type\n", __func__);
108} 112}
109 113
110module_init(ipip_init); 114module_init(ipip_init);