Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
aff4f914
Commit
aff4f914
authored
Feb 10, 2004
by
Hideaki Yoshifuji
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[IPV6]: Clean up ndisc printks.
parent
5850f935
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
104 additions
and
77 deletions
+104
-77
net/ipv6/ndisc.c
net/ipv6/ndisc.c
+104
-77
No files found.
net/ipv6/ndisc.c
View file @
aff4f914
...
...
@@ -28,11 +28,12 @@
/* Set to 3 to get tracing... */
#define ND_DEBUG 1
#define ND_PRINTK(
x...) printk(KERN_DEBUG x
)
#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
...
...
@@ -41,6 +42,10 @@
#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/config.h>
...
...
@@ -210,8 +215,10 @@ static struct ndisc_options *ndisc_parse_options(u8 *opt, int opt_len,
case
ND_OPT_MTU
:
case
ND_OPT_REDIRECT_HDR
:
if
(
ndopts
->
nd_opt_array
[
nd_opt
->
nd_opt_type
])
{
ND_PRINTK2
(
"ndisc_parse_options(): duplicated ND6 option found: type=%d
\n
"
,
nd_opt
->
nd_opt_type
);
ND_PRINTK2
(
KERN_WARNING
"%s(): duplicated ND6 option found: type=%d
\n
"
,
__FUNCTION__
,
nd_opt
->
nd_opt_type
);
}
else
{
ndopts
->
nd_opt_array
[
nd_opt
->
nd_opt_type
]
=
nd_opt
;
}
...
...
@@ -226,8 +233,9 @@ static struct ndisc_options *ndisc_parse_options(u8 *opt, int opt_len,
* Unknown options must be silently ignored,
* to accommodate future extension to the protocol.
*/
ND_PRINTK2
(
KERN_WARNING
"ndisc_parse_options(): ignored unsupported option; type=%d, len=%d
\n
"
,
ND_PRINTK2
(
KERN_NOTICE
"%s(): ignored unsupported option; type=%d, len=%d
\n
"
,
__FUNCTION__
,
nd_opt
->
nd_opt_type
,
nd_opt
->
nd_opt_len
);
}
opt_len
-=
l
;
...
...
@@ -408,7 +416,9 @@ static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh,
1
,
&
err
);
if
(
skb
==
NULL
)
{
ND_PRINTK1
(
"send_na: alloc skb failed
\n
"
);
ND_PRINTK0
(
KERN_ERR
"ICMPv6 NA: %s() failed to allocate an skb.
\n
"
,
__FUNCTION__
);
dst_release
(
dst
);
return
;
}
...
...
@@ -493,7 +503,9 @@ void ndisc_send_ns(struct net_device *dev, struct neighbour *neigh,
skb
=
sock_alloc_send_skb
(
sk
,
MAX_HEADER
+
len
+
LL_RESERVED_SPACE
(
dev
),
1
,
&
err
);
if
(
skb
==
NULL
)
{
ND_PRINTK1
(
"send_ns: alloc skb failed
\n
"
);
ND_PRINTK0
(
KERN_ERR
"ICMPv6 NA: %s() failed to allocate an skb.
\n
"
,
__FUNCTION__
);
dst_release
(
dst
);
return
;
}
...
...
@@ -565,7 +577,9 @@ void ndisc_send_rs(struct net_device *dev, struct in6_addr *saddr,
skb
=
sock_alloc_send_skb
(
sk
,
MAX_HEADER
+
len
+
LL_RESERVED_SPACE
(
dev
),
1
,
&
err
);
if
(
skb
==
NULL
)
{
ND_PRINTK1
(
"send_ns: alloc skb failed
\n
"
);
ND_PRINTK0
(
KERN_ERR
"ICMPv6 RS: %s() failed to allocate an skb.
\n
"
,
__FUNCTION__
);
dst_release
(
dst
);
return
;
}
...
...
@@ -628,8 +642,13 @@ static void ndisc_solicit(struct neighbour *neigh, struct sk_buff *skb)
saddr
=
&
skb
->
nh
.
ipv6h
->
saddr
;
if
((
probes
-=
neigh
->
parms
->
ucast_probes
)
<
0
)
{
if
(
!
(
neigh
->
nud_state
&
NUD_VALID
))
ND_PRINTK1
(
"trying to ucast probe in NUD_INVALID
\n
"
);
if
(
!
(
neigh
->
nud_state
&
NUD_VALID
))
{
ND_PRINTK1
(
KERN_DEBUG
"%s(): trying to ucast probe in NUD_INVALID: "
"%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x
\n
"
,
__FUNCTION__
,
NIP6
(
*
target
));
}
ndisc_send_ns
(
dev
,
neigh
,
target
,
target
,
saddr
);
}
else
if
((
probes
-=
neigh
->
parms
->
app_probes
)
<
0
)
{
#ifdef CONFIG_ARPD
...
...
@@ -658,8 +677,8 @@ static void ndisc_recv_ns(struct sk_buff *skb)
int
inc
;
if
(
ipv6_addr_is_multicast
(
&
msg
->
target
))
{
if
(
net_ratelimit
())
printk
(
KERN_WARNING
"ICMP NS: target address is multicast
\n
"
);
ND_PRINTK2
(
KERN_WARNING
"ICMPv6 NS: multicast target address
"
);
return
;
}
...
...
@@ -672,14 +691,14 @@ static void ndisc_recv_ns(struct sk_buff *skb)
daddr
->
s6_addr32
[
1
]
==
htonl
(
0x00000000
)
&&
daddr
->
s6_addr32
[
2
]
==
htonl
(
0x00000001
)
&&
daddr
->
s6_addr
[
12
]
==
0xff
))
{
if
(
net_ratelimit
())
printk
(
KERN_DEBUG
"ICMP
6 NS: bad DAD packet (wrong destination)
\n
"
);
ND_PRINTK2
(
KERN_WARNING
"ICMPv
6 NS: bad DAD packet (wrong destination)
\n
"
);
return
;
}
if
(
!
ndisc_parse_options
(
msg
->
opt
,
ndoptlen
,
&
ndopts
))
{
if
(
net_ratelimit
())
printk
(
KERN_WARNING
"ICMP NS: invalid ND option, ignored.
\n
"
);
ND_PRINTK2
(
KERN_WARNING
"ICMPv6 NS: invalid ND options
\n
"
);
return
;
}
...
...
@@ -687,8 +706,8 @@ static void ndisc_recv_ns(struct sk_buff *skb)
lladdr
=
(
u8
*
)(
ndopts
.
nd_opts_src_lladdr
+
1
);
lladdrlen
=
ndopts
.
nd_opts_src_lladdr
->
nd_opt_len
<<
3
;
if
(
lladdrlen
!=
NDISC_OPT_SPACE
(
dev
->
addr_len
))
{
if
(
net_ratelimit
())
printk
(
KERN_WARNING
"ICMP NS: bad lladdr length.
\n
"
);
ND_PRINTK2
(
KERN_WARNING
"ICMPv6 NS: invalid link-layer address length
\n
"
);
return
;
}
...
...
@@ -698,8 +717,8 @@ static void ndisc_recv_ns(struct sk_buff *skb)
* in the message.
*/
if
(
dad
)
{
if
(
net_ratelimit
())
printk
(
KERN_WARNING
"ICMP
6 NS: bad DAD packet (link-layer address option)
\n
"
);
ND_PRINTK2
(
KERN_WARNING
"ICMPv
6 NS: bad DAD packet (link-layer address option)
\n
"
);
return
;
}
}
...
...
@@ -813,34 +832,35 @@ static void ndisc_recv_na(struct sk_buff *skb)
struct
neighbour
*
neigh
;
if
(
skb
->
len
<
sizeof
(
struct
nd_msg
))
{
if
(
net_ratelimit
())
printk
(
KERN_WARNING
"ICMP
NA: packet too short
\n
"
);
ND_PRINTK2
(
KERN_WARNING
"ICMPv6
NA: packet too short
\n
"
);
return
;
}
if
(
ipv6_addr_is_multicast
(
&
msg
->
target
))
{
if
(
net_ratelimit
())
printk
(
KERN_WARNING
"NDISC NA: target address is multicast
\n
"
);
ND_PRINTK2
(
KERN_WARNING
"ICMPv6 NA: target address is multicast.
\n
"
);
return
;
}
if
(
ipv6_addr_is_multicast
(
daddr
)
&&
msg
->
icmph
.
icmp6_solicited
)
{
ND_PRINTK0
(
"NDISC: solicited NA is multicasted
\n
"
);
ND_PRINTK2
(
KERN_WARNING
"ICMPv6 NA: solicited NA is multicasted.
\n
"
);
return
;
}
if
(
!
ndisc_parse_options
(
msg
->
opt
,
ndoptlen
,
&
ndopts
))
{
if
(
net_ratelimit
())
printk
(
KERN_WARNING
"ICMP NS: invalid ND option, ignored.
\n
"
);
ND_PRINTK2
(
KERN_WARNING
"ICMPv6 NS: invalid ND option
\n
"
);
return
;
}
if
(
ndopts
.
nd_opts_tgt_lladdr
)
{
lladdr
=
(
u8
*
)(
ndopts
.
nd_opts_tgt_lladdr
+
1
);
lladdrlen
=
ndopts
.
nd_opts_tgt_lladdr
->
nd_opt_len
<<
3
;
if
(
lladdrlen
!=
NDISC_OPT_SPACE
(
dev
->
addr_len
))
{
if
(
net_ratelimit
())
printk
(
KERN_WARNING
"NDISC NA: invalid lladdr length.
\n
"
);
ND_PRINTK2
(
KERN_WARNING
"ICMPv6 NA: invalid link-layer address length
\n
"
);
return
;
}
}
...
...
@@ -854,7 +874,8 @@ static void ndisc_recv_na(struct sk_buff *skb)
about it. It could be misconfiguration, or
an smart proxy agent tries to help us :-)
*/
ND_PRINTK0
(
"%s: someone advertises our address!
\n
"
,
ND_PRINTK1
(
KERN_WARNING
"ICMPv6 NA: someone advertises our address on %s!
\n
"
,
ifp
->
idev
->
dev
->
name
);
in6_ifa_put
(
ifp
);
return
;
...
...
@@ -899,13 +920,13 @@ static void ndisc_router_discovery(struct sk_buff *skb)
optlen
=
(
skb
->
tail
-
skb
->
h
.
raw
)
-
sizeof
(
struct
ra_msg
);
if
(
!
(
ipv6_addr_type
(
&
skb
->
nh
.
ipv6h
->
saddr
)
&
IPV6_ADDR_LINKLOCAL
))
{
if
(
net_ratelimit
())
printk
(
KERN_WARNING
"ICMP RA: source address is not linklocal
\n
"
);
ND_PRINTK2
(
KERN_WARNING
"ICMPv6 RA: source address is not link-local.
\n
"
);
return
;
}
if
(
optlen
<
0
)
{
if
(
net_ratelimit
())
printk
(
KERN_WARNING
"ICMP
RA: packet too short
\n
"
);
ND_PRINTK2
(
KERN_WARNING
"ICMPv6
RA: packet too short
\n
"
);
return
;
}
...
...
@@ -915,7 +936,9 @@ static void ndisc_router_discovery(struct sk_buff *skb)
in6_dev
=
in6_dev_get
(
skb
->
dev
);
if
(
in6_dev
==
NULL
)
{
ND_PRINTK1
(
"RA: can't find in6 device
\n
"
);
ND_PRINTK0
(
KERN_ERR
"ICMPv6 RA: can't find inet6 device for %s.
\n
"
,
skb
->
dev
->
name
);
return
;
}
if
(
in6_dev
->
cnf
.
forwarding
||
!
in6_dev
->
cnf
.
accept_ra
)
{
...
...
@@ -925,9 +948,8 @@ static void ndisc_router_discovery(struct sk_buff *skb)
if
(
!
ndisc_parse_options
(
opt
,
optlen
,
&
ndopts
))
{
in6_dev_put
(
in6_dev
);
if
(
net_ratelimit
())
ND_PRINTK2
(
KERN_WARNING
"ICMP6 RA: invalid ND option, ignored.
\n
"
);
ND_PRINTK2
(
KERN_WARNING
"ICMP6 RA: invalid ND options
\n
"
);
return
;
}
...
...
@@ -960,18 +982,23 @@ static void ndisc_router_discovery(struct sk_buff *skb)
}
if
(
rt
==
NULL
&&
lifetime
)
{
ND_PRINTK2
(
"ndisc_rdisc: adding default router
\n
"
);
ND_PRINTK3
(
KERN_DEBUG
"ICMPv6 RA: adding default router.
\n
"
);
rt
=
rt6_add_dflt_router
(
&
skb
->
nh
.
ipv6h
->
saddr
,
skb
->
dev
);
if
(
rt
==
NULL
)
{
ND_PRINTK1
(
"route_add failed
\n
"
);
ND_PRINTK0
(
KERN_ERR
"ICMPv6 RA: %s() failed to add default route.
\n
"
,
__FUNCTION__
);
in6_dev_put
(
in6_dev
);
return
;
}
neigh
=
rt
->
rt6i_nexthop
;
if
(
neigh
==
NULL
)
{
ND_PRINTK1
(
"nd: add default router: null neighbour
\n
"
);
ND_PRINTK0
(
KERN_ERR
"ICMPv6 RA: %s() got default router without neighbour.
\n
"
,
__FUNCTION__
);
dst_release
(
&
rt
->
u
.
dst
);
in6_dev_put
(
in6_dev
);
return
;
...
...
@@ -1036,9 +1063,8 @@ static void ndisc_router_discovery(struct sk_buff *skb)
lladdr
=
(
u8
*
)((
ndopts
.
nd_opts_src_lladdr
)
+
1
);
lladdrlen
=
ndopts
.
nd_opts_src_lladdr
->
nd_opt_len
<<
3
;
if
(
lladdrlen
!=
NDISC_OPT_SPACE
(
skb
->
dev
->
addr_len
))
{
if
(
net_ratelimit
())
ND_PRINTK2
(
KERN_WARNING
"ICMP6 RA: Invalid lladdr length.
\n
"
);
ND_PRINTK2
(
KERN_WARNING
"ICMPv6 RA: invalid link-layer address length
\n
"
);
goto
out
;
}
}
...
...
@@ -1061,10 +1087,9 @@ static void ndisc_router_discovery(struct sk_buff *skb)
mtu
=
ntohl
(
mtu
);
if
(
mtu
<
IPV6_MIN_MTU
||
mtu
>
skb
->
dev
->
mtu
)
{
if
(
net_ratelimit
())
{
ND_PRINTK0
(
"NDISC: router announcement with mtu = %d
\n
"
,
mtu
);
}
ND_PRINTK2
(
KERN_WARNING
"ICMPv6 RA: invalid mtu: %d
\n
"
,
mtu
);
}
else
if
(
in6_dev
->
cnf
.
mtu6
!=
mtu
)
{
in6_dev
->
cnf
.
mtu6
=
mtu
;
...
...
@@ -1076,9 +1101,8 @@ static void ndisc_router_discovery(struct sk_buff *skb)
}
if
(
ndopts
.
nd_opts_tgt_lladdr
||
ndopts
.
nd_opts_rh
)
{
if
(
net_ratelimit
())
ND_PRINTK0
(
KERN_WARNING
"ICMP6 RA: got invalid option with RA"
);
ND_PRINTK2
(
KERN_WARNING
"ICMPv6 RA: invalid RA options"
);
}
out:
if
(
rt
)
...
...
@@ -1100,8 +1124,8 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
int
lladdrlen
;
if
(
!
(
ipv6_addr_type
(
&
skb
->
nh
.
ipv6h
->
saddr
)
&
IPV6_ADDR_LINKLOCAL
))
{
if
(
net_ratelimit
())
printk
(
KERN_WARNING
"ICMP redirect: source address is not linklocal
\n
"
);
ND_PRINTK2
(
KERN_WARNING
"ICMPv6 Redirect: source address is not link-local.
\n
"
);
return
;
}
...
...
@@ -1109,8 +1133,8 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
optlen
-=
sizeof
(
struct
icmp6hdr
)
+
2
*
sizeof
(
struct
in6_addr
);
if
(
optlen
<
0
)
{
if
(
net_ratelimit
())
printk
(
KERN_WARNING
"ICMP redirect: packet too small
\n
"
);
ND_PRINTK2
(
KERN_WARNING
"ICMPv6 Redirect: packet too short
\n
"
);
return
;
}
...
...
@@ -1119,16 +1143,16 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
dest
=
target
+
1
;
if
(
ipv6_addr_is_multicast
(
dest
))
{
if
(
net_ratelimit
())
printk
(
KERN_WARNING
"ICMP redirect for multicast addr
\n
"
);
ND_PRINTK2
(
KERN_WARNING
"ICMPv6 Redirect: destination address is multicast.
\n
"
);
return
;
}
if
(
ipv6_addr_cmp
(
dest
,
target
)
==
0
)
{
on_link
=
1
;
}
else
if
(
!
(
ipv6_addr_type
(
target
)
&
IPV6_ADDR_LINKLOCAL
))
{
if
(
net_ratelimit
())
printk
(
KERN_WARNING
"ICMP redirect: target address is not linklocal
\n
"
);
ND_PRINTK2
(
KERN_WARNING
"ICMPv6 Redirect: target address is not link-local.
\n
"
);
return
;
}
...
...
@@ -1146,9 +1170,8 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
*/
if
(
!
ndisc_parse_options
((
u8
*
)(
dest
+
1
),
optlen
,
&
ndopts
))
{
if
(
net_ratelimit
())
ND_PRINTK2
(
KERN_WARNING
"ICMP6 Redirect: invalid ND options, rejected.
\n
"
);
ND_PRINTK2
(
KERN_WARNING
"ICMPv6 Redirect: invalid ND options
\n
"
);
in6_dev_put
(
in6_dev
);
return
;
}
...
...
@@ -1156,9 +1179,8 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
lladdr
=
(
u8
*
)(
ndopts
.
nd_opts_tgt_lladdr
+
1
);
lladdrlen
=
ndopts
.
nd_opts_tgt_lladdr
->
nd_opt_len
<<
3
;
if
(
lladdrlen
!=
NDISC_OPT_SPACE
(
skb
->
dev
->
addr_len
))
{
if
(
net_ratelimit
())
ND_PRINTK2
(
KERN_WARNING
"ICMP6 Redirect: invalid lladdr length.
\n
"
);
ND_PRINTK2
(
KERN_WARNING
"ICMPv6 Redirect: invalid link-layer address length
\n
"
);
in6_dev_put
(
in6_dev
);
return
;
}
...
...
@@ -1203,7 +1225,9 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh,
dev
=
skb
->
dev
;
if
(
ipv6_get_lladdr
(
dev
,
&
saddr_buf
))
{
ND_PRINTK1
(
"redirect: no link_local addr for dev
\n
"
);
ND_PRINTK2
(
KERN_WARNING
"ICMPv6 Redirect: no link-local address on %s
\n
"
,
dev
->
name
);
return
;
}
...
...
@@ -1223,7 +1247,8 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh,
rt
=
(
struct
rt6_info
*
)
dst
;
if
(
rt
->
rt6i_flags
&
RTF_GATEWAY
)
{
ND_PRINTK1
(
"ndisc_send_redirect: not a neighbour
\n
"
);
ND_PRINTK2
(
KERN_WARNING
"ICMPv6 Redirect: destination is not a neighbour.
\n
"
);
dst_release
(
dst
);
return
;
}
...
...
@@ -1253,7 +1278,9 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh,
buff
=
sock_alloc_send_skb
(
sk
,
MAX_HEADER
+
len
+
LL_RESERVED_SPACE
(
dev
),
1
,
&
err
);
if
(
buff
==
NULL
)
{
ND_PRINTK1
(
"ndisc_send_redirect: alloc_skb failed
\n
"
);
ND_PRINTK0
(
KERN_ERR
"ICMPv6 Redirect: %s() failed to allocate an skb.
\n
"
,
__FUNCTION__
);
dst_release
(
dst
);
return
;
}
...
...
@@ -1333,16 +1360,16 @@ int ndisc_rcv(struct sk_buff *skb)
__skb_push
(
skb
,
skb
->
data
-
skb
->
h
.
raw
);
if
(
skb
->
nh
.
ipv6h
->
hop_limit
!=
255
)
{
if
(
net_ratelimit
())
printk
(
KERN_WARNING
"ICMP NDISC: fake message with non-255 Hop Limit received: %d
\n
"
,
skb
->
nh
.
ipv6h
->
hop_limit
);
ND_PRINTK2
(
KERN_WARNING
"ICMPv6 NDISC: invalid hop-limit: %d
\n
"
,
skb
->
nh
.
ipv6h
->
hop_limit
);
return
0
;
}
if
(
msg
->
icmph
.
icmp6_code
!=
0
)
{
if
(
net_ratelimit
())
printk
(
KERN_WARNING
"ICMP NDISC: code is not zero
\n
"
);
ND_PRINTK2
(
KERN_WARNING
"ICMPv6 NDISC: invalid ICMPv6 code: %d
\n
"
,
msg
->
icmph
.
icmp6_code
);
return
0
;
}
...
...
@@ -1410,9 +1437,9 @@ int __init ndisc_init(struct net_proto_family *ops)
err
=
sock_create
(
PF_INET6
,
SOCK_RAW
,
IPPROTO_ICMPV6
,
&
ndisc_socket
);
if
(
err
<
0
)
{
printk
(
KERN_ERR
"Failed to initialize the NDISC control socket (err %d).
\n
"
,
err
);
ND_PRINTK0
(
KERN_ERR
"ICMPv6 NDISC: Failed to initialize the control socket (err %d).
\n
"
,
err
);
ndisc_socket
=
NULL
;
/* For safety. */
return
err
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment