aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/ndisc.c
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2012-05-16 15:28:38 -0400
committerDavid S. Miller <davem@davemloft.net>2012-05-17 05:00:04 -0400
commit675418d5187785d3d996ca15fd700f5e02901cbc (patch)
tree9771e8a4b13307051a7af653b68d4726956b962a /net/ipv6/ndisc.c
parentf342cda7789381236a6c94926a9ca177a9098867 (diff)
net: ipv6: ndisc: Neaten ND_PRINTx macros
Why use several macros when one will do? Convert the multiple ND_PRINTKx macros to a single ND_PRINTK macro. Use the new net_<level>_ratelimited mechanism too. Add pr_fmt with "ICMPv6: " as prefix. Remove embedded ICMPv6 prefixes from messages. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/ndisc.c')
-rw-r--r--net/ipv6/ndisc.c216
1 files changed, 91 insertions, 125 deletions
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index cbb863d66481..c7a27ac906df 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -27,27 +27,7 @@
27 * YOSHIFUJI Hideaki @USAGI : Verify ND options properly 27 * YOSHIFUJI Hideaki @USAGI : Verify ND options properly
28 */ 28 */
29 29
30/* Set to 3 to get tracing... */ 30#define pr_fmt(fmt) "ICMPv6: " fmt
31#define ND_DEBUG 1
32
33#define ND_PRINTK(fmt, args...) do { if (net_ratelimit()) { printk(fmt, ## args); } } while(0)
34#define ND_NOPRINTK(x...) do { ; } while(0)
35#define ND_PRINTK0 ND_PRINTK
36#define ND_PRINTK1 ND_NOPRINTK
37#define ND_PRINTK2 ND_NOPRINTK
38#define ND_PRINTK3 ND_NOPRINTK
39#if ND_DEBUG >= 1
40#undef ND_PRINTK1
41#define ND_PRINTK1 ND_PRINTK
42#endif
43#if ND_DEBUG >= 2
44#undef ND_PRINTK2
45#define ND_PRINTK2 ND_PRINTK
46#endif
47#if ND_DEBUG >= 3
48#undef ND_PRINTK3
49#define ND_PRINTK3 ND_PRINTK
50#endif
51 31
52#include <linux/module.h> 32#include <linux/module.h>
53#include <linux/errno.h> 33#include <linux/errno.h>
@@ -92,6 +72,15 @@
92#include <linux/netfilter.h> 72#include <linux/netfilter.h>
93#include <linux/netfilter_ipv6.h> 73#include <linux/netfilter_ipv6.h>
94 74
75/* Set to 3 to get tracing... */
76#define ND_DEBUG 1
77
78#define ND_PRINTK(val, level, fmt, ...) \
79do { \
80 if (val <= ND_DEBUG) \
81 net_##level##_ratelimited(fmt, ##__VA_ARGS__); \
82} while (0)
83
95static u32 ndisc_hash(const void *pkey, 84static u32 ndisc_hash(const void *pkey,
96 const struct net_device *dev, 85 const struct net_device *dev,
97 __u32 *hash_rnd); 86 __u32 *hash_rnd);
@@ -265,10 +254,9 @@ static struct ndisc_options *ndisc_parse_options(u8 *opt, int opt_len,
265 case ND_OPT_MTU: 254 case ND_OPT_MTU:
266 case ND_OPT_REDIRECT_HDR: 255 case ND_OPT_REDIRECT_HDR:
267 if (ndopts->nd_opt_array[nd_opt->nd_opt_type]) { 256 if (ndopts->nd_opt_array[nd_opt->nd_opt_type]) {
268 ND_PRINTK2(KERN_WARNING 257 ND_PRINTK(2, warn,
269 "%s: duplicated ND6 option found: type=%d\n", 258 "%s: duplicated ND6 option found: type=%d\n",
270 __func__, 259 __func__, nd_opt->nd_opt_type);
271 nd_opt->nd_opt_type);
272 } else { 260 } else {
273 ndopts->nd_opt_array[nd_opt->nd_opt_type] = nd_opt; 261 ndopts->nd_opt_array[nd_opt->nd_opt_type] = nd_opt;
274 } 262 }
@@ -296,10 +284,11 @@ static struct ndisc_options *ndisc_parse_options(u8 *opt, int opt_len,
296 * to accommodate future extension to the 284 * to accommodate future extension to the
297 * protocol. 285 * protocol.
298 */ 286 */
299 ND_PRINTK2(KERN_NOTICE 287 ND_PRINTK(2, notice,
300 "%s: ignored unsupported option; type=%d, len=%d\n", 288 "%s: ignored unsupported option; type=%d, len=%d\n",
301 __func__, 289 __func__,
302 nd_opt->nd_opt_type, nd_opt->nd_opt_len); 290 nd_opt->nd_opt_type,
291 nd_opt->nd_opt_len);
303 } 292 }
304 } 293 }
305 opt_len -= l; 294 opt_len -= l;
@@ -455,9 +444,8 @@ struct sk_buff *ndisc_build_skb(struct net_device *dev,
455 len + hlen + tlen), 444 len + hlen + tlen),
456 1, &err); 445 1, &err);
457 if (!skb) { 446 if (!skb) {
458 ND_PRINTK0(KERN_ERR 447 ND_PRINTK(0, err, "ND: %s failed to allocate an skb, err=%d\n",
459 "ICMPv6 ND: %s failed to allocate an skb, err=%d.\n", 448 __func__, err);
460 __func__, err);
461 return NULL; 449 return NULL;
462 } 450 }
463 451
@@ -693,8 +681,9 @@ static void ndisc_solicit(struct neighbour *neigh, struct sk_buff *skb)
693 681
694 if ((probes -= neigh->parms->ucast_probes) < 0) { 682 if ((probes -= neigh->parms->ucast_probes) < 0) {
695 if (!(neigh->nud_state & NUD_VALID)) { 683 if (!(neigh->nud_state & NUD_VALID)) {
696 ND_PRINTK1(KERN_DEBUG "%s: trying to ucast probe in NUD_INVALID: %pI6\n", 684 ND_PRINTK(1, dbg,
697 __func__, target); 685 "%s: trying to ucast probe in NUD_INVALID: %pI6\n",
686 __func__, target);
698 } 687 }
699 ndisc_send_ns(dev, neigh, target, target, saddr); 688 ndisc_send_ns(dev, neigh, target, target, saddr);
700 } else if ((probes -= neigh->parms->app_probes) < 0) { 689 } else if ((probes -= neigh->parms->app_probes) < 0) {
@@ -740,8 +729,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
740 int is_router = -1; 729 int is_router = -1;
741 730
742 if (ipv6_addr_is_multicast(&msg->target)) { 731 if (ipv6_addr_is_multicast(&msg->target)) {
743 ND_PRINTK2(KERN_WARNING 732 ND_PRINTK(2, warn, "NS: multicast target address\n");
744 "ICMPv6 NS: multicast target address");
745 return; 733 return;
746 } 734 }
747 735
@@ -754,22 +742,20 @@ static void ndisc_recv_ns(struct sk_buff *skb)
754 daddr->s6_addr32[1] == htonl(0x00000000) && 742 daddr->s6_addr32[1] == htonl(0x00000000) &&
755 daddr->s6_addr32[2] == htonl(0x00000001) && 743 daddr->s6_addr32[2] == htonl(0x00000001) &&
756 daddr->s6_addr [12] == 0xff )) { 744 daddr->s6_addr [12] == 0xff )) {
757 ND_PRINTK2(KERN_WARNING 745 ND_PRINTK(2, warn, "NS: bad DAD packet (wrong destination)\n");
758 "ICMPv6 NS: bad DAD packet (wrong destination)\n");
759 return; 746 return;
760 } 747 }
761 748
762 if (!ndisc_parse_options(msg->opt, ndoptlen, &ndopts)) { 749 if (!ndisc_parse_options(msg->opt, ndoptlen, &ndopts)) {
763 ND_PRINTK2(KERN_WARNING 750 ND_PRINTK(2, warn, "NS: invalid ND options\n");
764 "ICMPv6 NS: invalid ND options\n");
765 return; 751 return;
766 } 752 }
767 753
768 if (ndopts.nd_opts_src_lladdr) { 754 if (ndopts.nd_opts_src_lladdr) {
769 lladdr = ndisc_opt_addr_data(ndopts.nd_opts_src_lladdr, dev); 755 lladdr = ndisc_opt_addr_data(ndopts.nd_opts_src_lladdr, dev);
770 if (!lladdr) { 756 if (!lladdr) {
771 ND_PRINTK2(KERN_WARNING 757 ND_PRINTK(2, warn,
772 "ICMPv6 NS: invalid link-layer address length\n"); 758 "NS: invalid link-layer address length\n");
773 return; 759 return;
774 } 760 }
775 761
@@ -779,8 +765,8 @@ static void ndisc_recv_ns(struct sk_buff *skb)
779 * in the message. 765 * in the message.
780 */ 766 */
781 if (dad) { 767 if (dad) {
782 ND_PRINTK2(KERN_WARNING 768 ND_PRINTK(2, warn,
783 "ICMPv6 NS: bad DAD packet (link-layer address option)\n"); 769 "NS: bad DAD packet (link-layer address option)\n");
784 return; 770 return;
785 } 771 }
786 } 772 }
@@ -898,34 +884,30 @@ static void ndisc_recv_na(struct sk_buff *skb)
898 struct neighbour *neigh; 884 struct neighbour *neigh;
899 885
900 if (skb->len < sizeof(struct nd_msg)) { 886 if (skb->len < sizeof(struct nd_msg)) {
901 ND_PRINTK2(KERN_WARNING 887 ND_PRINTK(2, warn, "NA: packet too short\n");
902 "ICMPv6 NA: packet too short\n");
903 return; 888 return;
904 } 889 }
905 890
906 if (ipv6_addr_is_multicast(&msg->target)) { 891 if (ipv6_addr_is_multicast(&msg->target)) {
907 ND_PRINTK2(KERN_WARNING 892 ND_PRINTK(2, warn, "NA: target address is multicast\n");
908 "ICMPv6 NA: target address is multicast.\n");
909 return; 893 return;
910 } 894 }
911 895
912 if (ipv6_addr_is_multicast(daddr) && 896 if (ipv6_addr_is_multicast(daddr) &&
913 msg->icmph.icmp6_solicited) { 897 msg->icmph.icmp6_solicited) {
914 ND_PRINTK2(KERN_WARNING 898 ND_PRINTK(2, warn, "NA: solicited NA is multicasted\n");
915 "ICMPv6 NA: solicited NA is multicasted.\n");
916 return; 899 return;
917 } 900 }
918 901
919 if (!ndisc_parse_options(msg->opt, ndoptlen, &ndopts)) { 902 if (!ndisc_parse_options(msg->opt, ndoptlen, &ndopts)) {
920 ND_PRINTK2(KERN_WARNING 903 ND_PRINTK(2, warn, "NS: invalid ND option\n");
921 "ICMPv6 NS: invalid ND option\n");
922 return; 904 return;
923 } 905 }
924 if (ndopts.nd_opts_tgt_lladdr) { 906 if (ndopts.nd_opts_tgt_lladdr) {
925 lladdr = ndisc_opt_addr_data(ndopts.nd_opts_tgt_lladdr, dev); 907 lladdr = ndisc_opt_addr_data(ndopts.nd_opts_tgt_lladdr, dev);
926 if (!lladdr) { 908 if (!lladdr) {
927 ND_PRINTK2(KERN_WARNING 909 ND_PRINTK(2, warn,
928 "ICMPv6 NA: invalid link-layer address length\n"); 910 "NA: invalid link-layer address length\n");
929 return; 911 return;
930 } 912 }
931 } 913 }
@@ -946,9 +928,9 @@ static void ndisc_recv_na(struct sk_buff *skb)
946 unsolicited advertisement. 928 unsolicited advertisement.
947 */ 929 */
948 if (skb->pkt_type != PACKET_LOOPBACK) 930 if (skb->pkt_type != PACKET_LOOPBACK)
949 ND_PRINTK1(KERN_WARNING 931 ND_PRINTK(1, warn,
950 "ICMPv6 NA: someone advertises our address %pI6 on %s!\n", 932 "NA: someone advertises our address %pI6 on %s!\n",
951 &ifp->addr, ifp->idev->dev->name); 933 &ifp->addr, ifp->idev->dev->name);
952 in6_ifa_put(ifp); 934 in6_ifa_put(ifp);
953 return; 935 return;
954 } 936 }
@@ -1010,8 +992,7 @@ static void ndisc_recv_rs(struct sk_buff *skb)
1010 992
1011 idev = __in6_dev_get(skb->dev); 993 idev = __in6_dev_get(skb->dev);
1012 if (!idev) { 994 if (!idev) {
1013 if (net_ratelimit()) 995 ND_PRINTK(1, err, "RS: can't find in6 device\n");
1014 ND_PRINTK1("ICMP6 RS: can't find in6 device\n");
1015 return; 996 return;
1016 } 997 }
1017 998
@@ -1028,8 +1009,7 @@ static void ndisc_recv_rs(struct sk_buff *skb)
1028 1009
1029 /* Parse ND options */ 1010 /* Parse ND options */
1030 if (!ndisc_parse_options(rs_msg->opt, ndoptlen, &ndopts)) { 1011 if (!ndisc_parse_options(rs_msg->opt, ndoptlen, &ndopts)) {
1031 if (net_ratelimit()) 1012 ND_PRINTK(2, notice, "NS: invalid ND option, ignored\n");
1032 ND_PRINTK2("ICMP6 NS: invalid ND option, ignored\n");
1033 goto out; 1013 goto out;
1034 } 1014 }
1035 1015
@@ -1127,20 +1107,17 @@ static void ndisc_router_discovery(struct sk_buff *skb)
1127 optlen = (skb->tail - skb->transport_header) - sizeof(struct ra_msg); 1107 optlen = (skb->tail - skb->transport_header) - sizeof(struct ra_msg);
1128 1108
1129 if (!(ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL)) { 1109 if (!(ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL)) {
1130 ND_PRINTK2(KERN_WARNING 1110 ND_PRINTK(2, warn, "RA: source address is not link-local\n");
1131 "ICMPv6 RA: source address is not link-local.\n");
1132 return; 1111 return;
1133 } 1112 }
1134 if (optlen < 0) { 1113 if (optlen < 0) {
1135 ND_PRINTK2(KERN_WARNING 1114 ND_PRINTK(2, warn, "RA: packet too short\n");
1136 "ICMPv6 RA: packet too short\n");
1137 return; 1115 return;
1138 } 1116 }
1139 1117
1140#ifdef CONFIG_IPV6_NDISC_NODETYPE 1118#ifdef CONFIG_IPV6_NDISC_NODETYPE
1141 if (skb->ndisc_nodetype == NDISC_NODETYPE_HOST) { 1119 if (skb->ndisc_nodetype == NDISC_NODETYPE_HOST) {
1142 ND_PRINTK2(KERN_WARNING 1120 ND_PRINTK(2, warn, "RA: from host or unauthorized router\n");
1143 "ICMPv6 RA: from host or unauthorized router\n");
1144 return; 1121 return;
1145 } 1122 }
1146#endif 1123#endif
@@ -1151,15 +1128,13 @@ static void ndisc_router_discovery(struct sk_buff *skb)
1151 1128
1152 in6_dev = __in6_dev_get(skb->dev); 1129 in6_dev = __in6_dev_get(skb->dev);
1153 if (in6_dev == NULL) { 1130 if (in6_dev == NULL) {
1154 ND_PRINTK0(KERN_ERR 1131 ND_PRINTK(0, err, "RA: can't find inet6 device for %s\n",
1155 "ICMPv6 RA: can't find inet6 device for %s.\n", 1132 skb->dev->name);
1156 skb->dev->name);
1157 return; 1133 return;
1158 } 1134 }
1159 1135
1160 if (!ndisc_parse_options(opt, optlen, &ndopts)) { 1136 if (!ndisc_parse_options(opt, optlen, &ndopts)) {
1161 ND_PRINTK2(KERN_WARNING 1137 ND_PRINTK(2, warn, "RA: invalid ND options\n");
1162 "ICMP6 RA: invalid ND options\n");
1163 return; 1138 return;
1164 } 1139 }
1165 1140
@@ -1212,9 +1187,9 @@ static void ndisc_router_discovery(struct sk_buff *skb)
1212 if (rt) { 1187 if (rt) {
1213 neigh = dst_neigh_lookup(&rt->dst, &ipv6_hdr(skb)->saddr); 1188 neigh = dst_neigh_lookup(&rt->dst, &ipv6_hdr(skb)->saddr);
1214 if (!neigh) { 1189 if (!neigh) {
1215 ND_PRINTK0(KERN_ERR 1190 ND_PRINTK(0, err,
1216 "ICMPv6 RA: %s got default router without neighbour.\n", 1191 "RA: %s got default router without neighbour\n",
1217 __func__); 1192 __func__);
1218 dst_release(&rt->dst); 1193 dst_release(&rt->dst);
1219 return; 1194 return;
1220 } 1195 }
@@ -1225,22 +1200,21 @@ static void ndisc_router_discovery(struct sk_buff *skb)
1225 } 1200 }
1226 1201
1227 if (rt == NULL && lifetime) { 1202 if (rt == NULL && lifetime) {
1228 ND_PRINTK3(KERN_DEBUG 1203 ND_PRINTK(3, dbg, "RA: adding default router\n");
1229 "ICMPv6 RA: adding default router.\n");
1230 1204
1231 rt = rt6_add_dflt_router(&ipv6_hdr(skb)->saddr, skb->dev, pref); 1205 rt = rt6_add_dflt_router(&ipv6_hdr(skb)->saddr, skb->dev, pref);
1232 if (rt == NULL) { 1206 if (rt == NULL) {
1233 ND_PRINTK0(KERN_ERR 1207 ND_PRINTK(0, err,
1234 "ICMPv6 RA: %s failed to add default route.\n", 1208 "RA: %s failed to add default route\n",
1235 __func__); 1209 __func__);
1236 return; 1210 return;
1237 } 1211 }
1238 1212
1239 neigh = dst_neigh_lookup(&rt->dst, &ipv6_hdr(skb)->saddr); 1213 neigh = dst_neigh_lookup(&rt->dst, &ipv6_hdr(skb)->saddr);
1240 if (neigh == NULL) { 1214 if (neigh == NULL) {
1241 ND_PRINTK0(KERN_ERR 1215 ND_PRINTK(0, err,
1242 "ICMPv6 RA: %s got default router without neighbour.\n", 1216 "RA: %s got default router without neighbour\n",
1243 __func__); 1217 __func__);
1244 dst_release(&rt->dst); 1218 dst_release(&rt->dst);
1245 return; 1219 return;
1246 } 1220 }
@@ -1308,8 +1282,8 @@ skip_linkparms:
1308 lladdr = ndisc_opt_addr_data(ndopts.nd_opts_src_lladdr, 1282 lladdr = ndisc_opt_addr_data(ndopts.nd_opts_src_lladdr,
1309 skb->dev); 1283 skb->dev);
1310 if (!lladdr) { 1284 if (!lladdr) {
1311 ND_PRINTK2(KERN_WARNING 1285 ND_PRINTK(2, warn,
1312 "ICMPv6 RA: invalid link-layer address length\n"); 1286 "RA: invalid link-layer address length\n");
1313 goto out; 1287 goto out;
1314 } 1288 }
1315 } 1289 }
@@ -1373,9 +1347,7 @@ skip_routeinfo:
1373 mtu = ntohl(n); 1347 mtu = ntohl(n);
1374 1348
1375 if (mtu < IPV6_MIN_MTU || mtu > skb->dev->mtu) { 1349 if (mtu < IPV6_MIN_MTU || mtu > skb->dev->mtu) {
1376 ND_PRINTK2(KERN_WARNING 1350 ND_PRINTK(2, warn, "RA: invalid mtu: %d\n", mtu);
1377 "ICMPv6 RA: invalid mtu: %d\n",
1378 mtu);
1379 } else if (in6_dev->cnf.mtu6 != mtu) { 1351 } else if (in6_dev->cnf.mtu6 != mtu) {
1380 in6_dev->cnf.mtu6 = mtu; 1352 in6_dev->cnf.mtu6 = mtu;
1381 1353
@@ -1396,8 +1368,7 @@ skip_routeinfo:
1396 } 1368 }
1397 1369
1398 if (ndopts.nd_opts_tgt_lladdr || ndopts.nd_opts_rh) { 1370 if (ndopts.nd_opts_tgt_lladdr || ndopts.nd_opts_rh) {
1399 ND_PRINTK2(KERN_WARNING 1371 ND_PRINTK(2, warn, "RA: invalid RA options\n");
1400 "ICMPv6 RA: invalid RA options");
1401 } 1372 }
1402out: 1373out:
1403 if (rt) 1374 if (rt)
@@ -1422,15 +1393,15 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
1422 switch (skb->ndisc_nodetype) { 1393 switch (skb->ndisc_nodetype) {
1423 case NDISC_NODETYPE_HOST: 1394 case NDISC_NODETYPE_HOST:
1424 case NDISC_NODETYPE_NODEFAULT: 1395 case NDISC_NODETYPE_NODEFAULT:
1425 ND_PRINTK2(KERN_WARNING 1396 ND_PRINTK(2, warn,
1426 "ICMPv6 Redirect: from host or unauthorized router\n"); 1397 "Redirect: from host or unauthorized router\n");
1427 return; 1398 return;
1428 } 1399 }
1429#endif 1400#endif
1430 1401
1431 if (!(ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL)) { 1402 if (!(ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL)) {
1432 ND_PRINTK2(KERN_WARNING 1403 ND_PRINTK(2, warn,
1433 "ICMPv6 Redirect: source address is not link-local.\n"); 1404 "Redirect: source address is not link-local\n");
1434 return; 1405 return;
1435 } 1406 }
1436 1407
@@ -1438,8 +1409,7 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
1438 optlen -= sizeof(struct icmp6hdr) + 2 * sizeof(struct in6_addr); 1409 optlen -= sizeof(struct icmp6hdr) + 2 * sizeof(struct in6_addr);
1439 1410
1440 if (optlen < 0) { 1411 if (optlen < 0) {
1441 ND_PRINTK2(KERN_WARNING 1412 ND_PRINTK(2, warn, "Redirect: packet too short\n");
1442 "ICMPv6 Redirect: packet too short\n");
1443 return; 1413 return;
1444 } 1414 }
1445 1415
@@ -1448,8 +1418,8 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
1448 dest = target + 1; 1418 dest = target + 1;
1449 1419
1450 if (ipv6_addr_is_multicast(dest)) { 1420 if (ipv6_addr_is_multicast(dest)) {
1451 ND_PRINTK2(KERN_WARNING 1421 ND_PRINTK(2, warn,
1452 "ICMPv6 Redirect: destination address is multicast.\n"); 1422 "Redirect: destination address is multicast\n");
1453 return; 1423 return;
1454 } 1424 }
1455 1425
@@ -1457,8 +1427,8 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
1457 on_link = 1; 1427 on_link = 1;
1458 } else if (ipv6_addr_type(target) != 1428 } else if (ipv6_addr_type(target) !=
1459 (IPV6_ADDR_UNICAST|IPV6_ADDR_LINKLOCAL)) { 1429 (IPV6_ADDR_UNICAST|IPV6_ADDR_LINKLOCAL)) {
1460 ND_PRINTK2(KERN_WARNING 1430 ND_PRINTK(2, warn,
1461 "ICMPv6 Redirect: target address is not link-local unicast.\n"); 1431 "Redirect: target address is not link-local unicast\n");
1462 return; 1432 return;
1463 } 1433 }
1464 1434
@@ -1474,16 +1444,15 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
1474 */ 1444 */
1475 1445
1476 if (!ndisc_parse_options((u8*)(dest + 1), optlen, &ndopts)) { 1446 if (!ndisc_parse_options((u8*)(dest + 1), optlen, &ndopts)) {
1477 ND_PRINTK2(KERN_WARNING 1447 ND_PRINTK(2, warn, "Redirect: invalid ND options\n");
1478 "ICMPv6 Redirect: invalid ND options\n");
1479 return; 1448 return;
1480 } 1449 }
1481 if (ndopts.nd_opts_tgt_lladdr) { 1450 if (ndopts.nd_opts_tgt_lladdr) {
1482 lladdr = ndisc_opt_addr_data(ndopts.nd_opts_tgt_lladdr, 1451 lladdr = ndisc_opt_addr_data(ndopts.nd_opts_tgt_lladdr,
1483 skb->dev); 1452 skb->dev);
1484 if (!lladdr) { 1453 if (!lladdr) {
1485 ND_PRINTK2(KERN_WARNING 1454 ND_PRINTK(2, warn,
1486 "ICMPv6 Redirect: invalid link-layer address length\n"); 1455 "Redirect: invalid link-layer address length\n");
1487 return; 1456 return;
1488 } 1457 }
1489 } 1458 }
@@ -1518,16 +1487,15 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
1518 u8 ha_buf[MAX_ADDR_LEN], *ha = NULL; 1487 u8 ha_buf[MAX_ADDR_LEN], *ha = NULL;
1519 1488
1520 if (ipv6_get_lladdr(dev, &saddr_buf, IFA_F_TENTATIVE)) { 1489 if (ipv6_get_lladdr(dev, &saddr_buf, IFA_F_TENTATIVE)) {
1521 ND_PRINTK2(KERN_WARNING 1490 ND_PRINTK(2, warn, "Redirect: no link-local address on %s\n",
1522 "ICMPv6 Redirect: no link-local address on %s\n", 1491 dev->name);
1523 dev->name);
1524 return; 1492 return;
1525 } 1493 }
1526 1494
1527 if (!ipv6_addr_equal(&ipv6_hdr(skb)->daddr, target) && 1495 if (!ipv6_addr_equal(&ipv6_hdr(skb)->daddr, target) &&
1528 ipv6_addr_type(target) != (IPV6_ADDR_UNICAST|IPV6_ADDR_LINKLOCAL)) { 1496 ipv6_addr_type(target) != (IPV6_ADDR_UNICAST|IPV6_ADDR_LINKLOCAL)) {
1529 ND_PRINTK2(KERN_WARNING 1497 ND_PRINTK(2, warn,
1530 "ICMPv6 Redirect: target address is not link-local unicast.\n"); 1498 "Redirect: target address is not link-local unicast\n");
1531 return; 1499 return;
1532 } 1500 }
1533 1501
@@ -1546,8 +1514,8 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
1546 rt = (struct rt6_info *) dst; 1514 rt = (struct rt6_info *) dst;
1547 1515
1548 if (rt->rt6i_flags & RTF_GATEWAY) { 1516 if (rt->rt6i_flags & RTF_GATEWAY) {
1549 ND_PRINTK2(KERN_WARNING 1517 ND_PRINTK(2, warn,
1550 "ICMPv6 Redirect: destination is not a neighbour.\n"); 1518 "Redirect: destination is not a neighbour\n");
1551 goto release; 1519 goto release;
1552 } 1520 }
1553 if (!rt->rt6i_peer) 1521 if (!rt->rt6i_peer)
@@ -1558,8 +1526,8 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
1558 if (dev->addr_len) { 1526 if (dev->addr_len) {
1559 struct neighbour *neigh = dst_neigh_lookup(skb_dst(skb), target); 1527 struct neighbour *neigh = dst_neigh_lookup(skb_dst(skb), target);
1560 if (!neigh) { 1528 if (!neigh) {
1561 ND_PRINTK2(KERN_WARNING 1529 ND_PRINTK(2, warn,
1562 "ICMPv6 Redirect: no neigh for target address\n"); 1530 "Redirect: no neigh for target address\n");
1563 goto release; 1531 goto release;
1564 } 1532 }
1565 1533
@@ -1587,9 +1555,9 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
1587 len + hlen + tlen), 1555 len + hlen + tlen),
1588 1, &err); 1556 1, &err);
1589 if (buff == NULL) { 1557 if (buff == NULL) {
1590 ND_PRINTK0(KERN_ERR 1558 ND_PRINTK(0, err,
1591 "ICMPv6 Redirect: %s failed to allocate an skb, err=%d.\n", 1559 "Redirect: %s failed to allocate an skb, err=%d\n",
1592 __func__, err); 1560 __func__, err);
1593 goto release; 1561 goto release;
1594 } 1562 }
1595 1563
@@ -1674,16 +1642,14 @@ int ndisc_rcv(struct sk_buff *skb)
1674 __skb_push(skb, skb->data - skb_transport_header(skb)); 1642 __skb_push(skb, skb->data - skb_transport_header(skb));
1675 1643
1676 if (ipv6_hdr(skb)->hop_limit != 255) { 1644 if (ipv6_hdr(skb)->hop_limit != 255) {
1677 ND_PRINTK2(KERN_WARNING 1645 ND_PRINTK(2, warn, "NDISC: invalid hop-limit: %d\n",
1678 "ICMPv6 NDISC: invalid hop-limit: %d\n", 1646 ipv6_hdr(skb)->hop_limit);
1679 ipv6_hdr(skb)->hop_limit);
1680 return 0; 1647 return 0;
1681 } 1648 }
1682 1649
1683 if (msg->icmph.icmp6_code != 0) { 1650 if (msg->icmph.icmp6_code != 0) {
1684 ND_PRINTK2(KERN_WARNING 1651 ND_PRINTK(2, warn, "NDISC: invalid ICMPv6 code: %d\n",
1685 "ICMPv6 NDISC: invalid ICMPv6 code: %d\n", 1652 msg->icmph.icmp6_code);
1686 msg->icmph.icmp6_code);
1687 return 0; 1653 return 0;
1688 } 1654 }
1689 1655
@@ -1804,9 +1770,9 @@ static int __net_init ndisc_net_init(struct net *net)
1804 err = inet_ctl_sock_create(&sk, PF_INET6, 1770 err = inet_ctl_sock_create(&sk, PF_INET6,
1805 SOCK_RAW, IPPROTO_ICMPV6, net); 1771 SOCK_RAW, IPPROTO_ICMPV6, net);
1806 if (err < 0) { 1772 if (err < 0) {
1807 ND_PRINTK0(KERN_ERR 1773 ND_PRINTK(0, err,
1808 "ICMPv6 NDISC: Failed to initialize the control socket (err %d).\n", 1774 "NDISC: Failed to initialize the control socket (err %d)\n",
1809 err); 1775 err);
1810 return err; 1776 return err;
1811 } 1777 }
1812 1778