Commit 132adf54 authored by Stephen Hemminger's avatar Stephen Hemminger Committed by David S. Miller

[IPV4]: cleanup

Add whitespace around keywords.
Signed-off-by: default avatarStephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1ac58ee3
...@@ -1339,7 +1339,7 @@ static int __init inet_init(void) ...@@ -1339,7 +1339,7 @@ static int __init inet_init(void)
* Initialise per-cpu ipv4 mibs * Initialise per-cpu ipv4 mibs
*/ */
if(init_ipv4_mibs()) if (init_ipv4_mibs())
printk(KERN_CRIT "inet_init: Cannot init ipv4 mibs\n"); ; printk(KERN_CRIT "inet_init: Cannot init ipv4 mibs\n"); ;
ipv4_proc_init(); ipv4_proc_init();
......
...@@ -1178,7 +1178,7 @@ int arp_ioctl(unsigned int cmd, void __user *arg) ...@@ -1178,7 +1178,7 @@ int arp_ioctl(unsigned int cmd, void __user *arg)
goto out; goto out;
} }
switch(cmd) { switch (cmd) {
case SIOCDARP: case SIOCDARP:
err = arp_req_delete(&r, dev); err = arp_req_delete(&r, dev);
break; break;
......
...@@ -1174,7 +1174,7 @@ static int cipso_v4_map_cat_rng_ntoh(const struct cipso_v4_doi *doi_def, ...@@ -1174,7 +1174,7 @@ static int cipso_v4_map_cat_rng_ntoh(const struct cipso_v4_doi *doi_def,
u16 cat_low; u16 cat_low;
u16 cat_high; u16 cat_high;
for(net_iter = 0; net_iter < net_cat_len; net_iter += 4) { for (net_iter = 0; net_iter < net_cat_len; net_iter += 4) {
cat_high = ntohs(*((__be16 *)&net_cat[net_iter])); cat_high = ntohs(*((__be16 *)&net_cat[net_iter]));
if ((net_iter + 4) <= net_cat_len) if ((net_iter + 4) <= net_cat_len)
cat_low = ntohs(*((__be16 *)&net_cat[net_iter + 2])); cat_low = ntohs(*((__be16 *)&net_cat[net_iter + 2]));
......
...@@ -633,7 +633,7 @@ int devinet_ioctl(unsigned int cmd, void __user *arg) ...@@ -633,7 +633,7 @@ int devinet_ioctl(unsigned int cmd, void __user *arg)
dev_load(ifr.ifr_name); dev_load(ifr.ifr_name);
#endif #endif
switch(cmd) { switch (cmd) {
case SIOCGIFADDR: /* Get interface address */ case SIOCGIFADDR: /* Get interface address */
case SIOCGIFBRDADDR: /* Get the broadcast address */ case SIOCGIFBRDADDR: /* Get the broadcast address */
case SIOCGIFDSTADDR: /* Get the destination address */ case SIOCGIFDSTADDR: /* Get the destination address */
...@@ -708,7 +708,7 @@ int devinet_ioctl(unsigned int cmd, void __user *arg) ...@@ -708,7 +708,7 @@ int devinet_ioctl(unsigned int cmd, void __user *arg)
if (!ifa && cmd != SIOCSIFADDR && cmd != SIOCSIFFLAGS) if (!ifa && cmd != SIOCSIFADDR && cmd != SIOCSIFFLAGS)
goto done; goto done;
switch(cmd) { switch (cmd) {
case SIOCGIFADDR: /* Get interface address */ case SIOCGIFADDR: /* Get interface address */
sin->sin_addr.s_addr = ifa->ifa_local; sin->sin_addr.s_addr = ifa->ifa_local;
goto rarok; goto rarok;
......
...@@ -350,11 +350,10 @@ static void __tnode_free_rcu(struct rcu_head *head) ...@@ -350,11 +350,10 @@ static void __tnode_free_rcu(struct rcu_head *head)
static inline void tnode_free(struct tnode *tn) static inline void tnode_free(struct tnode *tn)
{ {
if(IS_LEAF(tn)) { if (IS_LEAF(tn)) {
struct leaf *l = (struct leaf *) tn; struct leaf *l = (struct leaf *) tn;
call_rcu_bh(&l->rcu, __leaf_free_rcu); call_rcu_bh(&l->rcu, __leaf_free_rcu);
} } else
else
call_rcu(&tn->rcu, __tnode_free_rcu); call_rcu(&tn->rcu, __tnode_free_rcu);
} }
...@@ -553,7 +552,7 @@ static struct node *resize(struct trie *t, struct tnode *tn) ...@@ -553,7 +552,7 @@ static struct node *resize(struct trie *t, struct tnode *tn)
/* Keep root node larger */ /* Keep root node larger */
if(!tn->parent) if (!tn->parent)
inflate_threshold_use = inflate_threshold_root; inflate_threshold_use = inflate_threshold_root;
else else
inflate_threshold_use = inflate_threshold; inflate_threshold_use = inflate_threshold;
...@@ -584,7 +583,7 @@ static struct node *resize(struct trie *t, struct tnode *tn) ...@@ -584,7 +583,7 @@ static struct node *resize(struct trie *t, struct tnode *tn)
/* Keep root node larger */ /* Keep root node larger */
if(!tn->parent) if (!tn->parent)
halve_threshold_use = halve_threshold_root; halve_threshold_use = halve_threshold_root;
else else
halve_threshold_use = halve_threshold; halve_threshold_use = halve_threshold;
...@@ -2039,12 +2038,12 @@ static struct node *fib_trie_get_first(struct fib_trie_iter *iter, ...@@ -2039,12 +2038,12 @@ static struct node *fib_trie_get_first(struct fib_trie_iter *iter,
{ {
struct node *n ; struct node *n ;
if(!t) if (!t)
return NULL; return NULL;
n = rcu_dereference(t->trie); n = rcu_dereference(t->trie);
if(!iter) if (!iter)
return NULL; return NULL;
if (n) { if (n) {
...@@ -2084,7 +2083,7 @@ static void trie_collect_stats(struct trie *t, struct trie_stat *s) ...@@ -2084,7 +2083,7 @@ static void trie_collect_stats(struct trie *t, struct trie_stat *s)
int i; int i;
s->tnodes++; s->tnodes++;
if(tn->bits < MAX_STAT_DEPTH) if (tn->bits < MAX_STAT_DEPTH)
s->nodesizes[tn->bits]++; s->nodesizes[tn->bits]++;
for (i = 0; i < (1<<tn->bits); i++) for (i = 0; i < (1<<tn->bits); i++)
...@@ -2250,7 +2249,7 @@ static inline const char *rtn_scope(enum rt_scope_t s) ...@@ -2250,7 +2249,7 @@ static inline const char *rtn_scope(enum rt_scope_t s)
{ {
static char buf[32]; static char buf[32];
switch(s) { switch (s) {
case RT_SCOPE_UNIVERSE: return "universe"; case RT_SCOPE_UNIVERSE: return "universe";
case RT_SCOPE_SITE: return "site"; case RT_SCOPE_SITE: return "site";
case RT_SCOPE_LINK: return "link"; case RT_SCOPE_LINK: return "link";
......
...@@ -184,7 +184,7 @@ static __inline__ struct ipq *frag_alloc_queue(void) ...@@ -184,7 +184,7 @@ static __inline__ struct ipq *frag_alloc_queue(void)
{ {
struct ipq *qp = kmalloc(sizeof(struct ipq), GFP_ATOMIC); struct ipq *qp = kmalloc(sizeof(struct ipq), GFP_ATOMIC);
if(!qp) if (!qp)
return NULL; return NULL;
atomic_add(sizeof(struct ipq), &ip_frag_mem); atomic_add(sizeof(struct ipq), &ip_frag_mem);
return qp; return qp;
...@@ -321,11 +321,11 @@ static struct ipq *ip_frag_intern(struct ipq *qp_in) ...@@ -321,11 +321,11 @@ static struct ipq *ip_frag_intern(struct ipq *qp_in)
* promoted read lock to write lock. * promoted read lock to write lock.
*/ */
hlist_for_each_entry(qp, n, &ipq_hash[hash], list) { hlist_for_each_entry(qp, n, &ipq_hash[hash], list) {
if(qp->id == qp_in->id && if (qp->id == qp_in->id &&
qp->saddr == qp_in->saddr && qp->saddr == qp_in->saddr &&
qp->daddr == qp_in->daddr && qp->daddr == qp_in->daddr &&
qp->protocol == qp_in->protocol && qp->protocol == qp_in->protocol &&
qp->user == qp_in->user) { qp->user == qp_in->user) {
atomic_inc(&qp->refcnt); atomic_inc(&qp->refcnt);
write_unlock(&ipfrag_lock); write_unlock(&ipfrag_lock);
qp_in->last_in |= COMPLETE; qp_in->last_in |= COMPLETE;
...@@ -398,11 +398,11 @@ static inline struct ipq *ip_find(struct iphdr *iph, u32 user) ...@@ -398,11 +398,11 @@ static inline struct ipq *ip_find(struct iphdr *iph, u32 user)
read_lock(&ipfrag_lock); read_lock(&ipfrag_lock);
hash = ipqhashfn(id, saddr, daddr, protocol); hash = ipqhashfn(id, saddr, daddr, protocol);
hlist_for_each_entry(qp, n, &ipq_hash[hash], list) { hlist_for_each_entry(qp, n, &ipq_hash[hash], list) {
if(qp->id == id && if (qp->id == id &&
qp->saddr == saddr && qp->saddr == saddr &&
qp->daddr == daddr && qp->daddr == daddr &&
qp->protocol == protocol && qp->protocol == protocol &&
qp->user == user) { qp->user == user) {
atomic_inc(&qp->refcnt); atomic_inc(&qp->refcnt);
read_unlock(&ipfrag_lock); read_unlock(&ipfrag_lock);
return qp; return qp;
...@@ -524,7 +524,7 @@ static void ip_frag_queue(struct ipq *qp, struct sk_buff *skb) ...@@ -524,7 +524,7 @@ static void ip_frag_queue(struct ipq *qp, struct sk_buff *skb)
* this fragment, right? * this fragment, right?
*/ */
prev = NULL; prev = NULL;
for(next = qp->fragments; next != NULL; next = next->next) { for (next = qp->fragments; next != NULL; next = next->next) {
if (FRAG_CB(next)->offset >= offset) if (FRAG_CB(next)->offset >= offset)
break; /* bingo! */ break; /* bingo! */
prev = next; prev = next;
...@@ -627,7 +627,7 @@ static struct sk_buff *ip_frag_reasm(struct ipq *qp, struct net_device *dev) ...@@ -627,7 +627,7 @@ static struct sk_buff *ip_frag_reasm(struct ipq *qp, struct net_device *dev)
ihlen = head->nh.iph->ihl*4; ihlen = head->nh.iph->ihl*4;
len = ihlen + qp->len; len = ihlen + qp->len;
if(len > 65535) if (len > 65535)
goto out_oversize; goto out_oversize;
/* Head of list must not be cloned. */ /* Head of list must not be cloned. */
......
...@@ -566,7 +566,7 @@ slow_path: ...@@ -566,7 +566,7 @@ slow_path:
* Keep copying data until we run out. * Keep copying data until we run out.
*/ */
while(left > 0) { while (left > 0) {
len = left; len = left;
/* IF: it doesn't fit, use 'mtu' - the data space left */ /* IF: it doesn't fit, use 'mtu' - the data space left */
if (len > mtu) if (len > mtu)
......
...@@ -403,20 +403,20 @@ out: ...@@ -403,20 +403,20 @@ out:
*/ */
static int do_ip_setsockopt(struct sock *sk, int level, 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) |
(1<<IP_RETOPTS) | (1<<IP_TOS) | (1<<IP_RETOPTS) | (1<<IP_TOS) |
(1<<IP_TTL) | (1<<IP_HDRINCL) | (1<<IP_TTL) | (1<<IP_HDRINCL) |
(1<<IP_MTU_DISCOVER) | (1<<IP_RECVERR) | (1<<IP_MTU_DISCOVER) | (1<<IP_RECVERR) |
(1<<IP_ROUTER_ALERT) | (1<<IP_FREEBIND) | (1<<IP_ROUTER_ALERT) | (1<<IP_FREEBIND) |
(1<<IP_PASSSEC))) || (1<<IP_PASSSEC))) ||
optname == IP_MULTICAST_TTL || optname == IP_MULTICAST_TTL ||
optname == IP_MULTICAST_LOOP) { optname == IP_MULTICAST_LOOP) {
if (optlen >= sizeof(int)) { if (optlen >= sizeof(int)) {
if (get_user(val, (int __user *) optval)) if (get_user(val, (int __user *) optval))
return -EFAULT; return -EFAULT;
...@@ -440,444 +440,444 @@ static int do_ip_setsockopt(struct sock *sk, int level, ...@@ -440,444 +440,444 @@ static int do_ip_setsockopt(struct sock *sk, int level,
lock_sock(sk); lock_sock(sk);
switch (optname) { switch (optname) {
case IP_OPTIONS: case IP_OPTIONS:
{ {
struct ip_options * opt = NULL; struct ip_options * opt = NULL;
if (optlen > 40 || optlen < 0) if (optlen > 40 || optlen < 0)
goto e_inval; goto e_inval;
err = ip_options_get_from_user(&opt, optval, optlen); err = ip_options_get_from_user(&opt, optval, optlen);
if (err) if (err)
break; break;
if (inet->is_icsk) { if (inet->is_icsk) {
struct inet_connection_sock *icsk = inet_csk(sk); struct inet_connection_sock *icsk = inet_csk(sk);
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
if (sk->sk_family == PF_INET || if (sk->sk_family == PF_INET ||
(!((1 << sk->sk_state) & (!((1 << sk->sk_state) &
(TCPF_LISTEN | TCPF_CLOSE)) && (TCPF_LISTEN | TCPF_CLOSE)) &&
inet->daddr != LOOPBACK4_IPV6)) { inet->daddr != LOOPBACK4_IPV6)) {
#endif #endif
if (inet->opt) if (inet->opt)
icsk->icsk_ext_hdr_len -= inet->opt->optlen; icsk->icsk_ext_hdr_len -= inet->opt->optlen;
if (opt) if (opt)
icsk->icsk_ext_hdr_len += opt->optlen; icsk->icsk_ext_hdr_len += opt->optlen;
icsk->icsk_sync_mss(sk, icsk->icsk_pmtu_cookie); icsk->icsk_sync_mss(sk, icsk->icsk_pmtu_cookie);
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
}
#endif
} }
opt = xchg(&inet->opt, opt); #endif
kfree(opt);
break;
} }
case IP_PKTINFO: opt = xchg(&inet->opt, opt);
if (val) kfree(opt);
inet->cmsg_flags |= IP_CMSG_PKTINFO; break;
else }
inet->cmsg_flags &= ~IP_CMSG_PKTINFO; case IP_PKTINFO:
break; if (val)
case IP_RECVTTL: inet->cmsg_flags |= IP_CMSG_PKTINFO;
if (val) else
inet->cmsg_flags |= IP_CMSG_TTL; inet->cmsg_flags &= ~IP_CMSG_PKTINFO;
else break;
inet->cmsg_flags &= ~IP_CMSG_TTL; case IP_RECVTTL:
break; if (val)
case IP_RECVTOS: inet->cmsg_flags |= IP_CMSG_TTL;
if (val) else
inet->cmsg_flags |= IP_CMSG_TOS; inet->cmsg_flags &= ~IP_CMSG_TTL;
else break;
inet->cmsg_flags &= ~IP_CMSG_TOS; case IP_RECVTOS:
break; if (val)
case IP_RECVOPTS: inet->cmsg_flags |= IP_CMSG_TOS;
if (val) else
inet->cmsg_flags |= IP_CMSG_RECVOPTS; inet->cmsg_flags &= ~IP_CMSG_TOS;
else break;
inet->cmsg_flags &= ~IP_CMSG_RECVOPTS; case IP_RECVOPTS:
break; if (val)
case IP_RETOPTS: inet->cmsg_flags |= IP_CMSG_RECVOPTS;
if (val) else
inet->cmsg_flags |= IP_CMSG_RETOPTS; inet->cmsg_flags &= ~IP_CMSG_RECVOPTS;
else break;
inet->cmsg_flags &= ~IP_CMSG_RETOPTS; case IP_RETOPTS:
if (val)
inet->cmsg_flags |= IP_CMSG_RETOPTS;
else
inet->cmsg_flags &= ~IP_CMSG_RETOPTS;
break;
case IP_PASSSEC:
if (val)
inet->cmsg_flags |= IP_CMSG_PASSSEC;
else
inet->cmsg_flags &= ~IP_CMSG_PASSSEC;
break;
case IP_TOS: /* This sets both TOS and Precedence */
if (sk->sk_type == SOCK_STREAM) {
val &= ~3;
val |= inet->tos & 3;
}
if (IPTOS_PREC(val) >= IPTOS_PREC_CRITIC_ECP &&
!capable(CAP_NET_ADMIN)) {
err = -EPERM;
break; break;
case IP_PASSSEC: }
if (val) if (inet->tos != val) {
inet->cmsg_flags |= IP_CMSG_PASSSEC; inet->tos = val;
else sk->sk_priority = rt_tos2priority(val);
inet->cmsg_flags &= ~IP_CMSG_PASSSEC; sk_dst_reset(sk);
}
break;
case IP_TTL:
if (optlen<1)
goto e_inval;
if (val != -1 && (val < 1 || val>255))
goto e_inval;
inet->uc_ttl = val;
break;
case IP_HDRINCL:
if (sk->sk_type != SOCK_RAW) {
err = -ENOPROTOOPT;
break; break;
case IP_TOS: /* This sets both TOS and Precedence */ }
if (sk->sk_type == SOCK_STREAM) { inet->hdrincl = val ? 1 : 0;
val &= ~3; break;
val |= inet->tos & 3; case IP_MTU_DISCOVER:
} if (val<0 || val>2)
if (IPTOS_PREC(val) >= IPTOS_PREC_CRITIC_ECP && goto e_inval;
!capable(CAP_NET_ADMIN)) { inet->pmtudisc = val;
err = -EPERM; break;
case IP_RECVERR:
inet->recverr = !!val;
if (!val)
skb_queue_purge(&sk->sk_error_queue);
break;
case IP_MULTICAST_TTL:
if (sk->sk_type == SOCK_STREAM)
goto e_inval;
if (optlen<1)
goto e_inval;
if (val==-1)
val = 1;
if (val < 0 || val > 255)
goto e_inval;
inet->mc_ttl = val;
break;
case IP_MULTICAST_LOOP:
if (optlen<1)
goto e_inval;
inet->mc_loop = !!val;
break;
case IP_MULTICAST_IF:
{
struct ip_mreqn mreq;
struct net_device *dev = NULL;
if (sk->sk_type == SOCK_STREAM)
goto e_inval;
/*
* Check the arguments are allowable
*/
err = -EFAULT;
if (optlen >= sizeof(struct ip_mreqn)) {
if (copy_from_user(&mreq,optval,sizeof(mreq)))
break; break;
} } else {
if (inet->tos != val) { memset(&mreq, 0, sizeof(mreq));
inet->tos = val; if (optlen >= sizeof(struct in_addr) &&
sk->sk_priority = rt_tos2priority(val); copy_from_user(&mreq.imr_address,optval,sizeof(struct in_addr)))
sk_dst_reset(sk); break;
} }
break;
case IP_TTL: if (!mreq.imr_ifindex) {
if (optlen<1) if (mreq.imr_address.s_addr == INADDR_ANY) {
goto e_inval; inet->mc_index = 0;
if (val != -1 && (val < 1 || val>255)) inet->mc_addr = 0;
goto e_inval; err = 0;
inet->uc_ttl = val;
break;
case IP_HDRINCL:
if (sk->sk_type != SOCK_RAW) {
err = -ENOPROTOOPT;
break; break;
} }
inet->hdrincl = val ? 1 : 0; dev = ip_dev_find(mreq.imr_address.s_addr);
break; if (dev) {
case IP_MTU_DISCOVER: mreq.imr_ifindex = dev->ifindex;
if (val<0 || val>2) dev_put(dev);
goto e_inval; }
inet->pmtudisc = val; } else
break; dev = __dev_get_by_index(mreq.imr_ifindex);
case IP_RECVERR:
inet->recverr = !!val;
if (!val)
skb_queue_purge(&sk->sk_error_queue);
break;
case IP_MULTICAST_TTL:
if (sk->sk_type == SOCK_STREAM)
goto e_inval;
if (optlen<1)
goto e_inval;
if (val==-1)
val = 1;
if (val < 0 || val > 255)
goto e_inval;
inet->mc_ttl = val;
break;
case IP_MULTICAST_LOOP:
if (optlen<1)
goto e_inval;
inet->mc_loop = !!val;
break;
case IP_MULTICAST_IF:
{
struct ip_mreqn mreq;
struct net_device *dev = NULL;
if (sk->sk_type == SOCK_STREAM)
goto e_inval;
/*
* Check the arguments are allowable
*/
err = -EFAULT; err = -EADDRNOTAVAIL;
if (optlen >= sizeof(struct ip_mreqn)) { if (!dev)
if (copy_from_user(&mreq,optval,sizeof(mreq))) break;
break;
} else { err = -EINVAL;
memset(&mreq, 0, sizeof(mreq)); if (sk->sk_bound_dev_if &&
if (optlen >= sizeof(struct in_addr) && mreq.imr_ifindex != sk->sk_bound_dev_if)
copy_from_user(&mreq.imr_address,optval,sizeof(struct in_addr))) break;
break;
}
if (!mreq.imr_ifindex) { inet->mc_index = mreq.imr_ifindex;
if (mreq.imr_address.s_addr == INADDR_ANY) { inet->mc_addr = mreq.imr_address.s_addr;
inet->mc_index = 0; err = 0;
inet->mc_addr = 0; break;
err = 0; }
break;
}
dev = ip_dev_find(mreq.imr_address.s_addr);
if (dev) {
mreq.imr_ifindex = dev->ifindex;
dev_put(dev);
}
} else
dev = __dev_get_by_index(mreq.imr_ifindex);
case IP_ADD_MEMBERSHIP:
case IP_DROP_MEMBERSHIP:
{
struct ip_mreqn mreq;
err = -EADDRNOTAVAIL; if (optlen < sizeof(struct ip_mreq))
if (!dev) goto e_inval;
err = -EFAULT;
if (optlen >= sizeof(struct ip_mreqn)) {
if (copy_from_user(&mreq,optval,sizeof(mreq)))
break; break;
} else {
err = -EINVAL; memset(&mreq, 0, sizeof(mreq));
if (sk->sk_bound_dev_if && if (copy_from_user(&mreq,optval,sizeof(struct ip_mreq)))
mreq.imr_ifindex != sk->sk_bound_dev_if)
break; break;
}
inet->mc_index = mreq.imr_ifindex; if (optname == IP_ADD_MEMBERSHIP)
inet->mc_addr = mreq.imr_address.s_addr; err = ip_mc_join_group(sk, &mreq);
err = 0; else
err = ip_mc_leave_group(sk, &mreq);
break;
}
case IP_MSFILTER:
{
extern int sysctl_igmp_max_msf;
struct ip_msfilter *msf;
if (optlen < IP_MSFILTER_SIZE(0))
goto e_inval;
if (optlen > sysctl_optmem_max) {
err = -ENOBUFS;
break; break;
} }
msf = kmalloc(optlen, GFP_KERNEL);
if (msf == 0) {
err = -ENOBUFS;
break;
}
err = -EFAULT;
if (copy_from_user(msf, optval, optlen)) {
kfree(msf);
break;
}
/* numsrc >= (1G-4) overflow in 32 bits */
if (msf->imsf_numsrc >= 0x3ffffffcU ||
msf->imsf_numsrc > sysctl_igmp_max_msf) {
kfree(msf);
err = -ENOBUFS;
break;
}
if (IP_MSFILTER_SIZE(msf->imsf_numsrc) > optlen) {
kfree(msf);
err = -EINVAL;
break;
}
err = ip_mc_msfilter(sk, msf, 0);
kfree(msf);
break;
}
case IP_BLOCK_SOURCE:
case IP_UNBLOCK_SOURCE:
case IP_ADD_SOURCE_MEMBERSHIP:
case IP_DROP_SOURCE_MEMBERSHIP:
{
struct ip_mreq_source mreqs;
int omode, add;
case IP_ADD_MEMBERSHIP: if (optlen != sizeof(struct ip_mreq_source))
case IP_DROP_MEMBERSHIP: goto e_inval;
{ if (copy_from_user(&mreqs, optval, sizeof(mreqs))) {
struct ip_mreqn mreq;
if (optlen < sizeof(struct ip_mreq))
goto e_inval;
err = -EFAULT; err = -EFAULT;
if (optlen >= sizeof(struct ip_mreqn)) {
if(copy_from_user(&mreq,optval,sizeof(mreq)))
break;
} else {
memset(&mreq, 0, sizeof(mreq));
if (copy_from_user(&mreq,optval,sizeof(struct ip_mreq)))
break;
}
if (optname == IP_ADD_MEMBERSHIP)
err = ip_mc_join_group(sk, &mreq);
else
err = ip_mc_leave_group(sk, &mreq);
break; break;
} }
case IP_MSFILTER: if (optname == IP_BLOCK_SOURCE) {
{ omode = MCAST_EXCLUDE;
extern int sysctl_igmp_max_msf; add = 1;
struct ip_msfilter *msf; } else if (optname == IP_UNBLOCK_SOURCE) {
omode = MCAST_EXCLUDE;
add = 0;
} else if (optname == IP_ADD_SOURCE_MEMBERSHIP) {
struct ip_mreqn mreq;
if (optlen < IP_MSFILTER_SIZE(0)) mreq.imr_multiaddr.s_addr = mreqs.imr_multiaddr;
goto e_inval; mreq.imr_address.s_addr = mreqs.imr_interface;
if (optlen > sysctl_optmem_max) { mreq.imr_ifindex = 0;
err = -ENOBUFS; err = ip_mc_join_group(sk, &mreq);
break; if (err && err != -EADDRINUSE)
}
msf = kmalloc(optlen, GFP_KERNEL);
if (msf == 0) {
err = -ENOBUFS;
break; break;
} omode = MCAST_INCLUDE;
add = 1;
} else /* IP_DROP_SOURCE_MEMBERSHIP */ {
omode = MCAST_INCLUDE;
add = 0;
}
err = ip_mc_source(add, omode, sk, &mreqs, 0);
break;
}
case MCAST_JOIN_GROUP:
case MCAST_LEAVE_GROUP:
{
struct group_req greq;
struct sockaddr_in *psin;
struct ip_mreqn mreq;
if (optlen < sizeof(struct group_req))
goto e_inval;
err = -EFAULT;
if (copy_from_user(&greq, optval, sizeof(greq)))
break;
psin = (struct sockaddr_in *)&greq.gr_group;
if (psin->sin_family != AF_INET)
goto e_inval;
memset(&mreq, 0, sizeof(mreq));
mreq.imr_multiaddr = psin->sin_addr;
mreq.imr_ifindex = greq.gr_interface;
if (optname == MCAST_JOIN_GROUP)
err = ip_mc_join_group(sk, &mreq);
else
err = ip_mc_leave_group(sk, &mreq);
break;
}
case MCAST_JOIN_SOURCE_GROUP:
case MCAST_LEAVE_SOURCE_GROUP:
case MCAST_BLOCK_SOURCE:
case MCAST_UNBLOCK_SOURCE:
{
struct group_source_req greqs;
struct ip_mreq_source mreqs;
struct sockaddr_in *psin;
int omode, add;
if (optlen != sizeof(struct group_source_req))
goto e_inval;
if (copy_from_user(&greqs, optval, sizeof(greqs))) {
err = -EFAULT; err = -EFAULT;
if (copy_from_user(msf, optval, optlen)) {
kfree(msf);
break;
}
/* numsrc >= (1G-4) overflow in 32 bits */
if (msf->imsf_numsrc >= 0x3ffffffcU ||
msf->imsf_numsrc > sysctl_igmp_max_msf) {
kfree(msf);
err = -ENOBUFS;
break;
}
if (IP_MSFILTER_SIZE(msf->imsf_numsrc) > optlen) {
kfree(msf);
err = -EINVAL;
break;
}
err = ip_mc_msfilter(sk, msf, 0);
kfree(msf);
break; break;
} }
case IP_BLOCK_SOURCE: if (greqs.gsr_group.ss_family != AF_INET ||
case IP_UNBLOCK_SOURCE: greqs.gsr_source.ss_family != AF_INET) {
case IP_ADD_SOURCE_MEMBERSHIP: err = -EADDRNOTAVAIL;
case IP_DROP_SOURCE_MEMBERSHIP:
{
struct ip_mreq_source mreqs;
int omode, add;
if (optlen != sizeof(struct ip_mreq_source))
goto e_inval;
if (copy_from_user(&mreqs, optval, sizeof(mreqs))) {
err = -EFAULT;
break;
}
if (optname == IP_BLOCK_SOURCE) {
omode = MCAST_EXCLUDE;
add = 1;
} else if (optname == IP_UNBLOCK_SOURCE) {
omode = MCAST_EXCLUDE;
add = 0;
} else if (optname == IP_ADD_SOURCE_MEMBERSHIP) {
struct ip_mreqn mreq;
mreq.imr_multiaddr.s_addr = mreqs.imr_multiaddr;
mreq.imr_address.s_addr = mreqs.imr_interface;
mreq.imr_ifindex = 0;
err = ip_mc_join_group(sk, &mreq);
if (err && err != -EADDRINUSE)
break;
omode = MCAST_INCLUDE;
add = 1;
} else /* IP_DROP_SOURCE_MEMBERSHIP */ {
omode = MCAST_INCLUDE;
add = 0;
}
err = ip_mc_source(add, omode, sk, &mreqs, 0);
break; break;
} }
case MCAST_JOIN_GROUP: psin = (struct sockaddr_in *)&greqs.gsr_group;
case MCAST_LEAVE_GROUP: mreqs.imr_multiaddr = psin->sin_addr.s_addr;
{ psin = (struct sockaddr_in *)&greqs.gsr_source;
struct group_req greq; mreqs.imr_sourceaddr = psin->sin_addr.s_addr;
struct sockaddr_in *psin; mreqs.imr_interface = 0; /* use index for mc_source */
if (optname == MCAST_BLOCK_SOURCE) {
omode = MCAST_EXCLUDE;
add = 1;
} else if (optname == MCAST_UNBLOCK_SOURCE) {
omode = MCAST_EXCLUDE;
add = 0;
} else if (optname == MCAST_JOIN_SOURCE_GROUP) {
struct ip_mreqn mreq; struct ip_mreqn mreq;
if (optlen < sizeof(struct group_req)) psin = (struct sockaddr_in *)&greqs.gsr_group;
goto e_inval;
err = -EFAULT;
if(copy_from_user(&greq, optval, sizeof(greq)))
break;
psin = (struct sockaddr_in *)&greq.gr_group;
if (psin->sin_family != AF_INET)
goto e_inval;
memset(&mreq, 0, sizeof(mreq));
mreq.imr_multiaddr = psin->sin_addr; mreq.imr_multiaddr = psin->sin_addr;
mreq.imr_ifindex = greq.gr_interface; mreq.imr_address.s_addr = 0;
mreq.imr_ifindex = greqs.gsr_interface;
if (optname == MCAST_JOIN_GROUP) err = ip_mc_join_group(sk, &mreq);
err = ip_mc_join_group(sk, &mreq); if (err && err != -EADDRINUSE)
else break;
err = ip_mc_leave_group(sk, &mreq); greqs.gsr_interface = mreq.imr_ifindex;
omode = MCAST_INCLUDE;
add = 1;
} else /* MCAST_LEAVE_SOURCE_GROUP */ {
omode = MCAST_INCLUDE;
add = 0;
}
err = ip_mc_source(add, omode, sk, &mreqs,
greqs.gsr_interface);
break;
}
case MCAST_MSFILTER:
{
extern int sysctl_igmp_max_msf;
struct sockaddr_in *psin;
struct ip_msfilter *msf = NULL;
struct group_filter *gsf = NULL;
int msize, i, ifindex;
if (optlen < GROUP_FILTER_SIZE(0))
goto e_inval;
if (optlen > sysctl_optmem_max) {
err = -ENOBUFS;
break; break;
} }
case MCAST_JOIN_SOURCE_GROUP: gsf = kmalloc(optlen,GFP_KERNEL);
case MCAST_LEAVE_SOURCE_GROUP: if (gsf == 0) {
case MCAST_BLOCK_SOURCE: err = -ENOBUFS;
case MCAST_UNBLOCK_SOURCE:
{
struct group_source_req greqs;
struct ip_mreq_source mreqs;
struct sockaddr_in *psin;
int omode, add;
if (optlen != sizeof(struct group_source_req))
goto e_inval;
if (copy_from_user(&greqs, optval, sizeof(greqs))) {
err = -EFAULT;
break;
}
if (greqs.gsr_group.ss_family != AF_INET ||
greqs.gsr_source.ss_family != AF_INET) {
err = -EADDRNOTAVAIL;
break;
}
psin = (struct sockaddr_in *)&greqs.gsr_group;
mreqs.imr_multiaddr = psin->sin_addr.s_addr;
psin = (struct sockaddr_in *)&greqs.gsr_source;
mreqs.imr_sourceaddr = psin->sin_addr.s_addr;
mreqs.imr_interface = 0; /* use index for mc_source */
if (optname == MCAST_BLOCK_SOURCE) {
omode = MCAST_EXCLUDE;
add = 1;
} else if (optname == MCAST_UNBLOCK_SOURCE) {
omode = MCAST_EXCLUDE;
add = 0;
} else if (optname == MCAST_JOIN_SOURCE_GROUP) {
struct ip_mreqn mreq;
psin = (struct sockaddr_in *)&greqs.gsr_group;
mreq.imr_multiaddr = psin->sin_addr;
mreq.imr_address.s_addr = 0;
mreq.imr_ifindex = greqs.gsr_interface;
err = ip_mc_join_group(sk, &mreq);
if (err && err != -EADDRINUSE)
break;
greqs.gsr_interface = mreq.imr_ifindex;
omode = MCAST_INCLUDE;
add = 1;
} else /* MCAST_LEAVE_SOURCE_GROUP */ {
omode = MCAST_INCLUDE;
add = 0;
}
err = ip_mc_source(add, omode, sk, &mreqs,
greqs.gsr_interface);
break; break;
} }
case MCAST_MSFILTER: err = -EFAULT;
{ if (copy_from_user(gsf, optval, optlen)) {
extern int sysctl_igmp_max_msf; goto mc_msf_out;
struct sockaddr_in *psin; }
struct ip_msfilter *msf = NULL; /* numsrc >= (4G-140)/128 overflow in 32 bits */
struct group_filter *gsf = NULL; if (gsf->gf_numsrc >= 0x1ffffff ||
int msize, i, ifindex; gsf->gf_numsrc > sysctl_igmp_max_msf) {
err = -ENOBUFS;
if (optlen < GROUP_FILTER_SIZE(0)) goto mc_msf_out;
goto e_inval; }
if (optlen > sysctl_optmem_max) { if (GROUP_FILTER_SIZE(gsf->gf_numsrc) > optlen) {
err = -ENOBUFS; err = -EINVAL;
break; goto mc_msf_out;
} }
gsf = kmalloc(optlen,GFP_KERNEL); msize = IP_MSFILTER_SIZE(gsf->gf_numsrc);
if (gsf == 0) { msf = kmalloc(msize,GFP_KERNEL);
err = -ENOBUFS; if (msf == 0) {
break; err = -ENOBUFS;
} goto mc_msf_out;
err = -EFAULT; }
if (copy_from_user(gsf, optval, optlen)) { ifindex = gsf->gf_interface;
goto mc_msf_out; psin = (struct sockaddr_in *)&gsf->gf_group;
} if (psin->sin_family != AF_INET) {
/* numsrc >= (4G-140)/128 overflow in 32 bits */
if (gsf->gf_numsrc >= 0x1ffffff ||
gsf->gf_numsrc > sysctl_igmp_max_msf) {
err = -ENOBUFS;
goto mc_msf_out;
}
if (GROUP_FILTER_SIZE(gsf->gf_numsrc) > optlen) {
err = -EINVAL;
goto mc_msf_out;
}
msize = IP_MSFILTER_SIZE(gsf->gf_numsrc);
msf = kmalloc(msize,GFP_KERNEL);
if (msf == 0) {
err = -ENOBUFS;
goto mc_msf_out;
}
ifindex = gsf->gf_interface;
psin = (struct sockaddr_in *)&gsf->gf_group;
if (psin->sin_family != AF_INET) {
err = -EADDRNOTAVAIL;
goto mc_msf_out;
}
msf->imsf_multiaddr = psin->sin_addr.s_addr;
msf->imsf_interface = 0;
msf->imsf_fmode = gsf->gf_fmode;
msf->imsf_numsrc = gsf->gf_numsrc;
err = -EADDRNOTAVAIL; err = -EADDRNOTAVAIL;
for (i=0; i<gsf->gf_numsrc; ++i) { goto mc_msf_out;
psin = (struct sockaddr_in *)&gsf->gf_slist[i];
if (psin->sin_family != AF_INET)
goto mc_msf_out;
msf->imsf_slist[i] = psin->sin_addr.s_addr;
}
kfree(gsf);
gsf = NULL;
err = ip_mc_msfilter(sk, msf, ifindex);
mc_msf_out:
kfree(msf);
kfree(gsf);
break;
} }
case IP_ROUTER_ALERT: msf->imsf_multiaddr = psin->sin_addr.s_addr;
err = ip_ra_control(sk, val ? 1 : 0, NULL); msf->imsf_interface = 0;
break; msf->imsf_fmode = gsf->gf_fmode;
msf->imsf_numsrc = gsf->gf_numsrc;
err = -EADDRNOTAVAIL;
for (i=0; i<gsf->gf_numsrc; ++i) {
psin = (struct sockaddr_in *)&gsf->gf_slist[i];
case IP_FREEBIND: if (psin->sin_family != AF_INET)
if (optlen<1) goto mc_msf_out;
goto e_inval; msf->imsf_slist[i] = psin->sin_addr.s_addr;
inet->freebind = !!val; }
break; kfree(gsf);
gsf = NULL;
case IP_IPSEC_POLICY:
case IP_XFRM_POLICY: err = ip_mc_msfilter(sk, msf, ifindex);
err = -EPERM; mc_msf_out:
if (!capable(CAP_NET_ADMIN)) kfree(msf);
break; kfree(gsf);
err = xfrm_user_policy(sk, optname, optval, optlen); break;
}
case IP_ROUTER_ALERT:
err = ip_ra_control(sk, val ? 1 : 0, NULL);
break;
case IP_FREEBIND:
if (optlen<1)
goto e_inval;
inet->freebind = !!val;
break;
case IP_IPSEC_POLICY:
case IP_XFRM_POLICY:
err = -EPERM;
if (!capable(CAP_NET_ADMIN))
break; break;
err = xfrm_user_policy(sk, optname, optval, optlen);
break;
default: default:
err = -ENOPROTOOPT; err = -ENOPROTOOPT;
break; break;
} }
release_sock(sk); release_sock(sk);
return err; return err;
...@@ -948,214 +948,213 @@ EXPORT_SYMBOL(compat_ip_setsockopt); ...@@ -948,214 +948,213 @@ EXPORT_SYMBOL(compat_ip_setsockopt);
*/ */
static int do_ip_getsockopt(struct sock *sk, int level, int optname, static int do_ip_getsockopt(struct sock *sk, int level, int optname,
char __user *optval, int __user *optlen) char __user *optval, int __user *optlen)
{ {
struct inet_sock *inet = inet_sk(sk); struct inet_sock *inet = inet_sk(sk);
int val; int val;
int len; int len;
if(level!=SOL_IP) if (level != SOL_IP)
return -EOPNOTSUPP; return -EOPNOTSUPP;
#ifdef CONFIG_IP_MROUTE #ifdef CONFIG_IP_MROUTE
if(optname>=MRT_BASE && optname <=MRT_BASE+10) if (optname >= MRT_BASE && optname <= MRT_BASE+10) {
{
return ip_mroute_getsockopt(sk,optname,optval,optlen); return ip_mroute_getsockopt(sk,optname,optval,optlen);
} }
#endif #endif
if(get_user(len,optlen)) if (get_user(len,optlen))
return -EFAULT; return -EFAULT;
if(len < 0) if (len < 0)
return -EINVAL; return -EINVAL;
lock_sock(sk); lock_sock(sk);
switch(optname) { switch (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,
sizeof(struct ip_options)+ sizeof(struct ip_options)+
inet->opt->optlen); inet->opt->optlen);
release_sock(sk); release_sock(sk);
if (opt->optlen == 0) if (opt->optlen == 0)
return put_user(0, optlen); return put_user(0, optlen);
ip_options_undo(opt); ip_options_undo(opt);
len = min_t(unsigned int, len, opt->optlen); len = min_t(unsigned int, len, opt->optlen);
if(put_user(len, optlen)) if (put_user(len, optlen))
return -EFAULT; return -EFAULT;
if(copy_to_user(optval, opt->__data, len)) if (copy_to_user(optval, opt->__data, len))
return -EFAULT; return -EFAULT;
return 0; return 0;
} }
case IP_PKTINFO: case IP_PKTINFO:
val = (inet->cmsg_flags & IP_CMSG_PKTINFO) != 0; val = (inet->cmsg_flags & IP_CMSG_PKTINFO) != 0;
break; break;
case IP_RECVTTL: case IP_RECVTTL:
val = (inet->cmsg_flags & IP_CMSG_TTL) != 0; val = (inet->cmsg_flags & IP_CMSG_TTL) != 0;
break; break;
case IP_RECVTOS: case IP_RECVTOS:
val = (inet->cmsg_flags & IP_CMSG_TOS) != 0; val = (inet->cmsg_flags & IP_CMSG_TOS) != 0;
break; break;
case IP_RECVOPTS: case IP_RECVOPTS:
val = (inet->cmsg_flags & IP_CMSG_RECVOPTS) != 0; val = (inet->cmsg_flags & IP_CMSG_RECVOPTS) != 0;
break; break;
case IP_RETOPTS: case IP_RETOPTS:
val = (inet->cmsg_flags & IP_CMSG_RETOPTS) != 0; val = (inet->cmsg_flags & IP_CMSG_RETOPTS) != 0;
break; break;
case IP_PASSSEC: case IP_PASSSEC:
val = (inet->cmsg_flags & IP_CMSG_PASSSEC) != 0; val = (inet->cmsg_flags & IP_CMSG_PASSSEC) != 0;
break; break;
case IP_TOS: case IP_TOS:
val = inet->tos; val = inet->tos;
break; break;
case IP_TTL: case IP_TTL:
val = (inet->uc_ttl == -1 ? val = (inet->uc_ttl == -1 ?
sysctl_ip_default_ttl : sysctl_ip_default_ttl :
inet->uc_ttl); inet->uc_ttl);
break; break;
case IP_HDRINCL: case IP_HDRINCL:
val = inet->hdrincl; val = inet->hdrincl;
break; break;
case IP_MTU_DISCOVER: case IP_MTU_DISCOVER:
val = inet->pmtudisc; val = inet->pmtudisc;
break; break;
case IP_MTU: case IP_MTU:
{ {
struct dst_entry *dst; struct dst_entry *dst;
val = 0; val = 0;
dst = sk_dst_get(sk); dst = sk_dst_get(sk);
if (dst) { if (dst) {
val = dst_mtu(dst); val = dst_mtu(dst);
dst_release(dst); dst_release(dst);
}
if (!val) {
release_sock(sk);
return -ENOTCONN;
}
break;
} }
case IP_RECVERR: if (!val) {
val = inet->recverr;
break;
case IP_MULTICAST_TTL:
val = inet->mc_ttl;
break;
case IP_MULTICAST_LOOP:
val = inet->mc_loop;
break;
case IP_MULTICAST_IF:
{
struct in_addr addr;
len = min_t(unsigned int, len, sizeof(struct in_addr));
addr.s_addr = inet->mc_addr;
release_sock(sk); release_sock(sk);
return -ENOTCONN;
if(put_user(len, optlen))
return -EFAULT;
if(copy_to_user(optval, &addr, len))
return -EFAULT;
return 0;
} }
case IP_MSFILTER: break;
{ }
struct ip_msfilter msf; case IP_RECVERR:
int err; val = inet->recverr;
break;
case IP_MULTICAST_TTL:
val = inet->mc_ttl;
break;
case IP_MULTICAST_LOOP:
val = inet->mc_loop;
break;
case IP_MULTICAST_IF:
{
struct in_addr addr;
len = min_t(unsigned int, len, sizeof(struct in_addr));
addr.s_addr = inet->mc_addr;
release_sock(sk);
if (len < IP_MSFILTER_SIZE(0)) { if (put_user(len, optlen))
release_sock(sk); return -EFAULT;
return -EINVAL; if (copy_to_user(optval, &addr, len))
} return -EFAULT;
if (copy_from_user(&msf, optval, IP_MSFILTER_SIZE(0))) { return 0;
release_sock(sk); }
return -EFAULT; case IP_MSFILTER:
} {
err = ip_mc_msfget(sk, &msf, struct ip_msfilter msf;
(struct ip_msfilter __user *)optval, optlen); int err;
if (len < IP_MSFILTER_SIZE(0)) {
release_sock(sk); release_sock(sk);
return err; return -EINVAL;
} }
case MCAST_MSFILTER: if (copy_from_user(&msf, optval, IP_MSFILTER_SIZE(0))) {
{
struct group_filter gsf;
int err;
if (len < GROUP_FILTER_SIZE(0)) {
release_sock(sk);
return -EINVAL;
}
if (copy_from_user(&gsf, optval, GROUP_FILTER_SIZE(0))) {
release_sock(sk);
return -EFAULT;
}
err = ip_mc_gsfget(sk, &gsf,
(struct group_filter __user *)optval, optlen);
release_sock(sk); release_sock(sk);
return err; return -EFAULT;
} }
case IP_PKTOPTIONS: err = ip_mc_msfget(sk, &msf,
{ (struct ip_msfilter __user *)optval, optlen);
struct msghdr msg; release_sock(sk);
return err;
}
case MCAST_MSFILTER:
{
struct group_filter gsf;
int err;
if (len < GROUP_FILTER_SIZE(0)) {
release_sock(sk); release_sock(sk);
return -EINVAL;
}
if (copy_from_user(&gsf, optval, GROUP_FILTER_SIZE(0))) {
release_sock(sk);
return -EFAULT;
}
err = ip_mc_gsfget(sk, &gsf,
(struct group_filter __user *)optval, optlen);
release_sock(sk);
return err;
}
case IP_PKTOPTIONS:
{
struct msghdr msg;
release_sock(sk);
if (sk->sk_type != SOCK_STREAM) if (sk->sk_type != SOCK_STREAM)
return -ENOPROTOOPT; return -ENOPROTOOPT;
msg.msg_control = optval; msg.msg_control = optval;
msg.msg_controllen = len; msg.msg_controllen = len;
msg.msg_flags = 0; msg.msg_flags = 0;
if (inet->cmsg_flags & IP_CMSG_PKTINFO) { if (inet->cmsg_flags & IP_CMSG_PKTINFO) {
struct in_pktinfo info; struct in_pktinfo info;
info.ipi_addr.s_addr = inet->rcv_saddr; info.ipi_addr.s_addr = inet->rcv_saddr;
info.ipi_spec_dst.s_addr = inet->rcv_saddr; info.ipi_spec_dst.s_addr = inet->rcv_saddr;
info.ipi_ifindex = inet->mc_index; info.ipi_ifindex = inet->mc_index;
put_cmsg(&msg, SOL_IP, IP_PKTINFO, sizeof(info), &info); put_cmsg(&msg, SOL_IP, IP_PKTINFO, sizeof(info), &info);
}
if (inet->cmsg_flags & IP_CMSG_TTL) {
int hlim = inet->mc_ttl;
put_cmsg(&msg, SOL_IP, IP_TTL, sizeof(hlim), &hlim);
}
len -= msg.msg_controllen;
return put_user(len, optlen);
} }
case IP_FREEBIND: if (inet->cmsg_flags & IP_CMSG_TTL) {
val = inet->freebind; int hlim = inet->mc_ttl;
break; put_cmsg(&msg, SOL_IP, IP_TTL, sizeof(hlim), &hlim);
default: }
release_sock(sk); len -= msg.msg_controllen;
return -ENOPROTOOPT; return put_user(len, optlen);
}
case IP_FREEBIND:
val = inet->freebind;
break;
default:
release_sock(sk);
return -ENOPROTOOPT;
} }
release_sock(sk); release_sock(sk);
if (len < sizeof(int) && len > 0 && val>=0 && val<255) { if (len < sizeof(int) && len > 0 && val>=0 && val<255) {
unsigned char ucval = (unsigned char)val; unsigned char ucval = (unsigned char)val;
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;
} }
int ip_getsockopt(struct sock *sk, int level, int ip_getsockopt(struct sock *sk, int level,
int optname, char __user *optval, int __user *optlen) int optname, char __user *optval, int __user *optlen)
{ {
int err; int err;
...@@ -1169,7 +1168,7 @@ int ip_getsockopt(struct sock *sk, int level, ...@@ -1169,7 +1168,7 @@ int ip_getsockopt(struct sock *sk, int level,
) { ) {
int len; int len;
if(get_user(len,optlen)) if (get_user(len,optlen))
return -EFAULT; return -EFAULT;
lock_sock(sk); lock_sock(sk);
......
...@@ -782,7 +782,7 @@ static void __init ic_do_bootp_ext(u8 *ext) ...@@ -782,7 +782,7 @@ static void __init ic_do_bootp_ext(u8 *ext)
u8 *c; u8 *c;
printk("DHCP/BOOTP: Got extension %d:",*ext); printk("DHCP/BOOTP: Got extension %d:",*ext);
for(c=ext+2; c<ext+2+ext[1]; c++) for (c=ext+2; c<ext+2+ext[1]; c++)
printk(" %02x", *c); printk(" %02x", *c);
printk("\n"); printk("\n");
#endif #endif
...@@ -1094,7 +1094,7 @@ static int __init ic_dynamic(void) ...@@ -1094,7 +1094,7 @@ static int __init ic_dynamic(void)
retries = CONF_SEND_RETRIES; retries = CONF_SEND_RETRIES;
get_random_bytes(&timeout, sizeof(timeout)); get_random_bytes(&timeout, sizeof(timeout));
timeout = CONF_BASE_TIMEOUT + (timeout % (unsigned) CONF_TIMEOUT_RANDOM); timeout = CONF_BASE_TIMEOUT + (timeout % (unsigned) CONF_TIMEOUT_RANDOM);
for(;;) { for (;;) {
#ifdef IPCONFIG_BOOTP #ifdef IPCONFIG_BOOTP
if (do_bootp && (d->able & IC_BOOTP)) if (do_bootp && (d->able & IC_BOOTP))
ic_bootp_send_if(d, jiffies - start_jiffies); ic_bootp_send_if(d, jiffies - start_jiffies);
......
...@@ -302,7 +302,7 @@ static void ipmr_destroy_unres(struct mfc_cache *c) ...@@ -302,7 +302,7 @@ static void ipmr_destroy_unres(struct mfc_cache *c)
atomic_dec(&cache_resolve_queue_len); atomic_dec(&cache_resolve_queue_len);
while((skb=skb_dequeue(&c->mfc_un.unres.unresolved))) { while ((skb=skb_dequeue(&c->mfc_un.unres.unresolved))) {
if (skb->nh.iph->version == 0) { if (skb->nh.iph->version == 0) {
struct nlmsghdr *nlh = (struct nlmsghdr *)skb_pull(skb, sizeof(struct iphdr)); struct nlmsghdr *nlh = (struct nlmsghdr *)skb_pull(skb, sizeof(struct iphdr));
nlh->nlmsg_type = NLMSG_ERROR; nlh->nlmsg_type = NLMSG_ERROR;
...@@ -479,7 +479,7 @@ static struct mfc_cache *ipmr_cache_find(__be32 origin, __be32 mcastgrp) ...@@ -479,7 +479,7 @@ static struct mfc_cache *ipmr_cache_find(__be32 origin, __be32 mcastgrp)
static struct mfc_cache *ipmr_cache_alloc(void) static struct mfc_cache *ipmr_cache_alloc(void)
{ {
struct mfc_cache *c=kmem_cache_zalloc(mrt_cachep, GFP_KERNEL); struct mfc_cache *c=kmem_cache_zalloc(mrt_cachep, GFP_KERNEL);
if(c==NULL) if (c==NULL)
return NULL; return NULL;
c->mfc_un.res.minvif = MAXVIFS; c->mfc_un.res.minvif = MAXVIFS;
return c; return c;
...@@ -488,7 +488,7 @@ static struct mfc_cache *ipmr_cache_alloc(void) ...@@ -488,7 +488,7 @@ static struct mfc_cache *ipmr_cache_alloc(void)
static struct mfc_cache *ipmr_cache_alloc_unres(void) static struct mfc_cache *ipmr_cache_alloc_unres(void)
{ {
struct mfc_cache *c=kmem_cache_zalloc(mrt_cachep, GFP_ATOMIC); struct mfc_cache *c=kmem_cache_zalloc(mrt_cachep, GFP_ATOMIC);
if(c==NULL) if (c==NULL)
return NULL; return NULL;
skb_queue_head_init(&c->mfc_un.unres.unresolved); skb_queue_head_init(&c->mfc_un.unres.unresolved);
c->mfc_un.unres.expires = jiffies + 10*HZ; c->mfc_un.unres.expires = jiffies + 10*HZ;
...@@ -508,7 +508,7 @@ static void ipmr_cache_resolve(struct mfc_cache *uc, struct mfc_cache *c) ...@@ -508,7 +508,7 @@ static void ipmr_cache_resolve(struct mfc_cache *uc, struct mfc_cache *c)
* Play the pending entries through our router * Play the pending entries through our router
*/ */
while((skb=__skb_dequeue(&uc->mfc_un.unres.unresolved))) { while ((skb=__skb_dequeue(&uc->mfc_un.unres.unresolved))) {
if (skb->nh.iph->version == 0) { if (skb->nh.iph->version == 0) {
struct nlmsghdr *nlh = (struct nlmsghdr *)skb_pull(skb, sizeof(struct iphdr)); struct nlmsghdr *nlh = (struct nlmsghdr *)skb_pull(skb, sizeof(struct iphdr));
...@@ -551,7 +551,7 @@ static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert) ...@@ -551,7 +551,7 @@ static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert)
#endif #endif
skb = alloc_skb(128, GFP_ATOMIC); skb = alloc_skb(128, GFP_ATOMIC);
if(!skb) if (!skb)
return -ENOBUFS; return -ENOBUFS;
#ifdef CONFIG_IP_PIMSM #ifdef CONFIG_IP_PIMSM
...@@ -734,7 +734,7 @@ static int ipmr_mfc_add(struct mfcctl *mfc, int mrtsock) ...@@ -734,7 +734,7 @@ static int ipmr_mfc_add(struct mfcctl *mfc, int mrtsock)
return 0; return 0;
} }
if(!MULTICAST(mfc->mfcc_mcastgrp.s_addr)) if (!MULTICAST(mfc->mfcc_mcastgrp.s_addr))
return -EINVAL; return -EINVAL;
c=ipmr_cache_alloc(); c=ipmr_cache_alloc();
...@@ -788,7 +788,7 @@ static void mroute_clean_tables(struct sock *sk) ...@@ -788,7 +788,7 @@ static void mroute_clean_tables(struct sock *sk)
/* /*
* Shut down all active vif entries * Shut down all active vif entries
*/ */
for(i=0; i<maxvif; i++) { for (i=0; i<maxvif; i++) {
if (!(vif_table[i].flags&VIFF_STATIC)) if (!(vif_table[i].flags&VIFF_STATIC))
vif_delete(i); vif_delete(i);
} }
...@@ -858,119 +858,117 @@ int ip_mroute_setsockopt(struct sock *sk,int optname,char __user *optval,int opt ...@@ -858,119 +858,117 @@ int ip_mroute_setsockopt(struct sock *sk,int optname,char __user *optval,int opt
struct vifctl vif; struct vifctl vif;
struct mfcctl mfc; struct mfcctl mfc;
if(optname!=MRT_INIT) if (optname != MRT_INIT) {
{ if (sk != mroute_socket && !capable(CAP_NET_ADMIN))
if(sk!=mroute_socket && !capable(CAP_NET_ADMIN))
return -EACCES; return -EACCES;
} }
switch(optname) switch (optname) {
{ case MRT_INIT:
case MRT_INIT: if (sk->sk_type != SOCK_RAW ||
if (sk->sk_type != SOCK_RAW || inet_sk(sk)->num != IPPROTO_IGMP)
inet_sk(sk)->num != IPPROTO_IGMP) return -EOPNOTSUPP;
return -EOPNOTSUPP; if (optlen!=sizeof(int))
if(optlen!=sizeof(int)) return -ENOPROTOOPT;
return -ENOPROTOOPT;
rtnl_lock();
if (mroute_socket) {
rtnl_unlock();
return -EADDRINUSE;
}
ret = ip_ra_control(sk, 1, mrtsock_destruct);
if (ret == 0) {
write_lock_bh(&mrt_lock);
mroute_socket=sk;
write_unlock_bh(&mrt_lock);
ipv4_devconf.mc_forwarding++; rtnl_lock();
} if (mroute_socket) {
rtnl_unlock(); rtnl_unlock();
return ret; return -EADDRINUSE;
case MRT_DONE: }
if (sk!=mroute_socket)
return -EACCES; ret = ip_ra_control(sk, 1, mrtsock_destruct);
return ip_ra_control(sk, 0, NULL); if (ret == 0) {
case MRT_ADD_VIF: write_lock_bh(&mrt_lock);
case MRT_DEL_VIF: mroute_socket=sk;
if(optlen!=sizeof(vif)) write_unlock_bh(&mrt_lock);
return -EINVAL;
if (copy_from_user(&vif,optval,sizeof(vif))) ipv4_devconf.mc_forwarding++;
return -EFAULT; }
if(vif.vifc_vifi >= MAXVIFS) rtnl_unlock();
return -ENFILE; return ret;
rtnl_lock(); case MRT_DONE:
if (optname==MRT_ADD_VIF) { if (sk!=mroute_socket)
ret = vif_add(&vif, sk==mroute_socket); return -EACCES;
} else { return ip_ra_control(sk, 0, NULL);
ret = vif_delete(vif.vifc_vifi); case MRT_ADD_VIF:
} case MRT_DEL_VIF:
rtnl_unlock(); if (optlen!=sizeof(vif))
return ret; return -EINVAL;
if (copy_from_user(&vif,optval,sizeof(vif)))
return -EFAULT;
if (vif.vifc_vifi >= MAXVIFS)
return -ENFILE;
rtnl_lock();
if (optname==MRT_ADD_VIF) {
ret = vif_add(&vif, sk==mroute_socket);
} else {
ret = vif_delete(vif.vifc_vifi);
}
rtnl_unlock();
return ret;
/* /*
* Manipulate the forwarding caches. These live * Manipulate the forwarding caches. These live
* in a sort of kernel/user symbiosis. * in a sort of kernel/user symbiosis.
*/ */
case MRT_ADD_MFC: case MRT_ADD_MFC:
case MRT_DEL_MFC: case MRT_DEL_MFC:
if(optlen!=sizeof(mfc)) if (optlen!=sizeof(mfc))
return -EINVAL; return -EINVAL;
if (copy_from_user(&mfc,optval, sizeof(mfc))) if (copy_from_user(&mfc,optval, sizeof(mfc)))
return -EFAULT; return -EFAULT;
rtnl_lock(); rtnl_lock();
if (optname==MRT_DEL_MFC) if (optname==MRT_DEL_MFC)
ret = ipmr_mfc_delete(&mfc); ret = ipmr_mfc_delete(&mfc);
else else
ret = ipmr_mfc_add(&mfc, sk==mroute_socket); ret = ipmr_mfc_add(&mfc, sk==mroute_socket);
rtnl_unlock(); rtnl_unlock();
return ret; return ret;
/* /*
* Control PIM assert. * Control PIM assert.
*/ */
case MRT_ASSERT: case MRT_ASSERT:
{ {
int v; int v;
if(get_user(v,(int __user *)optval)) if (get_user(v,(int __user *)optval))
return -EFAULT; return -EFAULT;
mroute_do_assert=(v)?1:0; mroute_do_assert=(v)?1:0;
return 0; return 0;
} }
#ifdef CONFIG_IP_PIMSM #ifdef CONFIG_IP_PIMSM
case MRT_PIM: case MRT_PIM:
{ {
int v, ret; int v, ret;
if(get_user(v,(int __user *)optval)) if (get_user(v,(int __user *)optval))
return -EFAULT; return -EFAULT;
v = (v)?1:0; v = (v)?1:0;
rtnl_lock(); rtnl_lock();
ret = 0; ret = 0;
if (v != mroute_do_pim) { if (v != mroute_do_pim) {
mroute_do_pim = v; mroute_do_pim = v;
mroute_do_assert = v; mroute_do_assert = v;
#ifdef CONFIG_IP_PIMSM_V2 #ifdef CONFIG_IP_PIMSM_V2
if (mroute_do_pim) if (mroute_do_pim)
ret = inet_add_protocol(&pim_protocol, ret = inet_add_protocol(&pim_protocol,
IPPROTO_PIM); IPPROTO_PIM);
else else
ret = inet_del_protocol(&pim_protocol, ret = inet_del_protocol(&pim_protocol,
IPPROTO_PIM); IPPROTO_PIM);
if (ret < 0) if (ret < 0)
ret = -EAGAIN; ret = -EAGAIN;
#endif #endif
}
rtnl_unlock();
return ret;
} }
rtnl_unlock();
return ret;
}
#endif #endif
/* /*
* Spurious command, or MRT_VERSION which you cannot * Spurious command, or MRT_VERSION which you cannot
* set. * set.
*/ */
default: default:
return -ENOPROTOOPT; return -ENOPROTOOPT;
} }
} }
...@@ -983,7 +981,7 @@ int ip_mroute_getsockopt(struct sock *sk,int optname,char __user *optval,int __u ...@@ -983,7 +981,7 @@ int ip_mroute_getsockopt(struct sock *sk,int optname,char __user *optval,int __u
int olr; int olr;
int val; int val;
if(optname!=MRT_VERSION && if (optname!=MRT_VERSION &&
#ifdef CONFIG_IP_PIMSM #ifdef CONFIG_IP_PIMSM
optname!=MRT_PIM && optname!=MRT_PIM &&
#endif #endif
...@@ -997,17 +995,17 @@ int ip_mroute_getsockopt(struct sock *sk,int optname,char __user *optval,int __u ...@@ -997,17 +995,17 @@ int ip_mroute_getsockopt(struct sock *sk,int optname,char __user *optval,int __u
if (olr < 0) if (olr < 0)
return -EINVAL; return -EINVAL;
if(put_user(olr,optlen)) if (put_user(olr,optlen))
return -EFAULT; return -EFAULT;
if(optname==MRT_VERSION) if (optname==MRT_VERSION)
val=0x0305; val=0x0305;
#ifdef CONFIG_IP_PIMSM #ifdef CONFIG_IP_PIMSM
else if(optname==MRT_PIM) else if (optname==MRT_PIM)
val=mroute_do_pim; val=mroute_do_pim;
#endif #endif
else else
val=mroute_do_assert; val=mroute_do_assert;
if(copy_to_user(optval,&val,olr)) if (copy_to_user(optval,&val,olr))
return -EFAULT; return -EFAULT;
return 0; return 0;
} }
...@@ -1023,48 +1021,47 @@ int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg) ...@@ -1023,48 +1021,47 @@ int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg)
struct vif_device *vif; struct vif_device *vif;
struct mfc_cache *c; struct mfc_cache *c;
switch(cmd) switch (cmd) {
{ case SIOCGETVIFCNT:
case SIOCGETVIFCNT: if (copy_from_user(&vr,arg,sizeof(vr)))
if (copy_from_user(&vr,arg,sizeof(vr))) return -EFAULT;
return -EFAULT; if (vr.vifi>=maxvif)
if(vr.vifi>=maxvif) return -EINVAL;
return -EINVAL; read_lock(&mrt_lock);
read_lock(&mrt_lock); vif=&vif_table[vr.vifi];
vif=&vif_table[vr.vifi]; if (VIF_EXISTS(vr.vifi)) {
if(VIF_EXISTS(vr.vifi)) { vr.icount=vif->pkt_in;
vr.icount=vif->pkt_in; vr.ocount=vif->pkt_out;
vr.ocount=vif->pkt_out; vr.ibytes=vif->bytes_in;
vr.ibytes=vif->bytes_in; vr.obytes=vif->bytes_out;
vr.obytes=vif->bytes_out;
read_unlock(&mrt_lock);
if (copy_to_user(arg,&vr,sizeof(vr)))
return -EFAULT;
return 0;
}
read_unlock(&mrt_lock); read_unlock(&mrt_lock);
return -EADDRNOTAVAIL;
case SIOCGETSGCNT:
if (copy_from_user(&sr,arg,sizeof(sr)))
return -EFAULT;
read_lock(&mrt_lock); if (copy_to_user(arg,&vr,sizeof(vr)))
c = ipmr_cache_find(sr.src.s_addr, sr.grp.s_addr); return -EFAULT;
if (c) { return 0;
sr.pktcnt = c->mfc_un.res.pkt; }
sr.bytecnt = c->mfc_un.res.bytes; read_unlock(&mrt_lock);
sr.wrong_if = c->mfc_un.res.wrong_if; return -EADDRNOTAVAIL;
read_unlock(&mrt_lock); case SIOCGETSGCNT:
if (copy_from_user(&sr,arg,sizeof(sr)))
if (copy_to_user(arg,&sr,sizeof(sr))) return -EFAULT;
return -EFAULT;
return 0; read_lock(&mrt_lock);
} c = ipmr_cache_find(sr.src.s_addr, sr.grp.s_addr);
if (c) {
sr.pktcnt = c->mfc_un.res.pkt;
sr.bytecnt = c->mfc_un.res.bytes;
sr.wrong_if = c->mfc_un.res.wrong_if;
read_unlock(&mrt_lock); read_unlock(&mrt_lock);
return -EADDRNOTAVAIL;
default: if (copy_to_user(arg,&sr,sizeof(sr)))
return -ENOIOCTLCMD; return -EFAULT;
return 0;
}
read_unlock(&mrt_lock);
return -EADDRNOTAVAIL;
default:
return -ENOIOCTLCMD;
} }
} }
...@@ -1076,7 +1073,7 @@ static int ipmr_device_event(struct notifier_block *this, unsigned long event, v ...@@ -1076,7 +1073,7 @@ static int ipmr_device_event(struct notifier_block *this, unsigned long event, v
if (event != NETDEV_UNREGISTER) if (event != NETDEV_UNREGISTER)
return NOTIFY_DONE; return NOTIFY_DONE;
v=&vif_table[0]; v=&vif_table[0];
for(ct=0;ct<maxvif;ct++,v++) { for (ct=0;ct<maxvif;ct++,v++) {
if (v->dev==ptr) if (v->dev==ptr)
vif_delete(ct); vif_delete(ct);
} }
...@@ -1625,7 +1622,7 @@ static struct vif_device *ipmr_vif_seq_idx(struct ipmr_vif_iter *iter, ...@@ -1625,7 +1622,7 @@ static struct vif_device *ipmr_vif_seq_idx(struct ipmr_vif_iter *iter,
loff_t pos) loff_t pos)
{ {
for (iter->ct = 0; iter->ct < maxvif; ++iter->ct) { for (iter->ct = 0; iter->ct < maxvif; ++iter->ct) {
if(!VIF_EXISTS(iter->ct)) if (!VIF_EXISTS(iter->ct))
continue; continue;
if (pos-- == 0) if (pos-- == 0)
return &vif_table[iter->ct]; return &vif_table[iter->ct];
...@@ -1649,7 +1646,7 @@ static void *ipmr_vif_seq_next(struct seq_file *seq, void *v, loff_t *pos) ...@@ -1649,7 +1646,7 @@ static void *ipmr_vif_seq_next(struct seq_file *seq, void *v, loff_t *pos)
return ipmr_vif_seq_idx(iter, 0); return ipmr_vif_seq_idx(iter, 0);
while (++iter->ct < maxvif) { while (++iter->ct < maxvif) {
if(!VIF_EXISTS(iter->ct)) if (!VIF_EXISTS(iter->ct))
continue; continue;
return &vif_table[iter->ct]; return &vif_table[iter->ct];
} }
...@@ -1732,14 +1729,14 @@ static struct mfc_cache *ipmr_mfc_seq_idx(struct ipmr_mfc_iter *it, loff_t pos) ...@@ -1732,14 +1729,14 @@ static struct mfc_cache *ipmr_mfc_seq_idx(struct ipmr_mfc_iter *it, loff_t pos)
it->cache = mfc_cache_array; it->cache = mfc_cache_array;
read_lock(&mrt_lock); read_lock(&mrt_lock);
for (it->ct = 0; it->ct < MFC_LINES; it->ct++) for (it->ct = 0; it->ct < MFC_LINES; it->ct++)
for(mfc = mfc_cache_array[it->ct]; mfc; mfc = mfc->next) for (mfc = mfc_cache_array[it->ct]; mfc; mfc = mfc->next)
if (pos-- == 0) if (pos-- == 0)
return mfc; return mfc;
read_unlock(&mrt_lock); read_unlock(&mrt_lock);
it->cache = &mfc_unres_queue; it->cache = &mfc_unres_queue;
spin_lock_bh(&mfc_unres_lock); spin_lock_bh(&mfc_unres_lock);
for(mfc = mfc_unres_queue; mfc; mfc = mfc->next) for (mfc = mfc_unres_queue; mfc; mfc = mfc->next)
if (pos-- == 0) if (pos-- == 0)
return mfc; return mfc;
spin_unlock_bh(&mfc_unres_lock); spin_unlock_bh(&mfc_unres_lock);
...@@ -1829,9 +1826,9 @@ static int ipmr_mfc_seq_show(struct seq_file *seq, void *v) ...@@ -1829,9 +1826,9 @@ static int ipmr_mfc_seq_show(struct seq_file *seq, void *v)
mfc->mfc_un.res.wrong_if); mfc->mfc_un.res.wrong_if);
if (it->cache != &mfc_unres_queue) { if (it->cache != &mfc_unres_queue) {
for(n = mfc->mfc_un.res.minvif; for (n = mfc->mfc_un.res.minvif;
n < mfc->mfc_un.res.maxvif; n++ ) { n < mfc->mfc_un.res.maxvif; n++ ) {
if(VIF_EXISTS(n) if (VIF_EXISTS(n)
&& mfc->mfc_un.res.ttls[n] < 255) && mfc->mfc_un.res.ttls[n] < 255)
seq_printf(seq, seq_printf(seq,
" %2d:%-3d", " %2d:%-3d",
......
...@@ -93,7 +93,7 @@ static int xfrm4_tunnel_input(struct xfrm_state *x, struct sk_buff *skb) ...@@ -93,7 +93,7 @@ static int xfrm4_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
struct iphdr *iph = skb->nh.iph; struct iphdr *iph = skb->nh.iph;
int err = -EINVAL; int err = -EINVAL;
switch(iph->protocol){ switch (iph->protocol){
case IPPROTO_IPIP: case IPPROTO_IPIP:
break; break;
#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
......
...@@ -119,7 +119,7 @@ __xfrm4_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int ...@@ -119,7 +119,7 @@ __xfrm4_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
if (xfrm[i]->props.mode == XFRM_MODE_TUNNEL) { if (xfrm[i]->props.mode == XFRM_MODE_TUNNEL) {
unsigned short encap_family = xfrm[i]->props.family; unsigned short encap_family = xfrm[i]->props.family;
switch(encap_family) { switch (encap_family) {
case AF_INET: case AF_INET:
fl_tunnel.fl4_dst = xfrm[i]->id.daddr.a4; fl_tunnel.fl4_dst = xfrm[i]->id.daddr.a4;
fl_tunnel.fl4_src = xfrm[i]->props.saddr.a4; fl_tunnel.fl4_src = xfrm[i]->props.saddr.a4;
......
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