Commit 45329e71 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo Committed by David S. Miller

[DCCP] ipv6: cleanups

No changes in the logic were made, just removing trailing whitespaces,
etc.
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@mandriva.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c4d93909
...@@ -82,7 +82,7 @@ static __u32 dccp_v6_init_sequence(struct sock *sk, struct sk_buff *skb) ...@@ -82,7 +82,7 @@ static __u32 dccp_v6_init_sequence(struct sock *sk, struct sk_buff *skb)
skb->nh.ipv6h->saddr.s6_addr32, skb->nh.ipv6h->saddr.s6_addr32,
dh->dccph_dport, dh->dccph_dport,
dh->dccph_sport); dh->dccph_sport);
else
return secure_dccp_sequence_number(skb->nh.iph->daddr, return secure_dccp_sequence_number(skb->nh.iph->daddr,
skb->nh.iph->saddr, skb->nh.iph->saddr,
dh->dccph_dport, dh->dccph_dport,
...@@ -92,7 +92,7 @@ static __u32 dccp_v6_init_sequence(struct sock *sk, struct sk_buff *skb) ...@@ -92,7 +92,7 @@ static __u32 dccp_v6_init_sequence(struct sock *sk, struct sk_buff *skb)
static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
int addr_len) int addr_len)
{ {
struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr; struct sockaddr_in6 *usin = (struct sockaddr_in6 *)uaddr;
struct inet_connection_sock *icsk = inet_csk(sk); struct inet_connection_sock *icsk = inet_csk(sk);
struct inet_sock *inet = inet_sk(sk); struct inet_sock *inet = inet_sk(sk);
struct ipv6_pinfo *np = inet6_sk(sk); struct ipv6_pinfo *np = inet6_sk(sk);
...@@ -125,17 +125,15 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, ...@@ -125,17 +125,15 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
fl6_sock_release(flowlabel); fl6_sock_release(flowlabel);
} }
} }
/* /*
* connect() to INADDR_ANY means loopback (BSD'ism). * connect() to INADDR_ANY means loopback (BSD'ism).
*/ */
if (ipv6_addr_any(&usin->sin6_addr)) if (ipv6_addr_any(&usin->sin6_addr))
usin->sin6_addr.s6_addr[15] = 0x1; usin->sin6_addr.s6_addr[15] = 1;
addr_type = ipv6_addr_type(&usin->sin6_addr); addr_type = ipv6_addr_type(&usin->sin6_addr);
if(addr_type & IPV6_ADDR_MULTICAST) if (addr_type & IPV6_ADDR_MULTICAST)
return -ENETUNREACH; return -ENETUNREACH;
if (addr_type & IPV6_ADDR_LINKLOCAL) { if (addr_type & IPV6_ADDR_LINKLOCAL) {
...@@ -162,7 +160,6 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, ...@@ -162,7 +160,6 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
/* /*
* DCCP over IPv4 * DCCP over IPv4
*/ */
if (addr_type == IPV6_ADDR_MAPPED) { if (addr_type == IPV6_ADDR_MAPPED) {
u32 exthdrlen = icsk->icsk_ext_hdr_len; u32 exthdrlen = icsk->icsk_ext_hdr_len;
struct sockaddr_in sin; struct sockaddr_in sin;
...@@ -180,7 +177,6 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, ...@@ -180,7 +177,6 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
sk->sk_backlog_rcv = dccp_v4_do_rcv; sk->sk_backlog_rcv = dccp_v4_do_rcv;
err = dccp_v4_connect(sk, (struct sockaddr *)&sin, sizeof(sin)); err = dccp_v4_connect(sk, (struct sockaddr *)&sin, sizeof(sin));
if (err) { if (err) {
icsk->icsk_ext_hdr_len = exthdrlen; icsk->icsk_ext_hdr_len = exthdrlen;
icsk->icsk_af_ops = &dccp_ipv6_af_ops; icsk->icsk_af_ops = &dccp_ipv6_af_ops;
...@@ -206,8 +202,9 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, ...@@ -206,8 +202,9 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
fl.fl_ip_dport = usin->sin6_port; fl.fl_ip_dport = usin->sin6_port;
fl.fl_ip_sport = inet->sport; fl.fl_ip_sport = inet->sport;
if (np->opt && np->opt->srcrt) { if (np->opt != NULL && np->opt->srcrt != NULL) {
struct rt0_hdr *rt0 = (struct rt0_hdr *)np->opt->srcrt; const struct rt0_hdr *rt0 = (struct rt0_hdr *)np->opt->srcrt;
ipv6_addr_copy(&final, &fl.fl6_dst); ipv6_addr_copy(&final, &fl.fl6_dst);
ipv6_addr_copy(&fl.fl6_dst, rt0->addr); ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
final_p = &final; final_p = &final;
...@@ -216,10 +213,12 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, ...@@ -216,10 +213,12 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
err = ip6_dst_lookup(sk, &dst, &fl); err = ip6_dst_lookup(sk, &dst, &fl);
if (err) if (err)
goto failure; goto failure;
if (final_p) if (final_p)
ipv6_addr_copy(&fl.fl6_dst, final_p); ipv6_addr_copy(&fl.fl6_dst, final_p);
if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) err = xfrm_lookup(&dst, &fl, sk, 0);
if (err < 0)
goto failure; goto failure;
if (saddr == NULL) { if (saddr == NULL) {
...@@ -234,7 +233,7 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, ...@@ -234,7 +233,7 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
ip6_dst_store(sk, dst, NULL); ip6_dst_store(sk, dst, NULL);
icsk->icsk_ext_hdr_len = 0; icsk->icsk_ext_hdr_len = 0;
if (np->opt) if (np->opt != NULL)
icsk->icsk_ext_hdr_len = (np->opt->opt_flen + icsk->icsk_ext_hdr_len = (np->opt->opt_flen +
np->opt->opt_nflen); np->opt->opt_nflen);
...@@ -308,7 +307,6 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, ...@@ -308,7 +307,6 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
/* icmp should have updated the destination cache entry */ /* icmp should have updated the destination cache entry */
dst = __sk_dst_check(sk, np->dst_cookie); dst = __sk_dst_check(sk, np->dst_cookie);
if (dst == NULL) { if (dst == NULL) {
struct inet_sock *inet = inet_sk(sk); struct inet_sock *inet = inet_sk(sk);
struct flowi fl; struct flowi fl;
...@@ -325,16 +323,17 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, ...@@ -325,16 +323,17 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
fl.fl_ip_dport = inet->dport; fl.fl_ip_dport = inet->dport;
fl.fl_ip_sport = inet->sport; fl.fl_ip_sport = inet->sport;
if ((err = ip6_dst_lookup(sk, &dst, &fl))) { err = ip6_dst_lookup(sk, &dst, &fl);
if (err) {
sk->sk_err_soft = -err; sk->sk_err_soft = -err;
goto out; goto out;
} }
if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) { err = xfrm_lookup(&dst, &fl, sk, 0);
if (err < 0) {
sk->sk_err_soft = -err; sk->sk_err_soft = -err;
goto out; goto out;
} }
} else } else
dst_hold(dst); dst_hold(dst);
...@@ -358,11 +357,12 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, ...@@ -358,11 +357,12 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
req = inet6_csk_search_req(sk, &prev, dh->dccph_dport, req = inet6_csk_search_req(sk, &prev, dh->dccph_dport,
&hdr->daddr, &hdr->saddr, &hdr->daddr, &hdr->saddr,
inet6_iif(skb)); inet6_iif(skb));
if (!req) if (req == NULL)
goto out; goto out;
/* ICMPs are not backlogged, hence we cannot get /*
* an established socket here. * ICMPs are not backlogged, hence we cannot get an established
* socket here.
*/ */
BUG_TRAP(req->sk == NULL); BUG_TRAP(req->sk == NULL);
...@@ -385,7 +385,6 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, ...@@ -385,7 +385,6 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
* (see connect in sock.c) * (see connect in sock.c)
*/ */
sk->sk_error_report(sk); sk->sk_error_report(sk);
dccp_done(sk); dccp_done(sk);
} else } else
sk->sk_err_soft = err; sk->sk_err_soft = err;
...@@ -431,14 +430,16 @@ static int dccp_v6_send_response(struct sock *sk, struct request_sock *req, ...@@ -431,14 +430,16 @@ static int dccp_v6_send_response(struct sock *sk, struct request_sock *req,
ireq6->pktopts) { ireq6->pktopts) {
struct sk_buff *pktopts = ireq6->pktopts; struct sk_buff *pktopts = ireq6->pktopts;
struct inet6_skb_parm *rxopt = IP6CB(pktopts); struct inet6_skb_parm *rxopt = IP6CB(pktopts);
if (rxopt->srcrt) if (rxopt->srcrt)
opt = ipv6_invert_rthdr(sk, opt = ipv6_invert_rthdr(sk,
(struct ipv6_rt_hdr *)(pktopts->nh.raw + (struct ipv6_rt_hdr *)(pktopts->nh.raw +
rxopt->srcrt)); rxopt->srcrt));
} }
if (opt && opt->srcrt) { if (opt != NULL && opt->srcrt != NULL) {
struct rt0_hdr *rt0 = (struct rt0_hdr *)opt->srcrt; const struct rt0_hdr *rt0 = (struct rt0_hdr *)opt->srcrt;
ipv6_addr_copy(&final, &fl.fl6_dst); ipv6_addr_copy(&final, &fl.fl6_dst);
ipv6_addr_copy(&fl.fl6_dst, rt0->addr); ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
final_p = &final; final_p = &final;
...@@ -447,15 +448,19 @@ static int dccp_v6_send_response(struct sock *sk, struct request_sock *req, ...@@ -447,15 +448,19 @@ static int dccp_v6_send_response(struct sock *sk, struct request_sock *req,
err = ip6_dst_lookup(sk, &dst, &fl); err = ip6_dst_lookup(sk, &dst, &fl);
if (err) if (err)
goto done; goto done;
if (final_p) if (final_p)
ipv6_addr_copy(&fl.fl6_dst, final_p); ipv6_addr_copy(&fl.fl6_dst, final_p);
if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0)
err = xfrm_lookup(&dst, &fl, sk, 0);
if (err < 0)
goto done; goto done;
} }
skb = dccp_make_response(sk, dst, req); skb = dccp_make_response(sk, dst, req);
if (skb != NULL) { if (skb != NULL) {
struct dccp_hdr *dh = dccp_hdr(skb); struct dccp_hdr *dh = dccp_hdr(skb);
dh->dccph_checksum = dccp_v6_check(dh, skb->len, dh->dccph_checksum = dccp_v6_check(dh, skb->len,
&ireq6->loc_addr, &ireq6->loc_addr,
&ireq6->rmt_addr, &ireq6->rmt_addr,
...@@ -469,7 +474,7 @@ static int dccp_v6_send_response(struct sock *sk, struct request_sock *req, ...@@ -469,7 +474,7 @@ static int dccp_v6_send_response(struct sock *sk, struct request_sock *req,
} }
done: done:
if (opt && opt != np->opt) if (opt != NULL && opt != np->opt)
sock_kfree_s(sk, opt, opt->tot_len); sock_kfree_s(sk, opt, opt->tot_len);
dst_release(dst); dst_release(dst);
return err; return err;
...@@ -660,7 +665,6 @@ static struct sock *dccp_v6_hnd_req(struct sock *sk,struct sk_buff *skb) ...@@ -660,7 +665,6 @@ static struct sock *dccp_v6_hnd_req(struct sock *sk,struct sk_buff *skb)
&iph->saddr, dh->dccph_sport, &iph->saddr, dh->dccph_sport,
&iph->daddr, ntohs(dh->dccph_dport), &iph->daddr, ntohs(dh->dccph_dport),
inet6_iif(skb)); inet6_iif(skb));
if (nsk != NULL) { if (nsk != NULL) {
if (nsk->sk_state != DCCP_TIME_WAIT) { if (nsk->sk_state != DCCP_TIME_WAIT) {
bh_lock_sock(nsk); bh_lock_sock(nsk);
...@@ -777,7 +781,6 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk, ...@@ -777,7 +781,6 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk,
/* /*
* v6 mapped * v6 mapped
*/ */
newsk = dccp_v4_request_recv_sock(sk, skb, req, dst); newsk = dccp_v4_request_recv_sock(sk, skb, req, dst);
if (newsk == NULL) if (newsk == NULL)
return NULL; return NULL;
...@@ -825,9 +828,9 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk, ...@@ -825,9 +828,9 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk,
if (sk_acceptq_is_full(sk)) if (sk_acceptq_is_full(sk))
goto out_overflow; goto out_overflow;
if (np->rxopt.bits.osrcrt == 2 && if (np->rxopt.bits.osrcrt == 2 && opt == NULL && ireq6->pktopts) {
opt == NULL && ireq6->pktopts) { const struct inet6_skb_parm *rxopt = IP6CB(ireq6->pktopts);
struct inet6_skb_parm *rxopt = IP6CB(ireq6->pktopts);
if (rxopt->srcrt) if (rxopt->srcrt)
opt = ipv6_invert_rthdr(sk, opt = ipv6_invert_rthdr(sk,
(struct ipv6_rt_hdr *)(ireq6->pktopts->nh.raw + (struct ipv6_rt_hdr *)(ireq6->pktopts->nh.raw +
...@@ -841,8 +844,9 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk, ...@@ -841,8 +844,9 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk,
memset(&fl, 0, sizeof(fl)); memset(&fl, 0, sizeof(fl));
fl.proto = IPPROTO_DCCP; fl.proto = IPPROTO_DCCP;
ipv6_addr_copy(&fl.fl6_dst, &ireq6->rmt_addr); ipv6_addr_copy(&fl.fl6_dst, &ireq6->rmt_addr);
if (opt && opt->srcrt) { if (opt != NULL && opt->srcrt != NULL) {
struct rt0_hdr *rt0 = (struct rt0_hdr *) opt->srcrt; const struct rt0_hdr *rt0 = (struct rt0_hdr *)opt->srcrt;
ipv6_addr_copy(&final, &fl.fl6_dst); ipv6_addr_copy(&final, &fl.fl6_dst);
ipv6_addr_copy(&fl.fl6_dst, rt0->addr); ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
final_p = &final; final_p = &final;
...@@ -873,9 +877,8 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk, ...@@ -873,9 +877,8 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk,
*/ */
ip6_dst_store(newsk, dst, NULL); ip6_dst_store(newsk, dst, NULL);
newsk->sk_route_caps = dst->dev->features & newsk->sk_route_caps = dst->dev->features & ~(NETIF_F_IP_CSUM |
~(NETIF_F_IP_CSUM | NETIF_F_TSO); NETIF_F_TSO);
newdp6 = (struct dccp6_sock *)newsk; newdp6 = (struct dccp6_sock *)newsk;
newinet = inet_sk(newsk); newinet = inet_sk(newsk);
newinet->pinet6 = &newdp6->inet6; newinet->pinet6 = &newdp6->inet6;
...@@ -911,20 +914,20 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk, ...@@ -911,20 +914,20 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk,
newnp->mcast_oif = inet6_iif(skb); newnp->mcast_oif = inet6_iif(skb);
newnp->mcast_hops = skb->nh.ipv6h->hop_limit; newnp->mcast_hops = skb->nh.ipv6h->hop_limit;
/* Clone native IPv6 options from listening socket (if any) /*
* Clone native IPv6 options from listening socket (if any)
Yes, keeping reference count would be much more clever, *
but we make one more one thing there: reattach optmem * Yes, keeping reference count would be much more clever, but we make
to newsk. * one more one thing there: reattach optmem to newsk.
*/ */
if (opt) { if (opt != NULL) {
newnp->opt = ipv6_dup_options(newsk, opt); newnp->opt = ipv6_dup_options(newsk, opt);
if (opt != np->opt) if (opt != np->opt)
sock_kfree_s(sk, opt, opt->tot_len); sock_kfree_s(sk, opt, opt->tot_len);
} }
inet_csk(newsk)->icsk_ext_hdr_len = 0; inet_csk(newsk)->icsk_ext_hdr_len = 0;
if (newnp->opt) if (newnp->opt != NULL)
inet_csk(newsk)->icsk_ext_hdr_len = (newnp->opt->opt_nflen + inet_csk(newsk)->icsk_ext_hdr_len = (newnp->opt->opt_nflen +
newnp->opt->opt_flen); newnp->opt->opt_flen);
...@@ -941,7 +944,7 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk, ...@@ -941,7 +944,7 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk,
NET_INC_STATS_BH(LINUX_MIB_LISTENOVERFLOWS); NET_INC_STATS_BH(LINUX_MIB_LISTENOVERFLOWS);
out: out:
NET_INC_STATS_BH(LINUX_MIB_LISTENDROPS); NET_INC_STATS_BH(LINUX_MIB_LISTENDROPS);
if (opt && opt != np->opt) if (opt != NULL && opt != np->opt)
sock_kfree_s(sk, opt, opt->tot_len); sock_kfree_s(sk, opt, opt->tot_len);
dst_release(dst); dst_release(dst);
return NULL; return NULL;
...@@ -975,8 +978,8 @@ static int dccp_v6_do_rcv(struct sock *sk, struct sk_buff *skb) ...@@ -975,8 +978,8 @@ static int dccp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
goto discard; goto discard;
/* /*
* socket locking is here for SMP purposes as backlog rcv * socket locking is here for SMP purposes as backlog rcv is currently
* is currently called with bh processing disabled. * called with bh processing disabled.
*/ */
/* Do Stevens' IPV6_PKTOPTIONS. /* Do Stevens' IPV6_PKTOPTIONS.
...@@ -1003,18 +1006,18 @@ static int dccp_v6_do_rcv(struct sock *sk, struct sk_buff *skb) ...@@ -1003,18 +1006,18 @@ static int dccp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
if (sk->sk_state == DCCP_LISTEN) { if (sk->sk_state == DCCP_LISTEN) {
struct sock *nsk = dccp_v6_hnd_req(sk, skb); struct sock *nsk = dccp_v6_hnd_req(sk, skb);
if (!nsk)
goto discard;
if (nsk == NULL)
goto discard;
/* /*
* Queue it on the new socket if the new socket is active, * Queue it on the new socket if the new socket is active,
* otherwise we just shortcircuit this and continue with * otherwise we just shortcircuit this and continue with
* the new socket.. * the new socket..
*/ */
if(nsk != sk) { if (nsk != sk) {
if (dccp_child_process(sk, nsk, skb)) if (dccp_child_process(sk, nsk, skb))
goto reset; goto reset;
if (opt_skb) if (opt_skb != NULL)
__kfree_skb(opt_skb); __kfree_skb(opt_skb);
return 0; return 0;
} }
...@@ -1027,7 +1030,7 @@ static int dccp_v6_do_rcv(struct sock *sk, struct sk_buff *skb) ...@@ -1027,7 +1030,7 @@ static int dccp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
reset: reset:
dccp_v6_ctl_send_reset(skb); dccp_v6_ctl_send_reset(skb);
discard: discard:
if (opt_skb) if (opt_skb != NULL)
__kfree_skb(opt_skb); __kfree_skb(opt_skb);
kfree_skb(skb); kfree_skb(skb);
return 0; return 0;
...@@ -1075,7 +1078,6 @@ static int dccp_v6_rcv(struct sk_buff **pskb) ...@@ -1075,7 +1078,6 @@ static int dccp_v6_rcv(struct sk_buff **pskb)
* Generate Reset(No Connection) unless P.type == Reset * Generate Reset(No Connection) unless P.type == Reset
* Drop packet and return * Drop packet and return
*/ */
if (sk->sk_state == DCCP_TIME_WAIT) if (sk->sk_state == DCCP_TIME_WAIT)
goto do_time_wait; goto do_time_wait;
......
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