Commit 675418d5 authored by Joe Perches's avatar Joe Perches Committed by David S. Miller

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: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f342cda7
...@@ -27,27 +27,7 @@ ...@@ -27,27 +27,7 @@
* YOSHIFUJI Hideaki @USAGI : Verify ND options properly * YOSHIFUJI Hideaki @USAGI : Verify ND options properly
*/ */
/* Set to 3 to get tracing... */ #define pr_fmt(fmt) "ICMPv6: " fmt
#define ND_DEBUG 1
#define ND_PRINTK(fmt, args...) do { if (net_ratelimit()) { printk(fmt, ## args); } } while(0)
#define ND_NOPRINTK(x...) do { ; } while(0)
#define ND_PRINTK0 ND_PRINTK
#define ND_PRINTK1 ND_NOPRINTK
#define ND_PRINTK2 ND_NOPRINTK
#define ND_PRINTK3 ND_NOPRINTK
#if ND_DEBUG >= 1
#undef ND_PRINTK1
#define ND_PRINTK1 ND_PRINTK
#endif
#if ND_DEBUG >= 2
#undef ND_PRINTK2
#define ND_PRINTK2 ND_PRINTK
#endif
#if ND_DEBUG >= 3
#undef ND_PRINTK3
#define ND_PRINTK3 ND_PRINTK
#endif
#include <linux/module.h> #include <linux/module.h>
#include <linux/errno.h> #include <linux/errno.h>
...@@ -92,6 +72,15 @@ ...@@ -92,6 +72,15 @@
#include <linux/netfilter.h> #include <linux/netfilter.h>
#include <linux/netfilter_ipv6.h> #include <linux/netfilter_ipv6.h>
/* Set to 3 to get tracing... */
#define ND_DEBUG 1
#define ND_PRINTK(val, level, fmt, ...) \
do { \
if (val <= ND_DEBUG) \
net_##level##_ratelimited(fmt, ##__VA_ARGS__); \
} while (0)
static u32 ndisc_hash(const void *pkey, static u32 ndisc_hash(const void *pkey,
const struct net_device *dev, const struct net_device *dev,
__u32 *hash_rnd); __u32 *hash_rnd);
...@@ -265,10 +254,9 @@ static struct ndisc_options *ndisc_parse_options(u8 *opt, int opt_len, ...@@ -265,10 +254,9 @@ static struct ndisc_options *ndisc_parse_options(u8 *opt, int opt_len,
case ND_OPT_MTU: case ND_OPT_MTU:
case ND_OPT_REDIRECT_HDR: case ND_OPT_REDIRECT_HDR:
if (ndopts->nd_opt_array[nd_opt->nd_opt_type]) { if (ndopts->nd_opt_array[nd_opt->nd_opt_type]) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn,
"%s: duplicated ND6 option found: type=%d\n", "%s: duplicated ND6 option found: type=%d\n",
__func__, __func__, nd_opt->nd_opt_type);
nd_opt->nd_opt_type);
} else { } else {
ndopts->nd_opt_array[nd_opt->nd_opt_type] = nd_opt; ndopts->nd_opt_array[nd_opt->nd_opt_type] = nd_opt;
} }
...@@ -296,10 +284,11 @@ static struct ndisc_options *ndisc_parse_options(u8 *opt, int opt_len, ...@@ -296,10 +284,11 @@ static struct ndisc_options *ndisc_parse_options(u8 *opt, int opt_len,
* to accommodate future extension to the * to accommodate future extension to the
* protocol. * protocol.
*/ */
ND_PRINTK2(KERN_NOTICE ND_PRINTK(2, notice,
"%s: ignored unsupported option; type=%d, len=%d\n", "%s: ignored unsupported option; type=%d, len=%d\n",
__func__, __func__,
nd_opt->nd_opt_type, nd_opt->nd_opt_len); nd_opt->nd_opt_type,
nd_opt->nd_opt_len);
} }
} }
opt_len -= l; opt_len -= l;
...@@ -455,9 +444,8 @@ struct sk_buff *ndisc_build_skb(struct net_device *dev, ...@@ -455,9 +444,8 @@ struct sk_buff *ndisc_build_skb(struct net_device *dev,
len + hlen + tlen), len + hlen + tlen),
1, &err); 1, &err);
if (!skb) { if (!skb) {
ND_PRINTK0(KERN_ERR ND_PRINTK(0, err, "ND: %s failed to allocate an skb, err=%d\n",
"ICMPv6 ND: %s failed to allocate an skb, err=%d.\n", __func__, err);
__func__, err);
return NULL; return NULL;
} }
...@@ -693,8 +681,9 @@ static void ndisc_solicit(struct neighbour *neigh, struct sk_buff *skb) ...@@ -693,8 +681,9 @@ static void ndisc_solicit(struct neighbour *neigh, struct sk_buff *skb)
if ((probes -= neigh->parms->ucast_probes) < 0) { if ((probes -= neigh->parms->ucast_probes) < 0) {
if (!(neigh->nud_state & NUD_VALID)) { if (!(neigh->nud_state & NUD_VALID)) {
ND_PRINTK1(KERN_DEBUG "%s: trying to ucast probe in NUD_INVALID: %pI6\n", ND_PRINTK(1, dbg,
__func__, target); "%s: trying to ucast probe in NUD_INVALID: %pI6\n",
__func__, target);
} }
ndisc_send_ns(dev, neigh, target, target, saddr); ndisc_send_ns(dev, neigh, target, target, saddr);
} else if ((probes -= neigh->parms->app_probes) < 0) { } else if ((probes -= neigh->parms->app_probes) < 0) {
...@@ -740,8 +729,7 @@ static void ndisc_recv_ns(struct sk_buff *skb) ...@@ -740,8 +729,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
int is_router = -1; int is_router = -1;
if (ipv6_addr_is_multicast(&msg->target)) { if (ipv6_addr_is_multicast(&msg->target)) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn, "NS: multicast target address\n");
"ICMPv6 NS: multicast target address");
return; return;
} }
...@@ -754,22 +742,20 @@ static void ndisc_recv_ns(struct sk_buff *skb) ...@@ -754,22 +742,20 @@ static void ndisc_recv_ns(struct sk_buff *skb)
daddr->s6_addr32[1] == htonl(0x00000000) && daddr->s6_addr32[1] == htonl(0x00000000) &&
daddr->s6_addr32[2] == htonl(0x00000001) && daddr->s6_addr32[2] == htonl(0x00000001) &&
daddr->s6_addr [12] == 0xff )) { daddr->s6_addr [12] == 0xff )) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn, "NS: bad DAD packet (wrong destination)\n");
"ICMPv6 NS: bad DAD packet (wrong destination)\n");
return; return;
} }
if (!ndisc_parse_options(msg->opt, ndoptlen, &ndopts)) { if (!ndisc_parse_options(msg->opt, ndoptlen, &ndopts)) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn, "NS: invalid ND options\n");
"ICMPv6 NS: invalid ND options\n");
return; return;
} }
if (ndopts.nd_opts_src_lladdr) { if (ndopts.nd_opts_src_lladdr) {
lladdr = ndisc_opt_addr_data(ndopts.nd_opts_src_lladdr, dev); lladdr = ndisc_opt_addr_data(ndopts.nd_opts_src_lladdr, dev);
if (!lladdr) { if (!lladdr) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn,
"ICMPv6 NS: invalid link-layer address length\n"); "NS: invalid link-layer address length\n");
return; return;
} }
...@@ -779,8 +765,8 @@ static void ndisc_recv_ns(struct sk_buff *skb) ...@@ -779,8 +765,8 @@ static void ndisc_recv_ns(struct sk_buff *skb)
* in the message. * in the message.
*/ */
if (dad) { if (dad) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn,
"ICMPv6 NS: bad DAD packet (link-layer address option)\n"); "NS: bad DAD packet (link-layer address option)\n");
return; return;
} }
} }
...@@ -898,34 +884,30 @@ static void ndisc_recv_na(struct sk_buff *skb) ...@@ -898,34 +884,30 @@ static void ndisc_recv_na(struct sk_buff *skb)
struct neighbour *neigh; struct neighbour *neigh;
if (skb->len < sizeof(struct nd_msg)) { if (skb->len < sizeof(struct nd_msg)) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn, "NA: packet too short\n");
"ICMPv6 NA: packet too short\n");
return; return;
} }
if (ipv6_addr_is_multicast(&msg->target)) { if (ipv6_addr_is_multicast(&msg->target)) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn, "NA: target address is multicast\n");
"ICMPv6 NA: target address is multicast.\n");
return; return;
} }
if (ipv6_addr_is_multicast(daddr) && if (ipv6_addr_is_multicast(daddr) &&
msg->icmph.icmp6_solicited) { msg->icmph.icmp6_solicited) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn, "NA: solicited NA is multicasted\n");
"ICMPv6 NA: solicited NA is multicasted.\n");
return; return;
} }
if (!ndisc_parse_options(msg->opt, ndoptlen, &ndopts)) { if (!ndisc_parse_options(msg->opt, ndoptlen, &ndopts)) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn, "NS: invalid ND option\n");
"ICMPv6 NS: invalid ND option\n");
return; return;
} }
if (ndopts.nd_opts_tgt_lladdr) { if (ndopts.nd_opts_tgt_lladdr) {
lladdr = ndisc_opt_addr_data(ndopts.nd_opts_tgt_lladdr, dev); lladdr = ndisc_opt_addr_data(ndopts.nd_opts_tgt_lladdr, dev);
if (!lladdr) { if (!lladdr) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn,
"ICMPv6 NA: invalid link-layer address length\n"); "NA: invalid link-layer address length\n");
return; return;
} }
} }
...@@ -946,9 +928,9 @@ static void ndisc_recv_na(struct sk_buff *skb) ...@@ -946,9 +928,9 @@ static void ndisc_recv_na(struct sk_buff *skb)
unsolicited advertisement. unsolicited advertisement.
*/ */
if (skb->pkt_type != PACKET_LOOPBACK) if (skb->pkt_type != PACKET_LOOPBACK)
ND_PRINTK1(KERN_WARNING ND_PRINTK(1, warn,
"ICMPv6 NA: someone advertises our address %pI6 on %s!\n", "NA: someone advertises our address %pI6 on %s!\n",
&ifp->addr, ifp->idev->dev->name); &ifp->addr, ifp->idev->dev->name);
in6_ifa_put(ifp); in6_ifa_put(ifp);
return; return;
} }
...@@ -1010,8 +992,7 @@ static void ndisc_recv_rs(struct sk_buff *skb) ...@@ -1010,8 +992,7 @@ static void ndisc_recv_rs(struct sk_buff *skb)
idev = __in6_dev_get(skb->dev); idev = __in6_dev_get(skb->dev);
if (!idev) { if (!idev) {
if (net_ratelimit()) ND_PRINTK(1, err, "RS: can't find in6 device\n");
ND_PRINTK1("ICMP6 RS: can't find in6 device\n");
return; return;
} }
...@@ -1028,8 +1009,7 @@ static void ndisc_recv_rs(struct sk_buff *skb) ...@@ -1028,8 +1009,7 @@ static void ndisc_recv_rs(struct sk_buff *skb)
/* Parse ND options */ /* Parse ND options */
if (!ndisc_parse_options(rs_msg->opt, ndoptlen, &ndopts)) { if (!ndisc_parse_options(rs_msg->opt, ndoptlen, &ndopts)) {
if (net_ratelimit()) ND_PRINTK(2, notice, "NS: invalid ND option, ignored\n");
ND_PRINTK2("ICMP6 NS: invalid ND option, ignored\n");
goto out; goto out;
} }
...@@ -1127,20 +1107,17 @@ static void ndisc_router_discovery(struct sk_buff *skb) ...@@ -1127,20 +1107,17 @@ static void ndisc_router_discovery(struct sk_buff *skb)
optlen = (skb->tail - skb->transport_header) - sizeof(struct ra_msg); optlen = (skb->tail - skb->transport_header) - sizeof(struct ra_msg);
if (!(ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL)) { if (!(ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL)) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn, "RA: source address is not link-local\n");
"ICMPv6 RA: source address is not link-local.\n");
return; return;
} }
if (optlen < 0) { if (optlen < 0) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn, "RA: packet too short\n");
"ICMPv6 RA: packet too short\n");
return; return;
} }
#ifdef CONFIG_IPV6_NDISC_NODETYPE #ifdef CONFIG_IPV6_NDISC_NODETYPE
if (skb->ndisc_nodetype == NDISC_NODETYPE_HOST) { if (skb->ndisc_nodetype == NDISC_NODETYPE_HOST) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn, "RA: from host or unauthorized router\n");
"ICMPv6 RA: from host or unauthorized router\n");
return; return;
} }
#endif #endif
...@@ -1151,15 +1128,13 @@ static void ndisc_router_discovery(struct sk_buff *skb) ...@@ -1151,15 +1128,13 @@ static void ndisc_router_discovery(struct sk_buff *skb)
in6_dev = __in6_dev_get(skb->dev); in6_dev = __in6_dev_get(skb->dev);
if (in6_dev == NULL) { if (in6_dev == NULL) {
ND_PRINTK0(KERN_ERR ND_PRINTK(0, err, "RA: can't find inet6 device for %s\n",
"ICMPv6 RA: can't find inet6 device for %s.\n", skb->dev->name);
skb->dev->name);
return; return;
} }
if (!ndisc_parse_options(opt, optlen, &ndopts)) { if (!ndisc_parse_options(opt, optlen, &ndopts)) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn, "RA: invalid ND options\n");
"ICMP6 RA: invalid ND options\n");
return; return;
} }
...@@ -1212,9 +1187,9 @@ static void ndisc_router_discovery(struct sk_buff *skb) ...@@ -1212,9 +1187,9 @@ static void ndisc_router_discovery(struct sk_buff *skb)
if (rt) { if (rt) {
neigh = dst_neigh_lookup(&rt->dst, &ipv6_hdr(skb)->saddr); neigh = dst_neigh_lookup(&rt->dst, &ipv6_hdr(skb)->saddr);
if (!neigh) { if (!neigh) {
ND_PRINTK0(KERN_ERR ND_PRINTK(0, err,
"ICMPv6 RA: %s got default router without neighbour.\n", "RA: %s got default router without neighbour\n",
__func__); __func__);
dst_release(&rt->dst); dst_release(&rt->dst);
return; return;
} }
...@@ -1225,22 +1200,21 @@ static void ndisc_router_discovery(struct sk_buff *skb) ...@@ -1225,22 +1200,21 @@ static void ndisc_router_discovery(struct sk_buff *skb)
} }
if (rt == NULL && lifetime) { if (rt == NULL && lifetime) {
ND_PRINTK3(KERN_DEBUG ND_PRINTK(3, dbg, "RA: adding default router\n");
"ICMPv6 RA: adding default router.\n");
rt = rt6_add_dflt_router(&ipv6_hdr(skb)->saddr, skb->dev, pref); rt = rt6_add_dflt_router(&ipv6_hdr(skb)->saddr, skb->dev, pref);
if (rt == NULL) { if (rt == NULL) {
ND_PRINTK0(KERN_ERR ND_PRINTK(0, err,
"ICMPv6 RA: %s failed to add default route.\n", "RA: %s failed to add default route\n",
__func__); __func__);
return; return;
} }
neigh = dst_neigh_lookup(&rt->dst, &ipv6_hdr(skb)->saddr); neigh = dst_neigh_lookup(&rt->dst, &ipv6_hdr(skb)->saddr);
if (neigh == NULL) { if (neigh == NULL) {
ND_PRINTK0(KERN_ERR ND_PRINTK(0, err,
"ICMPv6 RA: %s got default router without neighbour.\n", "RA: %s got default router without neighbour\n",
__func__); __func__);
dst_release(&rt->dst); dst_release(&rt->dst);
return; return;
} }
...@@ -1308,8 +1282,8 @@ static void ndisc_router_discovery(struct sk_buff *skb) ...@@ -1308,8 +1282,8 @@ static void ndisc_router_discovery(struct sk_buff *skb)
lladdr = ndisc_opt_addr_data(ndopts.nd_opts_src_lladdr, lladdr = ndisc_opt_addr_data(ndopts.nd_opts_src_lladdr,
skb->dev); skb->dev);
if (!lladdr) { if (!lladdr) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn,
"ICMPv6 RA: invalid link-layer address length\n"); "RA: invalid link-layer address length\n");
goto out; goto out;
} }
} }
...@@ -1373,9 +1347,7 @@ static void ndisc_router_discovery(struct sk_buff *skb) ...@@ -1373,9 +1347,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
mtu = ntohl(n); mtu = ntohl(n);
if (mtu < IPV6_MIN_MTU || mtu > skb->dev->mtu) { if (mtu < IPV6_MIN_MTU || mtu > skb->dev->mtu) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn, "RA: invalid mtu: %d\n", mtu);
"ICMPv6 RA: invalid mtu: %d\n",
mtu);
} else if (in6_dev->cnf.mtu6 != mtu) { } else if (in6_dev->cnf.mtu6 != mtu) {
in6_dev->cnf.mtu6 = mtu; in6_dev->cnf.mtu6 = mtu;
...@@ -1396,8 +1368,7 @@ static void ndisc_router_discovery(struct sk_buff *skb) ...@@ -1396,8 +1368,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
} }
if (ndopts.nd_opts_tgt_lladdr || ndopts.nd_opts_rh) { if (ndopts.nd_opts_tgt_lladdr || ndopts.nd_opts_rh) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn, "RA: invalid RA options\n");
"ICMPv6 RA: invalid RA options");
} }
out: out:
if (rt) if (rt)
...@@ -1422,15 +1393,15 @@ static void ndisc_redirect_rcv(struct sk_buff *skb) ...@@ -1422,15 +1393,15 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
switch (skb->ndisc_nodetype) { switch (skb->ndisc_nodetype) {
case NDISC_NODETYPE_HOST: case NDISC_NODETYPE_HOST:
case NDISC_NODETYPE_NODEFAULT: case NDISC_NODETYPE_NODEFAULT:
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn,
"ICMPv6 Redirect: from host or unauthorized router\n"); "Redirect: from host or unauthorized router\n");
return; return;
} }
#endif #endif
if (!(ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL)) { if (!(ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL)) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn,
"ICMPv6 Redirect: source address is not link-local.\n"); "Redirect: source address is not link-local\n");
return; return;
} }
...@@ -1438,8 +1409,7 @@ static void ndisc_redirect_rcv(struct sk_buff *skb) ...@@ -1438,8 +1409,7 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
optlen -= sizeof(struct icmp6hdr) + 2 * sizeof(struct in6_addr); optlen -= sizeof(struct icmp6hdr) + 2 * sizeof(struct in6_addr);
if (optlen < 0) { if (optlen < 0) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn, "Redirect: packet too short\n");
"ICMPv6 Redirect: packet too short\n");
return; return;
} }
...@@ -1448,8 +1418,8 @@ static void ndisc_redirect_rcv(struct sk_buff *skb) ...@@ -1448,8 +1418,8 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
dest = target + 1; dest = target + 1;
if (ipv6_addr_is_multicast(dest)) { if (ipv6_addr_is_multicast(dest)) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn,
"ICMPv6 Redirect: destination address is multicast.\n"); "Redirect: destination address is multicast\n");
return; return;
} }
...@@ -1457,8 +1427,8 @@ static void ndisc_redirect_rcv(struct sk_buff *skb) ...@@ -1457,8 +1427,8 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
on_link = 1; on_link = 1;
} else if (ipv6_addr_type(target) != } else if (ipv6_addr_type(target) !=
(IPV6_ADDR_UNICAST|IPV6_ADDR_LINKLOCAL)) { (IPV6_ADDR_UNICAST|IPV6_ADDR_LINKLOCAL)) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn,
"ICMPv6 Redirect: target address is not link-local unicast.\n"); "Redirect: target address is not link-local unicast\n");
return; return;
} }
...@@ -1474,16 +1444,15 @@ static void ndisc_redirect_rcv(struct sk_buff *skb) ...@@ -1474,16 +1444,15 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
*/ */
if (!ndisc_parse_options((u8*)(dest + 1), optlen, &ndopts)) { if (!ndisc_parse_options((u8*)(dest + 1), optlen, &ndopts)) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn, "Redirect: invalid ND options\n");
"ICMPv6 Redirect: invalid ND options\n");
return; return;
} }
if (ndopts.nd_opts_tgt_lladdr) { if (ndopts.nd_opts_tgt_lladdr) {
lladdr = ndisc_opt_addr_data(ndopts.nd_opts_tgt_lladdr, lladdr = ndisc_opt_addr_data(ndopts.nd_opts_tgt_lladdr,
skb->dev); skb->dev);
if (!lladdr) { if (!lladdr) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn,
"ICMPv6 Redirect: invalid link-layer address length\n"); "Redirect: invalid link-layer address length\n");
return; return;
} }
} }
...@@ -1518,16 +1487,15 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target) ...@@ -1518,16 +1487,15 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
u8 ha_buf[MAX_ADDR_LEN], *ha = NULL; u8 ha_buf[MAX_ADDR_LEN], *ha = NULL;
if (ipv6_get_lladdr(dev, &saddr_buf, IFA_F_TENTATIVE)) { if (ipv6_get_lladdr(dev, &saddr_buf, IFA_F_TENTATIVE)) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn, "Redirect: no link-local address on %s\n",
"ICMPv6 Redirect: no link-local address on %s\n", dev->name);
dev->name);
return; return;
} }
if (!ipv6_addr_equal(&ipv6_hdr(skb)->daddr, target) && if (!ipv6_addr_equal(&ipv6_hdr(skb)->daddr, target) &&
ipv6_addr_type(target) != (IPV6_ADDR_UNICAST|IPV6_ADDR_LINKLOCAL)) { ipv6_addr_type(target) != (IPV6_ADDR_UNICAST|IPV6_ADDR_LINKLOCAL)) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn,
"ICMPv6 Redirect: target address is not link-local unicast.\n"); "Redirect: target address is not link-local unicast\n");
return; return;
} }
...@@ -1546,8 +1514,8 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target) ...@@ -1546,8 +1514,8 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
rt = (struct rt6_info *) dst; rt = (struct rt6_info *) dst;
if (rt->rt6i_flags & RTF_GATEWAY) { if (rt->rt6i_flags & RTF_GATEWAY) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn,
"ICMPv6 Redirect: destination is not a neighbour.\n"); "Redirect: destination is not a neighbour\n");
goto release; goto release;
} }
if (!rt->rt6i_peer) if (!rt->rt6i_peer)
...@@ -1558,8 +1526,8 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target) ...@@ -1558,8 +1526,8 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
if (dev->addr_len) { if (dev->addr_len) {
struct neighbour *neigh = dst_neigh_lookup(skb_dst(skb), target); struct neighbour *neigh = dst_neigh_lookup(skb_dst(skb), target);
if (!neigh) { if (!neigh) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn,
"ICMPv6 Redirect: no neigh for target address\n"); "Redirect: no neigh for target address\n");
goto release; goto release;
} }
...@@ -1587,9 +1555,9 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target) ...@@ -1587,9 +1555,9 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
len + hlen + tlen), len + hlen + tlen),
1, &err); 1, &err);
if (buff == NULL) { if (buff == NULL) {
ND_PRINTK0(KERN_ERR ND_PRINTK(0, err,
"ICMPv6 Redirect: %s failed to allocate an skb, err=%d.\n", "Redirect: %s failed to allocate an skb, err=%d\n",
__func__, err); __func__, err);
goto release; goto release;
} }
...@@ -1674,16 +1642,14 @@ int ndisc_rcv(struct sk_buff *skb) ...@@ -1674,16 +1642,14 @@ int ndisc_rcv(struct sk_buff *skb)
__skb_push(skb, skb->data - skb_transport_header(skb)); __skb_push(skb, skb->data - skb_transport_header(skb));
if (ipv6_hdr(skb)->hop_limit != 255) { if (ipv6_hdr(skb)->hop_limit != 255) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn, "NDISC: invalid hop-limit: %d\n",
"ICMPv6 NDISC: invalid hop-limit: %d\n", ipv6_hdr(skb)->hop_limit);
ipv6_hdr(skb)->hop_limit);
return 0; return 0;
} }
if (msg->icmph.icmp6_code != 0) { if (msg->icmph.icmp6_code != 0) {
ND_PRINTK2(KERN_WARNING ND_PRINTK(2, warn, "NDISC: invalid ICMPv6 code: %d\n",
"ICMPv6 NDISC: invalid ICMPv6 code: %d\n", msg->icmph.icmp6_code);
msg->icmph.icmp6_code);
return 0; return 0;
} }
...@@ -1804,9 +1770,9 @@ static int __net_init ndisc_net_init(struct net *net) ...@@ -1804,9 +1770,9 @@ static int __net_init ndisc_net_init(struct net *net)
err = inet_ctl_sock_create(&sk, PF_INET6, err = inet_ctl_sock_create(&sk, PF_INET6,
SOCK_RAW, IPPROTO_ICMPV6, net); SOCK_RAW, IPPROTO_ICMPV6, net);
if (err < 0) { if (err < 0) {
ND_PRINTK0(KERN_ERR ND_PRINTK(0, err,
"ICMPv6 NDISC: Failed to initialize the control socket (err %d).\n", "NDISC: Failed to initialize the control socket (err %d)\n",
err); err);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment