diff options
Diffstat (limited to 'net/ipv4/ping.c')
-rw-r--r-- | net/ipv4/ping.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c index aea5a199c37a..50009c787bcd 100644 --- a/net/ipv4/ping.c +++ b/net/ipv4/ping.c | |||
@@ -20,7 +20,6 @@ | |||
20 | * | 20 | * |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <asm/system.h> | ||
24 | #include <linux/uaccess.h> | 23 | #include <linux/uaccess.h> |
25 | #include <linux/types.h> | 24 | #include <linux/types.h> |
26 | #include <linux/fcntl.h> | 25 | #include <linux/fcntl.h> |
@@ -156,7 +155,7 @@ static struct sock *ping_v4_lookup(struct net *net, __be32 saddr, __be32 daddr, | |||
156 | struct hlist_nulls_node *hnode; | 155 | struct hlist_nulls_node *hnode; |
157 | 156 | ||
158 | pr_debug("try to find: num = %d, daddr = %pI4, dif = %d\n", | 157 | pr_debug("try to find: num = %d, daddr = %pI4, dif = %d\n", |
159 | (int)ident, &daddr, dif); | 158 | (int)ident, &daddr, dif); |
160 | read_lock_bh(&ping_table.lock); | 159 | read_lock_bh(&ping_table.lock); |
161 | 160 | ||
162 | ping_portaddr_for_each_entry(sk, hnode, hslot) { | 161 | ping_portaddr_for_each_entry(sk, hnode, hslot) { |
@@ -229,7 +228,7 @@ static int ping_init_sock(struct sock *sk) | |||
229 | static void ping_close(struct sock *sk, long timeout) | 228 | static void ping_close(struct sock *sk, long timeout) |
230 | { | 229 | { |
231 | pr_debug("ping_close(sk=%p,sk->num=%u)\n", | 230 | pr_debug("ping_close(sk=%p,sk->num=%u)\n", |
232 | inet_sk(sk), inet_sk(sk)->inet_num); | 231 | inet_sk(sk), inet_sk(sk)->inet_num); |
233 | pr_debug("isk->refcnt = %d\n", sk->sk_refcnt.counter); | 232 | pr_debug("isk->refcnt = %d\n", sk->sk_refcnt.counter); |
234 | 233 | ||
235 | sk_common_release(sk); | 234 | sk_common_release(sk); |
@@ -252,7 +251,7 @@ static int ping_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
252 | return -EINVAL; | 251 | return -EINVAL; |
253 | 252 | ||
254 | pr_debug("ping_v4_bind(sk=%p,sa_addr=%08x,sa_port=%d)\n", | 253 | 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)); | 254 | sk, addr->sin_addr.s_addr, ntohs(addr->sin_port)); |
256 | 255 | ||
257 | chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr); | 256 | chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr); |
258 | if (addr->sin_addr.s_addr == htonl(INADDR_ANY)) | 257 | if (addr->sin_addr.s_addr == htonl(INADDR_ANY)) |
@@ -280,9 +279,9 @@ static int ping_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
280 | } | 279 | } |
281 | 280 | ||
282 | pr_debug("after bind(): num = %d, daddr = %pI4, dif = %d\n", | 281 | pr_debug("after bind(): num = %d, daddr = %pI4, dif = %d\n", |
283 | (int)isk->inet_num, | 282 | (int)isk->inet_num, |
284 | &isk->inet_rcv_saddr, | 283 | &isk->inet_rcv_saddr, |
285 | (int)sk->sk_bound_dev_if); | 284 | (int)sk->sk_bound_dev_if); |
286 | 285 | ||
287 | err = 0; | 286 | err = 0; |
288 | if (isk->inet_rcv_saddr) | 287 | if (isk->inet_rcv_saddr) |
@@ -335,7 +334,7 @@ void ping_err(struct sk_buff *skb, u32 info) | |||
335 | return; | 334 | return; |
336 | 335 | ||
337 | pr_debug("ping_err(type=%04x,code=%04x,id=%04x,seq=%04x)\n", type, | 336 | 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)); | 337 | code, ntohs(icmph->un.echo.id), ntohs(icmph->un.echo.sequence)); |
339 | 338 | ||
340 | sk = ping_v4_lookup(net, iph->daddr, iph->saddr, | 339 | sk = ping_v4_lookup(net, iph->daddr, iph->saddr, |
341 | ntohs(icmph->un.echo.id), skb->dev->ifindex); | 340 | ntohs(icmph->un.echo.id), skb->dev->ifindex); |
@@ -556,7 +555,8 @@ static int ping_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, | |||
556 | ipc.oif = inet->mc_index; | 555 | ipc.oif = inet->mc_index; |
557 | if (!saddr) | 556 | if (!saddr) |
558 | saddr = inet->mc_addr; | 557 | saddr = inet->mc_addr; |
559 | } | 558 | } else if (!ipc.oif) |
559 | ipc.oif = inet->uc_index; | ||
560 | 560 | ||
561 | flowi4_init_output(&fl4, ipc.oif, sk->sk_mark, tos, | 561 | flowi4_init_output(&fl4, ipc.oif, sk->sk_mark, tos, |
562 | RT_SCOPE_UNIVERSE, sk->sk_protocol, | 562 | RT_SCOPE_UNIVERSE, sk->sk_protocol, |
@@ -630,6 +630,7 @@ static int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, | |||
630 | 630 | ||
631 | pr_debug("ping_recvmsg(sk=%p,sk->num=%u)\n", isk, isk->inet_num); | 631 | pr_debug("ping_recvmsg(sk=%p,sk->num=%u)\n", isk, isk->inet_num); |
632 | 632 | ||
633 | err = -EOPNOTSUPP; | ||
633 | if (flags & MSG_OOB) | 634 | if (flags & MSG_OOB) |
634 | goto out; | 635 | goto out; |
635 | 636 | ||
@@ -677,7 +678,7 @@ out: | |||
677 | static int ping_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) | 678 | static int ping_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) |
678 | { | 679 | { |
679 | pr_debug("ping_queue_rcv_skb(sk=%p,sk->num=%d,skb=%p)\n", | 680 | pr_debug("ping_queue_rcv_skb(sk=%p,sk->num=%d,skb=%p)\n", |
680 | inet_sk(sk), inet_sk(sk)->inet_num, skb); | 681 | inet_sk(sk), inet_sk(sk)->inet_num, skb); |
681 | if (sock_queue_rcv_skb(sk, skb) < 0) { | 682 | if (sock_queue_rcv_skb(sk, skb) < 0) { |
682 | kfree_skb(skb); | 683 | kfree_skb(skb); |
683 | pr_debug("ping_queue_rcv_skb -> failed\n"); | 684 | pr_debug("ping_queue_rcv_skb -> failed\n"); |
@@ -703,7 +704,7 @@ void ping_rcv(struct sk_buff *skb) | |||
703 | /* We assume the packet has already been checked by icmp_rcv */ | 704 | /* We assume the packet has already been checked by icmp_rcv */ |
704 | 705 | ||
705 | pr_debug("ping_rcv(skb=%p,id=%04x,seq=%04x)\n", | 706 | pr_debug("ping_rcv(skb=%p,id=%04x,seq=%04x)\n", |
706 | skb, ntohs(icmph->un.echo.id), ntohs(icmph->un.echo.sequence)); | 707 | skb, ntohs(icmph->un.echo.id), ntohs(icmph->un.echo.sequence)); |
707 | 708 | ||
708 | /* Push ICMP header back */ | 709 | /* Push ICMP header back */ |
709 | skb_push(skb, skb->data - (u8 *)icmph); | 710 | skb_push(skb, skb->data - (u8 *)icmph); |