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)
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
extern int ip_call_ra_chain(struct sk_buff *skb);
......
......@@ -2140,17 +2140,8 @@ int tcp_disconnect(struct sock *sk, int flags)
inet->dport = 0;
if (!(sk->userlocks & SOCK_BINDADDR_LOCK)) {
inet->rcv_saddr = inet->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, 16);
memset(&np->rcv_saddr, 0, 16);
}
#endif
}
if (!(sk->userlocks & SOCK_BINDADDR_LOCK))
inet_reset_saddr(sk);
sk->shutdown = 0;
__clear_bit(SOCK_DONE, &sk->flags);
......
......@@ -920,17 +920,9 @@ int udp_disconnect(struct sock *sk, int flags)
inet->daddr = 0;
inet->dport = 0;
sk->bound_dev_if = 0;
if (!(sk->userlocks&SOCK_BINDADDR_LOCK)) {
inet->rcv_saddr = inet->saddr = 0;
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
if (sk->family == PF_INET6) {
struct ipv6_pinfo *np = inet6_sk(sk);
if (!(sk->userlocks & SOCK_BINDADDR_LOCK))
inet_reset_saddr(sk);
memset(&np->saddr, 0, 16);
memset(&np->rcv_saddr, 0, 16);
}
#endif
}
if (!(sk->userlocks&SOCK_BINDPORT_LOCK)) {
sk->prot->unhash(sk);
inet->sport = 0;
......
......@@ -355,10 +355,7 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
/* Make sure we are allowed to bind here. */
if (sk->prot->get_port(sk, snum) != 0) {
inet->rcv_saddr = inet->saddr = 0;
memset(&np->rcv_saddr, 0, sizeof(struct in6_addr));
memset(&np->saddr, 0, sizeof(struct in6_addr));
inet_reset_saddr(sk);
release_sock(sk);
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