Commit 816b9bb2 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo Committed by David S. Miller

[IPV4/IPV6]: Consolidate saddr resetting into inet_reset_saddr().

parent e86747d2
...@@ -230,6 +230,23 @@ static inline void ip_eth_mc_map(u32 addr, char *buf) ...@@ -230,6 +230,23 @@ static inline void ip_eth_mc_map(u32 addr, char *buf)
buf[3]=addr&0x7F; buf[3]=addr&0x7F;
} }
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
#include <linux/ipv6.h>
#endif
static __inline__ void inet_reset_saddr(struct sock *sk)
{
inet_sk(sk)->rcv_saddr = inet_sk(sk)->saddr = 0;
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
if (sk->family == PF_INET6) {
struct ipv6_pinfo *np = inet6_sk(sk);
memset(&np->saddr, 0, sizeof(np->saddr));
memset(&np->rcv_saddr, 0, sizeof(np->rcv_saddr));
}
#endif
}
#endif #endif
extern int ip_call_ra_chain(struct sk_buff *skb); extern int ip_call_ra_chain(struct sk_buff *skb);
......
...@@ -2140,17 +2140,8 @@ int tcp_disconnect(struct sock *sk, int flags) ...@@ -2140,17 +2140,8 @@ int tcp_disconnect(struct sock *sk, int flags)
inet->dport = 0; inet->dport = 0;
if (!(sk->userlocks & SOCK_BINDADDR_LOCK)) { if (!(sk->userlocks & SOCK_BINDADDR_LOCK))
inet->rcv_saddr = inet->saddr = 0; inet_reset_saddr(sk);
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
if (sk->family == PF_INET6) {
struct ipv6_pinfo *np = inet6_sk(sk);
memset(&np->saddr, 0, 16);
memset(&np->rcv_saddr, 0, 16);
}
#endif
}
sk->shutdown = 0; sk->shutdown = 0;
__clear_bit(SOCK_DONE, &sk->flags); __clear_bit(SOCK_DONE, &sk->flags);
......
...@@ -920,17 +920,9 @@ int udp_disconnect(struct sock *sk, int flags) ...@@ -920,17 +920,9 @@ int udp_disconnect(struct sock *sk, int flags)
inet->daddr = 0; inet->daddr = 0;
inet->dport = 0; inet->dport = 0;
sk->bound_dev_if = 0; sk->bound_dev_if = 0;
if (!(sk->userlocks&SOCK_BINDADDR_LOCK)) { if (!(sk->userlocks & SOCK_BINDADDR_LOCK))
inet->rcv_saddr = inet->saddr = 0; inet_reset_saddr(sk);
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
if (sk->family == PF_INET6) {
struct ipv6_pinfo *np = inet6_sk(sk);
memset(&np->saddr, 0, 16);
memset(&np->rcv_saddr, 0, 16);
}
#endif
}
if (!(sk->userlocks&SOCK_BINDPORT_LOCK)) { if (!(sk->userlocks&SOCK_BINDPORT_LOCK)) {
sk->prot->unhash(sk); sk->prot->unhash(sk);
inet->sport = 0; inet->sport = 0;
......
...@@ -355,10 +355,7 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) ...@@ -355,10 +355,7 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
/* Make sure we are allowed to bind here. */ /* Make sure we are allowed to bind here. */
if (sk->prot->get_port(sk, snum) != 0) { if (sk->prot->get_port(sk, snum) != 0) {
inet->rcv_saddr = inet->saddr = 0; inet_reset_saddr(sk);
memset(&np->rcv_saddr, 0, sizeof(struct in6_addr));
memset(&np->saddr, 0, sizeof(struct in6_addr));
release_sock(sk); release_sock(sk);
return -EADDRINUSE; return -EADDRINUSE;
} }
......
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