Commit 09cb105e authored by Jianjun Kong's avatar Jianjun Kong Committed by David S. Miller

net: clean up net/ipv4/ip_sockglue.c tcp_output.c

Signed-off-by: default avatarJianjun Kong <jianjun@zeuux.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a7e9ff73
...@@ -94,7 +94,7 @@ static void ip_cmsg_recv_opts(struct msghdr *msg, struct sk_buff *skb) ...@@ -94,7 +94,7 @@ static void ip_cmsg_recv_opts(struct msghdr *msg, struct sk_buff *skb)
static void ip_cmsg_recv_retopts(struct msghdr *msg, struct sk_buff *skb) static void ip_cmsg_recv_retopts(struct msghdr *msg, struct sk_buff *skb)
{ {
unsigned char optbuf[sizeof(struct ip_options) + 40]; unsigned char optbuf[sizeof(struct ip_options) + 40];
struct ip_options * opt = (struct ip_options*)optbuf; struct ip_options * opt = (struct ip_options *)optbuf;
if (IPCB(skb)->opt.optlen == 0) if (IPCB(skb)->opt.optlen == 0)
return; return;
...@@ -411,7 +411,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, ...@@ -411,7 +411,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
int optname, char __user *optval, int optlen) int optname, char __user *optval, int optlen)
{ {
struct inet_sock *inet = inet_sk(sk); struct inet_sock *inet = inet_sk(sk);
int val=0,err; int val = 0, err;
if (((1<<optname) & ((1<<IP_PKTINFO) | (1<<IP_RECVTTL) | if (((1<<optname) & ((1<<IP_PKTINFO) | (1<<IP_RECVTTL) |
(1<<IP_RECVOPTS) | (1<<IP_RECVTOS) | (1<<IP_RECVOPTS) | (1<<IP_RECVTOS) |
...@@ -437,7 +437,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, ...@@ -437,7 +437,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
/* If optlen==0, it is equivalent to val == 0 */ /* If optlen==0, it is equivalent to val == 0 */
if (ip_mroute_opt(optname)) if (ip_mroute_opt(optname))
return ip_mroute_setsockopt(sk,optname,optval,optlen); return ip_mroute_setsockopt(sk, optname, optval, optlen);
err = 0; err = 0;
lock_sock(sk); lock_sock(sk);
...@@ -549,7 +549,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, ...@@ -549,7 +549,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
goto e_inval; goto e_inval;
if (optlen<1) if (optlen<1)
goto e_inval; goto e_inval;
if (val==-1) if (val == -1)
val = 1; val = 1;
if (val < 0 || val > 255) if (val < 0 || val > 255)
goto e_inval; goto e_inval;
...@@ -573,12 +573,12 @@ static int do_ip_setsockopt(struct sock *sk, int level, ...@@ -573,12 +573,12 @@ static int do_ip_setsockopt(struct sock *sk, int level,
err = -EFAULT; err = -EFAULT;
if (optlen >= sizeof(struct ip_mreqn)) { if (optlen >= sizeof(struct ip_mreqn)) {
if (copy_from_user(&mreq,optval,sizeof(mreq))) if (copy_from_user(&mreq, optval, sizeof(mreq)))
break; break;
} else { } else {
memset(&mreq, 0, sizeof(mreq)); memset(&mreq, 0, sizeof(mreq));
if (optlen >= sizeof(struct in_addr) && if (optlen >= sizeof(struct in_addr) &&
copy_from_user(&mreq.imr_address,optval,sizeof(struct in_addr))) copy_from_user(&mreq.imr_address, optval, sizeof(struct in_addr)))
break; break;
} }
...@@ -626,11 +626,11 @@ static int do_ip_setsockopt(struct sock *sk, int level, ...@@ -626,11 +626,11 @@ static int do_ip_setsockopt(struct sock *sk, int level,
goto e_inval; goto e_inval;
err = -EFAULT; err = -EFAULT;
if (optlen >= sizeof(struct ip_mreqn)) { if (optlen >= sizeof(struct ip_mreqn)) {
if (copy_from_user(&mreq,optval,sizeof(mreq))) if (copy_from_user(&mreq, optval, sizeof(mreq)))
break; break;
} else { } else {
memset(&mreq, 0, sizeof(mreq)); memset(&mreq, 0, sizeof(mreq));
if (copy_from_user(&mreq,optval,sizeof(struct ip_mreq))) if (copy_from_user(&mreq, optval, sizeof(struct ip_mreq)))
break; break;
} }
...@@ -808,7 +808,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, ...@@ -808,7 +808,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
err = -ENOBUFS; err = -ENOBUFS;
break; break;
} }
gsf = kmalloc(optlen,GFP_KERNEL); gsf = kmalloc(optlen, GFP_KERNEL);
if (!gsf) { if (!gsf) {
err = -ENOBUFS; err = -ENOBUFS;
break; break;
...@@ -828,7 +828,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, ...@@ -828,7 +828,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
goto mc_msf_out; goto mc_msf_out;
} }
msize = IP_MSFILTER_SIZE(gsf->gf_numsrc); msize = IP_MSFILTER_SIZE(gsf->gf_numsrc);
msf = kmalloc(msize,GFP_KERNEL); msf = kmalloc(msize, GFP_KERNEL);
if (!msf) { if (!msf) {
err = -ENOBUFS; err = -ENOBUFS;
goto mc_msf_out; goto mc_msf_out;
...@@ -971,9 +971,9 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname, ...@@ -971,9 +971,9 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (ip_mroute_opt(optname)) if (ip_mroute_opt(optname))
return ip_mroute_getsockopt(sk,optname,optval,optlen); return ip_mroute_getsockopt(sk, optname, optval, optlen);
if (get_user(len,optlen)) if (get_user(len, optlen))
return -EFAULT; return -EFAULT;
if (len < 0) if (len < 0)
return -EINVAL; return -EINVAL;
...@@ -984,7 +984,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname, ...@@ -984,7 +984,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
case IP_OPTIONS: case IP_OPTIONS:
{ {
unsigned char optbuf[sizeof(struct ip_options)+40]; unsigned char optbuf[sizeof(struct ip_options)+40];
struct ip_options * opt = (struct ip_options*)optbuf; struct ip_options * opt = (struct ip_options *)optbuf;
opt->optlen = 0; opt->optlen = 0;
if (inet->opt) if (inet->opt)
memcpy(optbuf, inet->opt, memcpy(optbuf, inet->opt,
...@@ -1154,13 +1154,13 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname, ...@@ -1154,13 +1154,13 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
len = 1; len = 1;
if (put_user(len, optlen)) if (put_user(len, optlen))
return -EFAULT; return -EFAULT;
if (copy_to_user(optval,&ucval,1)) if (copy_to_user(optval, &ucval, 1))
return -EFAULT; return -EFAULT;
} else { } else {
len = min_t(unsigned int, sizeof(int), len); len = min_t(unsigned int, sizeof(int), len);
if (put_user(len, optlen)) if (put_user(len, optlen))
return -EFAULT; return -EFAULT;
if (copy_to_user(optval,&val,len)) if (copy_to_user(optval, &val, len))
return -EFAULT; return -EFAULT;
} }
return 0; return 0;
...@@ -1178,7 +1178,7 @@ int ip_getsockopt(struct sock *sk, int level, ...@@ -1178,7 +1178,7 @@ int ip_getsockopt(struct sock *sk, int level,
!ip_mroute_opt(optname)) { !ip_mroute_opt(optname)) {
int len; int len;
if (get_user(len,optlen)) if (get_user(len, optlen))
return -EFAULT; return -EFAULT;
lock_sock(sk); lock_sock(sk);
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
/* People can turn this off for buggy TCP's found in printers etc. */ /* People can turn this off for buggy TCP's found in printers etc. */
int sysctl_tcp_retrans_collapse __read_mostly = 1; int sysctl_tcp_retrans_collapse __read_mostly = 1;
/* People can turn this on to work with those rare, broken TCPs that /* People can turn this on to work with those rare, broken TCPs that
* interpret the window field as a signed quantity. * interpret the window field as a signed quantity.
*/ */
int sysctl_tcp_workaround_signed_windows __read_mostly = 0; int sysctl_tcp_workaround_signed_windows __read_mostly = 0;
...@@ -484,7 +484,7 @@ static unsigned tcp_syn_options(struct sock *sk, struct sk_buff *skb, ...@@ -484,7 +484,7 @@ static unsigned tcp_syn_options(struct sock *sk, struct sk_buff *skb,
} }
if (likely(sysctl_tcp_window_scaling)) { if (likely(sysctl_tcp_window_scaling)) {
opts->ws = tp->rx_opt.rcv_wscale; opts->ws = tp->rx_opt.rcv_wscale;
if(likely(opts->ws)) if (likely(opts->ws))
size += TCPOLEN_WSCALE_ALIGNED; size += TCPOLEN_WSCALE_ALIGNED;
} }
if (likely(sysctl_tcp_sack)) { if (likely(sysctl_tcp_sack)) {
...@@ -526,7 +526,7 @@ static unsigned tcp_synack_options(struct sock *sk, ...@@ -526,7 +526,7 @@ static unsigned tcp_synack_options(struct sock *sk,
if (likely(ireq->wscale_ok)) { if (likely(ireq->wscale_ok)) {
opts->ws = ireq->rcv_wscale; opts->ws = ireq->rcv_wscale;
if(likely(opts->ws)) if (likely(opts->ws))
size += TCPOLEN_WSCALE_ALIGNED; size += TCPOLEN_WSCALE_ALIGNED;
} }
if (likely(doing_ts)) { if (likely(doing_ts)) {
...@@ -1172,7 +1172,7 @@ static int tcp_init_tso_segs(struct sock *sk, struct sk_buff *skb, ...@@ -1172,7 +1172,7 @@ static int tcp_init_tso_segs(struct sock *sk, struct sk_buff *skb,
static inline int tcp_minshall_check(const struct tcp_sock *tp) static inline int tcp_minshall_check(const struct tcp_sock *tp)
{ {
return after(tp->snd_sml,tp->snd_una) && return after(tp->snd_sml, tp->snd_una) &&
!after(tp->snd_sml, tp->snd_nxt); !after(tp->snd_sml, tp->snd_nxt);
} }
......
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