* [PATCH net-next v4] net: ipv6: fix code style error and warning of ndisc.c
From: yuan linyu @ 2017-05-20 13:57 UTC (permalink / raw)
To: netdev; +Cc: David S . Miller, yuan linyu
From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
Signed-off-by: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
---
net/ipv6/ndisc.c | 310 +++++++++++++++++++++++++++++--------------------------
1 file changed, 163 insertions(+), 147 deletions(-)
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index d310dc4..df31f29 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -12,8 +12,7 @@
* 2 of the License, or (at your option) any later version.
*/
-/*
- * Changes:
+/* Changes:
*
* Alexey I. Froloff : RFC6106 (DNSSL) support
* Pierre Ynard : export userland ND options
@@ -99,7 +98,6 @@ static const struct neigh_ops ndisc_hh_ops = {
.connected_output = neigh_resolve_output,
};
-
static const struct neigh_ops ndisc_direct_ops = {
.family = AF_INET6,
.output = neigh_direct_output,
@@ -147,13 +145,13 @@ void __ndisc_fill_addr_option(struct sk_buff *skb, int type, void *data,
u8 *opt = skb_put(skb, space);
opt[0] = type;
- opt[1] = space>>3;
+ opt[1] = space >> 3;
memset(opt + 2, 0, pad);
opt += pad;
space -= pad;
- memcpy(opt+2, data, data_len);
+ memcpy(opt + 2, data, data_len);
data_len += 2;
opt += data_len;
space -= data_len;
@@ -182,6 +180,7 @@ static struct nd_opt_hdr *ndisc_next_option(struct nd_opt_hdr *cur,
struct nd_opt_hdr *end)
{
int type;
+
if (!cur || !end || cur >= end)
return NULL;
type = cur->nd_opt_type;
@@ -222,6 +221,7 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
memset(ndopts, 0, sizeof(*ndopts));
while (opt_len) {
int l;
+
if (opt_len < sizeof(struct nd_opt_hdr))
return NULL;
l = nd_opt->nd_opt_len << 3;
@@ -240,13 +240,15 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
"%s: duplicated ND6 option found: type=%d\n",
__func__, nd_opt->nd_opt_type);
} else {
- ndopts->nd_opt_array[nd_opt->nd_opt_type] = nd_opt;
+ ndopts->nd_opt_array[nd_opt->nd_opt_type] =
+ nd_opt;
}
break;
case ND_OPT_PREFIX_INFO:
ndopts->nd_opts_pi_end = nd_opt;
if (!ndopts->nd_opt_array[nd_opt->nd_opt_type])
- ndopts->nd_opt_array[nd_opt->nd_opt_type] = nd_opt;
+ ndopts->nd_opt_array[nd_opt->nd_opt_type] =
+ nd_opt;
break;
#ifdef CONFIG_IPV6_ROUTE_INFO
case ND_OPT_ROUTE_INFO:
@@ -261,8 +263,7 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
if (!ndopts->nd_useropts)
ndopts->nd_useropts = nd_opt;
} else {
- /*
- * Unknown options must be silently ignored,
+ /* Unknown options must be silently ignored,
* to accommodate future extension to the
* protocol.
*/
@@ -280,7 +281,8 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
return ndopts;
}
-int ndisc_mc_map(const struct in6_addr *addr, char *buf, struct net_device *dev, int dir)
+int ndisc_mc_map(const struct in6_addr *addr, char *buf,
+ struct net_device *dev, int dir)
{
switch (dev->type) {
case ARPHRD_ETHER:
@@ -327,9 +329,8 @@ static int ndisc_constructor(struct neighbour *neigh)
bool is_multicast = ipv6_addr_is_multicast(addr);
in6_dev = in6_dev_get(dev);
- if (!in6_dev) {
+ if (!in6_dev)
return -EINVAL;
- }
parms = in6_dev->nd_parms;
__neigh_parms_put(neigh->parms);
@@ -344,12 +345,12 @@ static int ndisc_constructor(struct neighbour *neigh)
if (is_multicast) {
neigh->nud_state = NUD_NOARP;
ndisc_mc_map(addr, neigh->ha, dev, 1);
- } else if (dev->flags&(IFF_NOARP|IFF_LOOPBACK)) {
+ } else if (dev->flags & (IFF_NOARP | IFF_LOOPBACK)) {
neigh->nud_state = NUD_NOARP;
memcpy(neigh->ha, dev->dev_addr, dev->addr_len);
- if (dev->flags&IFF_LOOPBACK)
+ if (dev->flags & IFF_LOOPBACK)
neigh->type = RTN_LOCAL;
- } else if (dev->flags&IFF_POINTOPOINT) {
+ } else if (dev->flags & IFF_POINTOPOINT) {
neigh->nud_state = NUD_NOARP;
memcpy(neigh->ha, dev->broadcast, dev->addr_len);
}
@@ -357,7 +358,7 @@ static int ndisc_constructor(struct neighbour *neigh)
neigh->ops = &ndisc_hh_ops;
else
neigh->ops = &ndisc_generic_ops;
- if (neigh->nud_state&NUD_VALID)
+ if (neigh->nud_state & NUD_VALID)
neigh->output = neigh->ops->connected_output;
else
neigh->output = neigh->ops->output;
@@ -512,7 +513,8 @@ void ndisc_send_na(struct net_device *dev, const struct in6_addr *daddr,
in6_ifa_put(ifp);
} else {
if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
- inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
+ inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->
+ srcprefs,
&tmpaddr))
return;
src_addr = &tmpaddr;
@@ -580,7 +582,7 @@ void ndisc_send_ns(struct net_device *dev, const struct in6_addr *solicit,
if (!saddr) {
if (ipv6_get_lladdr(dev, &addr_buf,
- (IFA_F_TENTATIVE|IFA_F_OPTIMISTIC)))
+ (IFA_F_TENTATIVE | IFA_F_OPTIMISTIC)))
return;
saddr = &addr_buf;
}
@@ -629,8 +631,7 @@ void ndisc_send_rs(struct net_device *dev, const struct in6_addr *saddr,
int optlen = 0;
#ifdef CONFIG_IPV6_OPTIMISTIC_DAD
- /*
- * According to section 2.2 of RFC 4429, we must not
+ /* According to section 2.2 of RFC 4429, we must not
* send router solicitations with a sllao from
* optimistic addresses, but we may send the solicitation
* if we don't include the sllao. So here we check
@@ -641,9 +642,8 @@ void ndisc_send_rs(struct net_device *dev, const struct in6_addr *saddr,
struct inet6_ifaddr *ifp = ipv6_get_ifaddr(dev_net(dev), saddr,
dev, 1);
if (ifp) {
- if (ifp->flags & IFA_F_OPTIMISTIC) {
+ if (ifp->flags & IFA_F_OPTIMISTIC)
send_sllao = 0;
- }
in6_ifa_put(ifp);
} else {
send_sllao = 0;
@@ -672,11 +672,9 @@ void ndisc_send_rs(struct net_device *dev, const struct in6_addr *saddr,
ndisc_send_skb(skb, daddr, saddr);
}
-
static void ndisc_error_report(struct neighbour *neigh, struct sk_buff *skb)
{
- /*
- * "The sender MUST return an ICMP
+ /* "The sender MUST return an ICMP
* destination unreachable"
*/
dst_link_failure(skb);
@@ -695,7 +693,7 @@ static void ndisc_solicit(struct neighbour *neigh, struct sk_buff *skb)
if (skb && ipv6_chk_addr_and_flags(dev_net(dev), &ipv6_hdr(skb)->saddr,
dev, 1,
- IFA_F_TENTATIVE|IFA_F_OPTIMISTIC))
+ IFA_F_TENTATIVE | IFA_F_OPTIMISTIC))
saddr = &ipv6_hdr(skb)->saddr;
probes -= NEIGH_VAR(neigh->parms, UCAST_PROBES);
if (probes < 0) {
@@ -705,11 +703,14 @@ static void ndisc_solicit(struct neighbour *neigh, struct sk_buff *skb)
__func__, target);
}
ndisc_send_ns(dev, target, target, saddr, 0);
- } else if ((probes -= NEIGH_VAR(neigh->parms, APP_PROBES)) < 0) {
- neigh_app_ns(neigh);
} else {
- addrconf_addr_solict_mult(target, &mcaddr);
- ndisc_send_ns(dev, target, &mcaddr, saddr, 0);
+ probes -= NEIGH_VAR(neigh->parms, APP_PROBES);
+ if (probes < 0) {
+ neigh_app_ns(neigh);
+ } else {
+ addrconf_addr_solict_mult(target, &mcaddr);
+ ndisc_send_ns(dev, target, &mcaddr, saddr, 0);
+ }
}
}
@@ -765,8 +766,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
return;
}
- /*
- * RFC2461 7.1.1:
+ /* RFC2461 7.1.1:
* DAD has to be destined for solicited node multicast address.
*/
if (dad && !ipv6_addr_is_solict_mult(daddr)) {
@@ -806,7 +806,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
ifp = ipv6_get_ifaddr(dev_net(dev), &msg->target, dev, 1);
if (ifp) {
have_ifp:
- if (ifp->flags & (IFA_F_TENTATIVE|IFA_F_OPTIMISTIC)) {
+ if (ifp->flags & (IFA_F_TENTATIVE | IFA_F_OPTIMISTIC)) {
if (dad) {
if (nonce != 0 && ifp->dad_nonce == nonce) {
u8 *np = (u8 *)&nonce;
@@ -817,28 +817,27 @@ static void ndisc_recv_ns(struct sk_buff *skb)
&ifp->addr, np);
goto out;
}
- /*
- * We are colliding with another node
+ /* We are colliding with another node
* who is doing DAD
* so fail our DAD process
*/
addrconf_dad_failure(ifp);
return;
- } else {
- /*
- * This is not a dad solicitation.
- * If we are an optimistic node,
- * we should respond.
- * Otherwise, we should ignore it.
- */
- if (!(ifp->flags & IFA_F_OPTIMISTIC))
- goto out;
}
+
+ /* This is not a dad solicitation.
+ * If we are an optimistic node,
+ * we should respond.
+ * Otherwise, we should ignore it.
+ */
+ if (!(ifp->flags & IFA_F_OPTIMISTIC))
+ goto out;
}
idev = ifp->idev;
} else {
struct net *net = dev_net(dev);
+ bool is_acast_proxy = false;
/* perhaps an address on the master device */
if (netif_is_l3_slave(dev)) {
@@ -846,7 +845,8 @@ static void ndisc_recv_ns(struct sk_buff *skb)
mdev = netdev_master_upper_dev_get_rcu(dev);
if (mdev) {
- ifp = ipv6_get_ifaddr(net, &msg->target, mdev, 1);
+ ifp = ipv6_get_ifaddr(net, &msg->target,
+ mdev, 1);
if (ifp)
goto have_ifp;
}
@@ -858,28 +858,36 @@ static void ndisc_recv_ns(struct sk_buff *skb)
return;
}
- if (ipv6_chk_acast_addr(net, dev, &msg->target) ||
- (idev->cnf.forwarding &&
- (net->ipv6.devconf_all->proxy_ndp || idev->cnf.proxy_ndp) &&
- (is_router = pndisc_is_router(&msg->target, dev)) >= 0)) {
+ if (ipv6_chk_acast_addr(net, dev, &msg->target)) {
+ is_acast_proxy = true;
+ } else if (idev->cnf.forwarding &&
+ (net->ipv6.devconf_all->proxy_ndp ||
+ idev->cnf.proxy_ndp)) {
+ is_router = pndisc_is_router(&msg->target, dev);
+ if (is_router >= 0)
+ is_acast_proxy = true;
+ }
+ if (is_acast_proxy) {
if (!(NEIGH_CB(skb)->flags & LOCALLY_ENQUEUED) &&
skb->pkt_type != PACKET_HOST &&
inc &&
NEIGH_VAR(idev->nd_parms, PROXY_DELAY) != 0) {
- /*
- * for anycast or proxy,
+ /* for anycast or proxy,
* sender should delay its response
* by a random time between 0 and
* MAX_ANYCAST_DELAY_TIME seconds.
* (RFC2461) -- yoshfuji
*/
struct sk_buff *n = skb_clone(skb, GFP_ATOMIC);
+
if (n)
- pneigh_enqueue(&nd_tbl, idev->nd_parms, n);
+ pneigh_enqueue(&nd_tbl,
+ idev->nd_parms, n);
goto out;
}
- } else
+ } else {
goto out;
+ }
}
if (is_router < 0)
@@ -887,7 +895,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
if (dad) {
ndisc_send_na(dev, &in6addr_linklocal_allnodes, &msg->target,
- !!is_router, false, (ifp != NULL), true);
+ !!is_router, false, ifp, true);
goto out;
}
@@ -896,20 +904,19 @@ static void ndisc_recv_ns(struct sk_buff *skb)
else
NEIGH_CACHE_STAT_INC(&nd_tbl, rcv_probes_ucast);
- /*
- * update / create cache entry
+ /* update / create cache entry
* for the source address
*/
neigh = __neigh_lookup(&nd_tbl, saddr, dev,
!inc || lladdr || !dev->addr_len);
if (neigh)
ndisc_update(dev, neigh, lladdr, NUD_STALE,
- NEIGH_UPDATE_F_WEAK_OVERRIDE|
+ NEIGH_UPDATE_F_WEAK_OVERRIDE |
NEIGH_UPDATE_F_OVERRIDE,
NDISC_NEIGHBOUR_SOLICITATION, &ndopts);
if (neigh || !dev->header_ops) {
ndisc_send_na(dev, saddr, &msg->target, !!is_router,
- true, (ifp != NULL && inc), inc);
+ true, (ifp && inc), inc);
if (neigh)
neigh_release(neigh);
}
@@ -973,19 +980,19 @@ static void ndisc_recv_na(struct sk_buff *skb)
}
ifp = ipv6_get_ifaddr(dev_net(dev), &msg->target, dev, 1);
if (ifp) {
- if (skb->pkt_type != PACKET_LOOPBACK
- && (ifp->flags & IFA_F_TENTATIVE)) {
- addrconf_dad_failure(ifp);
- return;
+ if (skb->pkt_type != PACKET_LOOPBACK &&
+ (ifp->flags & IFA_F_TENTATIVE)) {
+ addrconf_dad_failure(ifp);
+ return;
}
/* What should we make now? The advertisement
- is invalid, but ndisc specs say nothing
- about it. It could be misconfiguration, or
- an smart proxy agent tries to help us :-)
-
- We should not print the error if NA has been
- received from loopback - it is just our own
- unsolicited advertisement.
+ * is invalid, but ndisc specs say nothing
+ * about it. It could be misconfiguration, or
+ * an smart proxy agent tries to help us :-)
+ *
+ * We should not print the error if NA has been
+ * received from loopback - it is just our own
+ * unsolicited advertisement.
*/
if (skb->pkt_type != PACKET_LOOPBACK)
ND_PRINTK(1, warn,
@@ -1003,30 +1010,31 @@ static void ndisc_recv_na(struct sk_buff *skb)
if (neigh->nud_state & NUD_FAILED)
goto out;
- /*
- * Don't update the neighbor cache entry on a proxy NA from
+ /* Don't update the neighbor cache entry on a proxy NA from
* ourselves because either the proxied node is off link or it
* has already sent a NA to us.
*/
if (lladdr && !memcmp(lladdr, dev->dev_addr, dev->addr_len) &&
- net->ipv6.devconf_all->forwarding && net->ipv6.devconf_all->proxy_ndp &&
+ net->ipv6.devconf_all->forwarding &&
+ net->ipv6.devconf_all->proxy_ndp &&
pneigh_lookup(&nd_tbl, net, &msg->target, dev, 0)) {
/* XXX: idev->cnf.proxy_ndp */
goto out;
}
ndisc_update(dev, neigh, lladdr,
- msg->icmph.icmp6_solicited ? NUD_REACHABLE : NUD_STALE,
- NEIGH_UPDATE_F_WEAK_OVERRIDE|
- (msg->icmph.icmp6_override ? NEIGH_UPDATE_F_OVERRIDE : 0)|
- NEIGH_UPDATE_F_OVERRIDE_ISROUTER|
- (msg->icmph.icmp6_router ? NEIGH_UPDATE_F_ISROUTER : 0),
+ msg->icmph.icmp6_solicited ?
+ NUD_REACHABLE : NUD_STALE,
+ NEIGH_UPDATE_F_WEAK_OVERRIDE |
+ (msg->icmph.icmp6_override ?
+ NEIGH_UPDATE_F_OVERRIDE : 0) |
+ NEIGH_UPDATE_F_OVERRIDE_ISROUTER |
+ (msg->icmph.icmp6_router ?
+ NEIGH_UPDATE_F_ISROUTER : 0),
NDISC_NEIGHBOUR_ADVERTISEMENT, &ndopts);
if ((old_flags & ~neigh->flags) & NTF_ROUTER) {
- /*
- * Change: router to host
- */
+ /* Change: router to host */
rt6_clean_tohost(dev_net(dev), saddr);
}
@@ -1058,8 +1066,7 @@ static void ndisc_recv_rs(struct sk_buff *skb)
if (!idev->cnf.forwarding)
goto out;
- /*
- * Don't update NCE if src = ::;
+ /* Don't update NCE if src = ::;
* this implies that the source node has no ip address assigned yet.
*/
if (ipv6_addr_any(saddr))
@@ -1081,8 +1088,8 @@ static void ndisc_recv_rs(struct sk_buff *skb)
neigh = __neigh_lookup(&nd_tbl, saddr, skb->dev, 1);
if (neigh) {
ndisc_update(skb->dev, neigh, lladdr, NUD_STALE,
- NEIGH_UPDATE_F_WEAK_OVERRIDE|
- NEIGH_UPDATE_F_OVERRIDE|
+ NEIGH_UPDATE_F_WEAK_OVERRIDE |
+ NEIGH_UPDATE_F_OVERRIDE |
NEIGH_UPDATE_F_OVERRIDE_ISROUTER,
NDISC_ROUTER_SOLICITATION, &ndopts);
neigh_release(neigh);
@@ -1110,9 +1117,8 @@ static void ndisc_ra_useropt(struct sk_buff *ra, struct nd_opt_hdr *opt)
}
nlh = nlmsg_put(skb, 0, 0, RTM_NEWNDUSEROPT, base_size, 0);
- if (!nlh) {
+ if (!nlh)
goto nla_put_failure;
- }
ndmsg = nlmsg_data(nlh);
ndmsg->nduseropt_family = AF_INET6;
@@ -1174,9 +1180,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
}
#endif
- /*
- * set the RA_RECV flag in the interface
- */
+ /* set the RA_RECV flag in the interface */
in6_dev = __in6_dev_get(skb->dev);
if (!in6_dev) {
@@ -1208,15 +1212,13 @@ static void ndisc_router_discovery(struct sk_buff *skb)
#endif
if (in6_dev->if_flags & IF_RS_SENT) {
- /*
- * flag that an RA was received after an RS was sent
+ /* flag that an RA was received after an RS was sent
* out on this interface.
*/
in6_dev->if_flags |= IF_RA_RCVD;
}
- /*
- * Remember the managed/otherconf flags from most recently
+ /* Remember the managed/otherconf flags from most recently
* received RA message (RFC 2462) -- yoshfuji
*/
old_if_flags = in6_dev->if_flags;
@@ -1299,77 +1301,79 @@ static void ndisc_router_discovery(struct sk_buff *skb)
}
neigh->flags |= NTF_ROUTER;
} else if (rt) {
- rt->rt6i_flags = (rt->rt6i_flags & ~RTF_PREF_MASK) | RTF_PREF(pref);
+ rt->rt6i_flags =
+ (rt->rt6i_flags & ~RTF_PREF_MASK) | RTF_PREF(pref);
}
if (rt)
rt6_set_expires(rt, jiffies + (HZ * lifetime));
if (in6_dev->cnf.accept_ra_min_hop_limit < 256 &&
ra_msg->icmph.icmp6_hop_limit) {
- if (in6_dev->cnf.accept_ra_min_hop_limit <= ra_msg->icmph.icmp6_hop_limit) {
+ if (in6_dev->cnf.accept_ra_min_hop_limit <=
+ ra_msg->icmph.icmp6_hop_limit) {
in6_dev->cnf.hop_limit = ra_msg->icmph.icmp6_hop_limit;
if (rt)
dst_metric_set(&rt->dst, RTAX_HOPLIMIT,
ra_msg->icmph.icmp6_hop_limit);
} else {
- ND_PRINTK(2, warn, "RA: Got route advertisement with lower hop_limit than minimum\n");
+ ND_PRINTK(2, warn,
+ "RA: Got route advertisement with lower hop_limit than minimum\n");
}
}
skip_defrtr:
- /*
- * Update Reachable Time and Retrans Timer
- */
+ /* Update Reachable Time and Retrans Timer */
if (in6_dev->nd_parms) {
unsigned long rtime = ntohl(ra_msg->retrans_timer);
- if (rtime && rtime/1000 < MAX_SCHEDULE_TIMEOUT/HZ) {
- rtime = (rtime*HZ)/1000;
- if (rtime < HZ/10)
- rtime = HZ/10;
+ if (rtime && rtime / 1000 < MAX_SCHEDULE_TIMEOUT / HZ) {
+ rtime = (rtime * HZ) / 1000;
+ if (rtime < HZ / 10)
+ rtime = HZ / 10;
NEIGH_VAR_SET(in6_dev->nd_parms, RETRANS_TIME, rtime);
in6_dev->tstamp = jiffies;
send_ifinfo_notify = true;
}
rtime = ntohl(ra_msg->reachable_time);
- if (rtime && rtime/1000 < MAX_SCHEDULE_TIMEOUT/(3*HZ)) {
- rtime = (rtime*HZ)/1000;
+ if (rtime && rtime / 1000 < MAX_SCHEDULE_TIMEOUT / (3 * HZ)) {
+ rtime = (rtime * HZ) / 1000;
- if (rtime < HZ/10)
- rtime = HZ/10;
+ if (rtime < HZ / 10)
+ rtime = HZ / 10;
- if (rtime != NEIGH_VAR(in6_dev->nd_parms, BASE_REACHABLE_TIME)) {
+ if (rtime != NEIGH_VAR(in6_dev->nd_parms,
+ BASE_REACHABLE_TIME)) {
NEIGH_VAR_SET(in6_dev->nd_parms,
BASE_REACHABLE_TIME, rtime);
NEIGH_VAR_SET(in6_dev->nd_parms,
GC_STALETIME, 3 * rtime);
- in6_dev->nd_parms->reachable_time = neigh_rand_reach_time(rtime);
+ in6_dev->nd_parms->reachable_time =
+ neigh_rand_reach_time(rtime);
in6_dev->tstamp = jiffies;
send_ifinfo_notify = true;
}
}
}
- /*
- * Send a notify if RA changed managed/otherconf flags or timer settings
+ /* Send a notify if RA changed managed/otherconf flags
+ * or timer settings
*/
if (send_ifinfo_notify)
inet6_ifinfo_notify(RTM_NEWLINK, in6_dev);
skip_linkparms:
- /*
- * Process options.
- */
+ /* Process options */
if (!neigh)
neigh = __neigh_lookup(&nd_tbl, &ipv6_hdr(skb)->saddr,
skb->dev, 1);
if (neigh) {
u8 *lladdr = NULL;
+
if (ndopts.nd_opts_src_lladdr) {
lladdr = ndisc_opt_addr_data(ndopts.nd_opts_src_lladdr,
skb->dev);
@@ -1380,9 +1384,9 @@ static void ndisc_router_discovery(struct sk_buff *skb)
}
}
ndisc_update(skb->dev, neigh, lladdr, NUD_STALE,
- NEIGH_UPDATE_F_WEAK_OVERRIDE|
- NEIGH_UPDATE_F_OVERRIDE|
- NEIGH_UPDATE_F_OVERRIDE_ISROUTER|
+ NEIGH_UPDATE_F_WEAK_OVERRIDE |
+ NEIGH_UPDATE_F_OVERRIDE |
+ NEIGH_UPDATE_F_OVERRIDE_ISROUTER |
NEIGH_UPDATE_F_ISROUTER,
NDISC_ROUTER_ADVERTISEMENT, &ndopts);
}
@@ -1406,6 +1410,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
if (in6_dev->cnf.accept_ra_rtr_pref && ndopts.nd_opts_ri) {
struct nd_opt_hdr *p;
+
for (p = ndopts.nd_opts_ri;
p;
p = ndisc_next_option(p, ndopts.nd_opts_ri_end)) {
@@ -1418,9 +1423,11 @@ static void ndisc_router_discovery(struct sk_buff *skb)
if (ri->prefix_len == 0 &&
!in6_dev->cnf.accept_ra_defrtr)
continue;
- if (ri->prefix_len < in6_dev->cnf.accept_ra_rt_info_min_plen)
+ if (ri->prefix_len <
+ in6_dev->cnf.accept_ra_rt_info_min_plen)
continue;
- if (ri->prefix_len > in6_dev->cnf.accept_ra_rt_info_max_plen)
+ if (ri->prefix_len >
+ in6_dev->cnf.accept_ra_rt_info_max_plen)
continue;
rt6_route_rcv(skb->dev, (u8 *)p, (p->nd_opt_len) << 3,
&ipv6_hdr(skb)->saddr);
@@ -1442,12 +1449,13 @@ static void ndisc_router_discovery(struct sk_buff *skb)
if (in6_dev->cnf.accept_ra_pinfo && ndopts.nd_opts_pi) {
struct nd_opt_hdr *p;
+
for (p = ndopts.nd_opts_pi;
p;
p = ndisc_next_option(p, ndopts.nd_opts_pi_end)) {
addrconf_prefix_rcv(skb->dev, (u8 *)p,
(p->nd_opt_len) << 3,
- ndopts.nd_opts_src_lladdr != NULL);
+ ndopts.nd_opts_src_lladdr);
}
}
@@ -1455,7 +1463,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
__be32 n;
u32 mtu;
- memcpy(&n, ((u8 *)(ndopts.nd_opts_mtu+1))+2, sizeof(mtu));
+ memcpy(&n, ((u8 *)(ndopts.nd_opts_mtu + 1)) + 2, sizeof(mtu));
mtu = ntohl(n);
if (mtu < IPV6_MIN_MTU || mtu > skb->dev->mtu) {
@@ -1472,6 +1480,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
if (ndopts.nd_useropts) {
struct nd_opt_hdr *p;
+
for (p = ndopts.nd_useropts;
p;
p = ndisc_next_useropt(skb->dev, p,
@@ -1480,9 +1489,9 @@ static void ndisc_router_discovery(struct sk_buff *skb)
}
}
- if (ndopts.nd_opts_tgt_lladdr || ndopts.nd_opts_rh) {
+ if (ndopts.nd_opts_tgt_lladdr || ndopts.nd_opts_rh)
ND_PRINTK(2, warn, "RA: invalid RA options\n");
- }
+
out:
ip6_rt_put(rt);
if (neigh)
@@ -1518,7 +1527,7 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
if (!ndopts.nd_opts_rh) {
ip6_redirect_no_header(skb, dev_net(skb->dev),
- skb->dev->ifindex, 0);
+ skb->dev->ifindex, 0);
return;
}
@@ -1569,7 +1578,8 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
}
if (!ipv6_addr_equal(&ipv6_hdr(skb)->daddr, target) &&
- ipv6_addr_type(target) != (IPV6_ADDR_UNICAST|IPV6_ADDR_LINKLOCAL)) {
+ ipv6_addr_type(target) !=
+ (IPV6_ADDR_UNICAST | IPV6_ADDR_LINKLOCAL)) {
ND_PRINTK(2, warn,
"Redirect: target address is not link-local unicast\n");
return;
@@ -1587,7 +1597,7 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
if (IS_ERR(dst))
return;
- rt = (struct rt6_info *) dst;
+ rt = (struct rt6_info *)dst;
if (rt->rt6i_flags & RTF_GATEWAY) {
ND_PRINTK(2, warn,
@@ -1595,14 +1605,16 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
goto release;
}
peer = inet_getpeer_v6(net->ipv6.peers, &ipv6_hdr(skb)->saddr, 1);
- ret = inet_peer_xrlim_allow(peer, 1*HZ);
+ ret = inet_peer_xrlim_allow(peer, 1 * HZ);
if (peer)
inet_putpeer(peer);
if (!ret)
goto release;
if (dev->addr_len) {
- struct neighbour *neigh = dst_neigh_lookup(skb_dst(skb), target);
+ struct neighbour *neigh =
+ dst_neigh_lookup(skb_dst(skb), target);
+
if (!neigh) {
ND_PRINTK(2, warn,
"Redirect: no neigh for target address\n");
@@ -1617,14 +1629,16 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
optlen += ndisc_redirect_opt_addr_space(dev, neigh,
ops_data_buf,
&ops_data);
- } else
+ } else {
read_unlock_bh(&neigh->lock);
+ }
neigh_release(neigh);
}
rd_len = min_t(unsigned int,
- IPV6_MIN_MTU - sizeof(struct ipv6hdr) - sizeof(*msg) - optlen,
+ IPV6_MIN_MTU - sizeof(struct ipv6hdr) -
+ sizeof(*msg) - optlen,
skb->len + 8);
rd_len &= ~0x7;
optlen += rd_len;
@@ -1642,16 +1656,12 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
.dest = ipv6_hdr(skb)->daddr,
};
- /*
- * include target_address option
- */
+ /* include target_address option */
if (ha)
ndisc_fill_redirect_addr_option(buff, ha, ops_data);
- /*
- * build redirect option and copy skb over to the new packet.
- */
+ /* build redirect option and copy skb over to the new packet */
if (rd_len)
ndisc_fill_redirect_hdr_option(buff, skb, rd_len);
@@ -1737,7 +1747,8 @@ int ndisc_rcv(struct sk_buff *skb)
return 0;
}
-static int ndisc_netdev_event(struct notifier_block *this, unsigned long event, void *ptr)
+static int ndisc_netdev_event(struct notifier_block *this,
+ unsigned long event, void *ptr)
{
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
struct netdev_notifier_change_info *change_info;
@@ -1787,6 +1798,7 @@ static void ndisc_warn_deprecated_sysctl(struct ctl_table *ctl,
{
static char warncomm[TASK_COMM_LEN];
static int warned;
+
if (strcmp(warncomm, current->comm) && warned < 5) {
strcpy(warncomm, current->comm);
pr_warn("process `%s' is using deprecated sysctl (%s) net.ipv6.neigh.%s.%s - use net.ipv6.neigh.%s.%s_ms instead\n",
@@ -1797,7 +1809,8 @@ static void ndisc_warn_deprecated_sysctl(struct ctl_table *ctl,
}
}
-int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
+int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write,
+ void __user *buffer, size_t *lenp, loff_t *ppos)
{
struct net_device *dev = ctl->extra1;
struct inet6_dev *idev;
@@ -1805,7 +1818,8 @@ int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write, void __user *bu
if ((strcmp(ctl->procname, "retrans_time") == 0) ||
(strcmp(ctl->procname, "base_reachable_time") == 0))
- ndisc_warn_deprecated_sysctl(ctl, "syscall", dev ? dev->name : "default");
+ ndisc_warn_deprecated_sysctl(ctl, "syscall",
+ dev ? dev->name : "default");
if (strcmp(ctl->procname, "retrans_time") == 0)
ret = neigh_proc_dointvec(ctl, write, buffer, lenp, ppos);
@@ -1821,18 +1835,22 @@ int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write, void __user *bu
else
ret = -1;
- if (write && ret == 0 && dev && (idev = in6_dev_get(dev)) != NULL) {
- if (ctl->data == &NEIGH_VAR(idev->nd_parms, BASE_REACHABLE_TIME))
+ if (!write || ret || !dev)
+ return ret;
+
+ idev = in6_dev_get(dev);
+ if (idev) {
+ if (ctl->data ==
+ &NEIGH_VAR(idev->nd_parms, BASE_REACHABLE_TIME))
idev->nd_parms->reachable_time =
- neigh_rand_reach_time(NEIGH_VAR(idev->nd_parms, BASE_REACHABLE_TIME));
+ neigh_rand_reach_time(
+ NEIGH_VAR(idev->nd_parms, BASE_REACHABLE_TIME));
idev->tstamp = jiffies;
inet6_ifinfo_notify(RTM_NEWLINK, idev);
in6_dev_put(idev);
}
return ret;
}
-
-
#endif
static int __net_init ndisc_net_init(struct net *net)
@@ -1877,9 +1895,7 @@ int __init ndisc_init(void)
err = register_pernet_subsys(&ndisc_net_ops);
if (err)
return err;
- /*
- * Initialize the neighbour table
- */
+ /* Initialize the neighbour table */
neigh_table_init(NEIGH_ND_TABLE, &nd_tbl);
#ifdef CONFIG_SYSCTL
--
2.7.4
^ permalink raw reply related
* [PATCH net-next v3] net: ipv6: fix code style error and warning of ndisc.c
From: yuan linyu @ 2017-05-20 13:43 UTC (permalink / raw)
To: netdev; +Cc: David S . Miller, yuan linyu
From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
Signed-off-by: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
---
net/ipv6/ndisc.c | 310 +++++++++++++++++++++++++++++--------------------------
1 file changed, 163 insertions(+), 147 deletions(-)
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index d310dc4..7528c4c 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -12,8 +12,7 @@
* 2 of the License, or (at your option) any later version.
*/
-/*
- * Changes:
+/* Changes:
*
* Alexey I. Froloff : RFC6106 (DNSSL) support
* Pierre Ynard : export userland ND options
@@ -99,7 +98,6 @@ static const struct neigh_ops ndisc_hh_ops = {
.connected_output = neigh_resolve_output,
};
-
static const struct neigh_ops ndisc_direct_ops = {
.family = AF_INET6,
.output = neigh_direct_output,
@@ -147,13 +145,13 @@ void __ndisc_fill_addr_option(struct sk_buff *skb, int type, void *data,
u8 *opt = skb_put(skb, space);
opt[0] = type;
- opt[1] = space>>3;
+ opt[1] = space >> 3;
memset(opt + 2, 0, pad);
opt += pad;
space -= pad;
- memcpy(opt+2, data, data_len);
+ memcpy(opt + 2, data, data_len);
data_len += 2;
opt += data_len;
space -= data_len;
@@ -182,6 +180,7 @@ static struct nd_opt_hdr *ndisc_next_option(struct nd_opt_hdr *cur,
struct nd_opt_hdr *end)
{
int type;
+
if (!cur || !end || cur >= end)
return NULL;
type = cur->nd_opt_type;
@@ -222,6 +221,7 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
memset(ndopts, 0, sizeof(*ndopts));
while (opt_len) {
int l;
+
if (opt_len < sizeof(struct nd_opt_hdr))
return NULL;
l = nd_opt->nd_opt_len << 3;
@@ -240,13 +240,15 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
"%s: duplicated ND6 option found: type=%d\n",
__func__, nd_opt->nd_opt_type);
} else {
- ndopts->nd_opt_array[nd_opt->nd_opt_type] = nd_opt;
+ ndopts->nd_opt_array[nd_opt->nd_opt_type] =
+ nd_opt;
}
break;
case ND_OPT_PREFIX_INFO:
ndopts->nd_opts_pi_end = nd_opt;
if (!ndopts->nd_opt_array[nd_opt->nd_opt_type])
- ndopts->nd_opt_array[nd_opt->nd_opt_type] = nd_opt;
+ ndopts->nd_opt_array[nd_opt->nd_opt_type] =
+ nd_opt;
break;
#ifdef CONFIG_IPV6_ROUTE_INFO
case ND_OPT_ROUTE_INFO:
@@ -261,8 +263,7 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
if (!ndopts->nd_useropts)
ndopts->nd_useropts = nd_opt;
} else {
- /*
- * Unknown options must be silently ignored,
+ /* Unknown options must be silently ignored,
* to accommodate future extension to the
* protocol.
*/
@@ -280,7 +281,8 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
return ndopts;
}
-int ndisc_mc_map(const struct in6_addr *addr, char *buf, struct net_device *dev, int dir)
+int ndisc_mc_map(const struct in6_addr *addr, char *buf,
+ struct net_device *dev, int dir)
{
switch (dev->type) {
case ARPHRD_ETHER:
@@ -327,9 +329,8 @@ static int ndisc_constructor(struct neighbour *neigh)
bool is_multicast = ipv6_addr_is_multicast(addr);
in6_dev = in6_dev_get(dev);
- if (!in6_dev) {
+ if (!in6_dev)
return -EINVAL;
- }
parms = in6_dev->nd_parms;
__neigh_parms_put(neigh->parms);
@@ -344,12 +345,12 @@ static int ndisc_constructor(struct neighbour *neigh)
if (is_multicast) {
neigh->nud_state = NUD_NOARP;
ndisc_mc_map(addr, neigh->ha, dev, 1);
- } else if (dev->flags&(IFF_NOARP|IFF_LOOPBACK)) {
+ } else if (dev->flags & (IFF_NOARP | IFF_LOOPBACK)) {
neigh->nud_state = NUD_NOARP;
memcpy(neigh->ha, dev->dev_addr, dev->addr_len);
- if (dev->flags&IFF_LOOPBACK)
+ if (dev->flags & IFF_LOOPBACK)
neigh->type = RTN_LOCAL;
- } else if (dev->flags&IFF_POINTOPOINT) {
+ } else if (dev->flags & IFF_POINTOPOINT) {
neigh->nud_state = NUD_NOARP;
memcpy(neigh->ha, dev->broadcast, dev->addr_len);
}
@@ -357,7 +358,7 @@ static int ndisc_constructor(struct neighbour *neigh)
neigh->ops = &ndisc_hh_ops;
else
neigh->ops = &ndisc_generic_ops;
- if (neigh->nud_state&NUD_VALID)
+ if (neigh->nud_state & NUD_VALID)
neigh->output = neigh->ops->connected_output;
else
neigh->output = neigh->ops->output;
@@ -512,7 +513,8 @@ void ndisc_send_na(struct net_device *dev, const struct in6_addr *daddr,
in6_ifa_put(ifp);
} else {
if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
- inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
+ inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->
+ srcprefs,
&tmpaddr))
return;
src_addr = &tmpaddr;
@@ -580,7 +582,7 @@ void ndisc_send_ns(struct net_device *dev, const struct in6_addr *solicit,
if (!saddr) {
if (ipv6_get_lladdr(dev, &addr_buf,
- (IFA_F_TENTATIVE|IFA_F_OPTIMISTIC)))
+ (IFA_F_TENTATIVE | IFA_F_OPTIMISTIC)))
return;
saddr = &addr_buf;
}
@@ -629,8 +631,7 @@ void ndisc_send_rs(struct net_device *dev, const struct in6_addr *saddr,
int optlen = 0;
#ifdef CONFIG_IPV6_OPTIMISTIC_DAD
- /*
- * According to section 2.2 of RFC 4429, we must not
+ /* According to section 2.2 of RFC 4429, we must not
* send router solicitations with a sllao from
* optimistic addresses, but we may send the solicitation
* if we don't include the sllao. So here we check
@@ -641,9 +642,8 @@ void ndisc_send_rs(struct net_device *dev, const struct in6_addr *saddr,
struct inet6_ifaddr *ifp = ipv6_get_ifaddr(dev_net(dev), saddr,
dev, 1);
if (ifp) {
- if (ifp->flags & IFA_F_OPTIMISTIC) {
+ if (ifp->flags & IFA_F_OPTIMISTIC)
send_sllao = 0;
- }
in6_ifa_put(ifp);
} else {
send_sllao = 0;
@@ -672,11 +672,9 @@ void ndisc_send_rs(struct net_device *dev, const struct in6_addr *saddr,
ndisc_send_skb(skb, daddr, saddr);
}
-
static void ndisc_error_report(struct neighbour *neigh, struct sk_buff *skb)
{
- /*
- * "The sender MUST return an ICMP
+ /* "The sender MUST return an ICMP
* destination unreachable"
*/
dst_link_failure(skb);
@@ -695,7 +693,7 @@ static void ndisc_solicit(struct neighbour *neigh, struct sk_buff *skb)
if (skb && ipv6_chk_addr_and_flags(dev_net(dev), &ipv6_hdr(skb)->saddr,
dev, 1,
- IFA_F_TENTATIVE|IFA_F_OPTIMISTIC))
+ IFA_F_TENTATIVE | IFA_F_OPTIMISTIC))
saddr = &ipv6_hdr(skb)->saddr;
probes -= NEIGH_VAR(neigh->parms, UCAST_PROBES);
if (probes < 0) {
@@ -705,11 +703,14 @@ static void ndisc_solicit(struct neighbour *neigh, struct sk_buff *skb)
__func__, target);
}
ndisc_send_ns(dev, target, target, saddr, 0);
- } else if ((probes -= NEIGH_VAR(neigh->parms, APP_PROBES)) < 0) {
- neigh_app_ns(neigh);
} else {
- addrconf_addr_solict_mult(target, &mcaddr);
- ndisc_send_ns(dev, target, &mcaddr, saddr, 0);
+ probes -= NEIGH_VAR(neigh->parms, APP_PROBES);
+ if (probes < 0) {
+ neigh_app_ns(neigh);
+ } else {
+ addrconf_addr_solict_mult(target, &mcaddr);
+ ndisc_send_ns(dev, target, &mcaddr, saddr, 0);
+ }
}
}
@@ -765,8 +766,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
return;
}
- /*
- * RFC2461 7.1.1:
+ /* RFC2461 7.1.1:
* DAD has to be destined for solicited node multicast address.
*/
if (dad && !ipv6_addr_is_solict_mult(daddr)) {
@@ -806,7 +806,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
ifp = ipv6_get_ifaddr(dev_net(dev), &msg->target, dev, 1);
if (ifp) {
have_ifp:
- if (ifp->flags & (IFA_F_TENTATIVE|IFA_F_OPTIMISTIC)) {
+ if (ifp->flags & (IFA_F_TENTATIVE | IFA_F_OPTIMISTIC)) {
if (dad) {
if (nonce != 0 && ifp->dad_nonce == nonce) {
u8 *np = (u8 *)&nonce;
@@ -817,28 +817,27 @@ static void ndisc_recv_ns(struct sk_buff *skb)
&ifp->addr, np);
goto out;
}
- /*
- * We are colliding with another node
+ /* We are colliding with another node
* who is doing DAD
* so fail our DAD process
*/
addrconf_dad_failure(ifp);
return;
- } else {
- /*
- * This is not a dad solicitation.
- * If we are an optimistic node,
- * we should respond.
- * Otherwise, we should ignore it.
- */
- if (!(ifp->flags & IFA_F_OPTIMISTIC))
- goto out;
}
+
+ /* This is not a dad solicitation.
+ * If we are an optimistic node,
+ * we should respond.
+ * Otherwise, we should ignore it.
+ */
+ if (!(ifp->flags & IFA_F_OPTIMISTIC))
+ goto out;
}
idev = ifp->idev;
} else {
struct net *net = dev_net(dev);
+ bool is_acast_proxy = false;
/* perhaps an address on the master device */
if (netif_is_l3_slave(dev)) {
@@ -846,7 +845,8 @@ static void ndisc_recv_ns(struct sk_buff *skb)
mdev = netdev_master_upper_dev_get_rcu(dev);
if (mdev) {
- ifp = ipv6_get_ifaddr(net, &msg->target, mdev, 1);
+ ifp = ipv6_get_ifaddr(net, &msg->target,
+ mdev, 1);
if (ifp)
goto have_ifp;
}
@@ -858,28 +858,36 @@ static void ndisc_recv_ns(struct sk_buff *skb)
return;
}
- if (ipv6_chk_acast_addr(net, dev, &msg->target) ||
- (idev->cnf.forwarding &&
- (net->ipv6.devconf_all->proxy_ndp || idev->cnf.proxy_ndp) &&
- (is_router = pndisc_is_router(&msg->target, dev)) >= 0)) {
+ if (ipv6_chk_acast_addr(net, dev, &msg->target)) {
+ is_acast_proxy = true;
+ } else if (idev->cnf.forwarding &&
+ (net->ipv6.devconf_all->proxy_ndp ||
+ idev->cnf.proxy_ndp)) {
+ is_router = pndisc_is_router(&msg->target, dev);
+ if (is_router >= 0)
+ is_acast_proxy = true;
+ }
+ if (is_acast_proxy) {
if (!(NEIGH_CB(skb)->flags & LOCALLY_ENQUEUED) &&
skb->pkt_type != PACKET_HOST &&
inc &&
NEIGH_VAR(idev->nd_parms, PROXY_DELAY) != 0) {
- /*
- * for anycast or proxy,
+ /* for anycast or proxy,
* sender should delay its response
* by a random time between 0 and
* MAX_ANYCAST_DELAY_TIME seconds.
* (RFC2461) -- yoshfuji
*/
struct sk_buff *n = skb_clone(skb, GFP_ATOMIC);
+
if (n)
- pneigh_enqueue(&nd_tbl, idev->nd_parms, n);
+ pneigh_enqueue(&nd_tbl,
+ idev->nd_parms, n);
goto out;
}
- } else
+ } else {
goto out;
+ }
}
if (is_router < 0)
@@ -887,7 +895,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
if (dad) {
ndisc_send_na(dev, &in6addr_linklocal_allnodes, &msg->target,
- !!is_router, false, (ifp != NULL), true);
+ !!is_router, false, ifp, true);
goto out;
}
@@ -896,20 +904,19 @@ static void ndisc_recv_ns(struct sk_buff *skb)
else
NEIGH_CACHE_STAT_INC(&nd_tbl, rcv_probes_ucast);
- /*
- * update / create cache entry
+ /* update / create cache entry
* for the source address
*/
neigh = __neigh_lookup(&nd_tbl, saddr, dev,
!inc || lladdr || !dev->addr_len);
if (neigh)
ndisc_update(dev, neigh, lladdr, NUD_STALE,
- NEIGH_UPDATE_F_WEAK_OVERRIDE|
+ NEIGH_UPDATE_F_WEAK_OVERRIDE |
NEIGH_UPDATE_F_OVERRIDE,
NDISC_NEIGHBOUR_SOLICITATION, &ndopts);
if (neigh || !dev->header_ops) {
ndisc_send_na(dev, saddr, &msg->target, !!is_router,
- true, (ifp != NULL && inc), inc);
+ true, (ifp && inc), inc);
if (neigh)
neigh_release(neigh);
}
@@ -973,19 +980,19 @@ static void ndisc_recv_na(struct sk_buff *skb)
}
ifp = ipv6_get_ifaddr(dev_net(dev), &msg->target, dev, 1);
if (ifp) {
- if (skb->pkt_type != PACKET_LOOPBACK
- && (ifp->flags & IFA_F_TENTATIVE)) {
- addrconf_dad_failure(ifp);
- return;
+ if (skb->pkt_type != PACKET_LOOPBACK &&
+ (ifp->flags & IFA_F_TENTATIVE)) {
+ addrconf_dad_failure(ifp);
+ return;
}
/* What should we make now? The advertisement
- is invalid, but ndisc specs say nothing
- about it. It could be misconfiguration, or
- an smart proxy agent tries to help us :-)
-
- We should not print the error if NA has been
- received from loopback - it is just our own
- unsolicited advertisement.
+ * is invalid, but ndisc specs say nothing
+ * about it. It could be misconfiguration, or
+ * an smart proxy agent tries to help us :-)
+ *
+ * We should not print the error if NA has been
+ * received from loopback - it is just our own
+ * unsolicited advertisement.
*/
if (skb->pkt_type != PACKET_LOOPBACK)
ND_PRINTK(1, warn,
@@ -1003,30 +1010,31 @@ static void ndisc_recv_na(struct sk_buff *skb)
if (neigh->nud_state & NUD_FAILED)
goto out;
- /*
- * Don't update the neighbor cache entry on a proxy NA from
+ /* Don't update the neighbor cache entry on a proxy NA from
* ourselves because either the proxied node is off link or it
* has already sent a NA to us.
*/
if (lladdr && !memcmp(lladdr, dev->dev_addr, dev->addr_len) &&
- net->ipv6.devconf_all->forwarding && net->ipv6.devconf_all->proxy_ndp &&
+ net->ipv6.devconf_all->forwarding &&
+ net->ipv6.devconf_all->proxy_ndp &&
pneigh_lookup(&nd_tbl, net, &msg->target, dev, 0)) {
/* XXX: idev->cnf.proxy_ndp */
goto out;
}
ndisc_update(dev, neigh, lladdr,
- msg->icmph.icmp6_solicited ? NUD_REACHABLE : NUD_STALE,
- NEIGH_UPDATE_F_WEAK_OVERRIDE|
- (msg->icmph.icmp6_override ? NEIGH_UPDATE_F_OVERRIDE : 0)|
- NEIGH_UPDATE_F_OVERRIDE_ISROUTER|
- (msg->icmph.icmp6_router ? NEIGH_UPDATE_F_ISROUTER : 0),
+ msg->icmph.icmp6_solicited ?
+ NUD_REACHABLE : NUD_STALE,
+ NEIGH_UPDATE_F_WEAK_OVERRIDE |
+ (msg->icmph.icmp6_override ?
+ NEIGH_UPDATE_F_OVERRIDE : 0) |
+ NEIGH_UPDATE_F_OVERRIDE_ISROUTER |
+ (msg->icmph.icmp6_router ?
+ NEIGH_UPDATE_F_ISROUTER : 0),
NDISC_NEIGHBOUR_ADVERTISEMENT, &ndopts);
if ((old_flags & ~neigh->flags) & NTF_ROUTER) {
- /*
- * Change: router to host
- */
+ /* Change: router to host */
rt6_clean_tohost(dev_net(dev), saddr);
}
@@ -1058,8 +1066,7 @@ static void ndisc_recv_rs(struct sk_buff *skb)
if (!idev->cnf.forwarding)
goto out;
- /*
- * Don't update NCE if src = ::;
+ /* Don't update NCE if src = ::;
* this implies that the source node has no ip address assigned yet.
*/
if (ipv6_addr_any(saddr))
@@ -1081,8 +1088,8 @@ static void ndisc_recv_rs(struct sk_buff *skb)
neigh = __neigh_lookup(&nd_tbl, saddr, skb->dev, 1);
if (neigh) {
ndisc_update(skb->dev, neigh, lladdr, NUD_STALE,
- NEIGH_UPDATE_F_WEAK_OVERRIDE|
- NEIGH_UPDATE_F_OVERRIDE|
+ NEIGH_UPDATE_F_WEAK_OVERRIDE |
+ NEIGH_UPDATE_F_OVERRIDE |
NEIGH_UPDATE_F_OVERRIDE_ISROUTER,
NDISC_ROUTER_SOLICITATION, &ndopts);
neigh_release(neigh);
@@ -1110,9 +1117,8 @@ static void ndisc_ra_useropt(struct sk_buff *ra, struct nd_opt_hdr *opt)
}
nlh = nlmsg_put(skb, 0, 0, RTM_NEWNDUSEROPT, base_size, 0);
- if (!nlh) {
+ if (!nlh)
goto nla_put_failure;
- }
ndmsg = nlmsg_data(nlh);
ndmsg->nduseropt_family = AF_INET6;
@@ -1174,9 +1180,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
}
#endif
- /*
- * set the RA_RECV flag in the interface
- */
+ /* set the RA_RECV flag in the interface */
in6_dev = __in6_dev_get(skb->dev);
if (!in6_dev) {
@@ -1208,15 +1212,13 @@ static void ndisc_router_discovery(struct sk_buff *skb)
#endif
if (in6_dev->if_flags & IF_RS_SENT) {
- /*
- * flag that an RA was received after an RS was sent
+ /* flag that an RA was received after an RS was sent
* out on this interface.
*/
in6_dev->if_flags |= IF_RA_RCVD;
}
- /*
- * Remember the managed/otherconf flags from most recently
+ /* Remember the managed/otherconf flags from most recently
* received RA message (RFC 2462) -- yoshfuji
*/
old_if_flags = in6_dev->if_flags;
@@ -1299,77 +1301,79 @@ static void ndisc_router_discovery(struct sk_buff *skb)
}
neigh->flags |= NTF_ROUTER;
} else if (rt) {
- rt->rt6i_flags = (rt->rt6i_flags & ~RTF_PREF_MASK) | RTF_PREF(pref);
+ rt->rt6i_flags =
+ (rt->rt6i_flags & ~RTF_PREF_MASK) | RTF_PREF(pref);
}
if (rt)
rt6_set_expires(rt, jiffies + (HZ * lifetime));
if (in6_dev->cnf.accept_ra_min_hop_limit < 256 &&
ra_msg->icmph.icmp6_hop_limit) {
- if (in6_dev->cnf.accept_ra_min_hop_limit <= ra_msg->icmph.icmp6_hop_limit) {
+ if (in6_dev->cnf.accept_ra_min_hop_limit <=
+ ra_msg->icmph.icmp6_hop_limit) {
in6_dev->cnf.hop_limit = ra_msg->icmph.icmp6_hop_limit;
if (rt)
dst_metric_set(&rt->dst, RTAX_HOPLIMIT,
ra_msg->icmph.icmp6_hop_limit);
} else {
- ND_PRINTK(2, warn, "RA: Got route advertisement with lower hop_limit than minimum\n");
+ ND_PRINTK(2, warn,
+ "RA: Got route advertisement with lower hop_limit than minimum\n");
}
}
skip_defrtr:
- /*
- * Update Reachable Time and Retrans Timer
- */
+ /* Update Reachable Time and Retrans Timer */
if (in6_dev->nd_parms) {
unsigned long rtime = ntohl(ra_msg->retrans_timer);
- if (rtime && rtime/1000 < MAX_SCHEDULE_TIMEOUT/HZ) {
- rtime = (rtime*HZ)/1000;
- if (rtime < HZ/10)
- rtime = HZ/10;
+ if (rtime && rtime / 1000 < MAX_SCHEDULE_TIMEOUT / HZ) {
+ rtime = (rtime * HZ) / 1000;
+ if (rtime < HZ / 10)
+ rtime = HZ / 10;
NEIGH_VAR_SET(in6_dev->nd_parms, RETRANS_TIME, rtime);
in6_dev->tstamp = jiffies;
send_ifinfo_notify = true;
}
rtime = ntohl(ra_msg->reachable_time);
- if (rtime && rtime/1000 < MAX_SCHEDULE_TIMEOUT/(3*HZ)) {
- rtime = (rtime*HZ)/1000;
+ if (rtime && rtime / 1000 < MAX_SCHEDULE_TIMEOUT / (3 * HZ)) {
+ rtime = (rtime * HZ) / 1000;
- if (rtime < HZ/10)
- rtime = HZ/10;
+ if (rtime < HZ / 10)
+ rtime = HZ / 10;
- if (rtime != NEIGH_VAR(in6_dev->nd_parms, BASE_REACHABLE_TIME)) {
+ if (rtime != NEIGH_VAR(in6_dev->nd_parms,
+ BASE_REACHABLE_TIME)) {
NEIGH_VAR_SET(in6_dev->nd_parms,
BASE_REACHABLE_TIME, rtime);
NEIGH_VAR_SET(in6_dev->nd_parms,
GC_STALETIME, 3 * rtime);
- in6_dev->nd_parms->reachable_time = neigh_rand_reach_time(rtime);
+ in6_dev->nd_parms->reachable_time =
+ neigh_rand_reach_time(rtime);
in6_dev->tstamp = jiffies;
send_ifinfo_notify = true;
}
}
}
- /*
- * Send a notify if RA changed managed/otherconf flags or timer settings
+ /* Send a notify if RA changed managed/otherconf flags
+ * or timer settings
*/
if (send_ifinfo_notify)
inet6_ifinfo_notify(RTM_NEWLINK, in6_dev);
skip_linkparms:
- /*
- * Process options.
- */
+ /* Process options */
if (!neigh)
neigh = __neigh_lookup(&nd_tbl, &ipv6_hdr(skb)->saddr,
skb->dev, 1);
if (neigh) {
u8 *lladdr = NULL;
+
if (ndopts.nd_opts_src_lladdr) {
lladdr = ndisc_opt_addr_data(ndopts.nd_opts_src_lladdr,
skb->dev);
@@ -1380,9 +1384,9 @@ static void ndisc_router_discovery(struct sk_buff *skb)
}
}
ndisc_update(skb->dev, neigh, lladdr, NUD_STALE,
- NEIGH_UPDATE_F_WEAK_OVERRIDE|
- NEIGH_UPDATE_F_OVERRIDE|
- NEIGH_UPDATE_F_OVERRIDE_ISROUTER|
+ NEIGH_UPDATE_F_WEAK_OVERRIDE |
+ NEIGH_UPDATE_F_OVERRIDE |
+ NEIGH_UPDATE_F_OVERRIDE_ISROUTER |
NEIGH_UPDATE_F_ISROUTER,
NDISC_ROUTER_ADVERTISEMENT, &ndopts);
}
@@ -1406,6 +1410,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
if (in6_dev->cnf.accept_ra_rtr_pref && ndopts.nd_opts_ri) {
struct nd_opt_hdr *p;
+
for (p = ndopts.nd_opts_ri;
p;
p = ndisc_next_option(p, ndopts.nd_opts_ri_end)) {
@@ -1418,9 +1423,11 @@ static void ndisc_router_discovery(struct sk_buff *skb)
if (ri->prefix_len == 0 &&
!in6_dev->cnf.accept_ra_defrtr)
continue;
- if (ri->prefix_len < in6_dev->cnf.accept_ra_rt_info_min_plen)
+ if (ri->prefix_len <
+ in6_dev->cnf.accept_ra_rt_info_min_plen)
continue;
- if (ri->prefix_len > in6_dev->cnf.accept_ra_rt_info_max_plen)
+ if (ri->prefix_len >
+ in6_dev->cnf.accept_ra_rt_info_max_plen)
continue;
rt6_route_rcv(skb->dev, (u8 *)p, (p->nd_opt_len) << 3,
&ipv6_hdr(skb)->saddr);
@@ -1442,12 +1449,13 @@ static void ndisc_router_discovery(struct sk_buff *skb)
if (in6_dev->cnf.accept_ra_pinfo && ndopts.nd_opts_pi) {
struct nd_opt_hdr *p;
+
for (p = ndopts.nd_opts_pi;
p;
p = ndisc_next_option(p, ndopts.nd_opts_pi_end)) {
addrconf_prefix_rcv(skb->dev, (u8 *)p,
(p->nd_opt_len) << 3,
- ndopts.nd_opts_src_lladdr != NULL);
+ ndopts.nd_opts_src_lladdr);
}
}
@@ -1455,7 +1463,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
__be32 n;
u32 mtu;
- memcpy(&n, ((u8 *)(ndopts.nd_opts_mtu+1))+2, sizeof(mtu));
+ memcpy(&n, ((u8 *)(ndopts.nd_opts_mtu + 1)) + 2, sizeof(mtu));
mtu = ntohl(n);
if (mtu < IPV6_MIN_MTU || mtu > skb->dev->mtu) {
@@ -1472,6 +1480,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
if (ndopts.nd_useropts) {
struct nd_opt_hdr *p;
+
for (p = ndopts.nd_useropts;
p;
p = ndisc_next_useropt(skb->dev, p,
@@ -1480,9 +1489,9 @@ static void ndisc_router_discovery(struct sk_buff *skb)
}
}
- if (ndopts.nd_opts_tgt_lladdr || ndopts.nd_opts_rh) {
+ if (ndopts.nd_opts_tgt_lladdr || ndopts.nd_opts_rh)
ND_PRINTK(2, warn, "RA: invalid RA options\n");
- }
+
out:
ip6_rt_put(rt);
if (neigh)
@@ -1518,7 +1527,7 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
if (!ndopts.nd_opts_rh) {
ip6_redirect_no_header(skb, dev_net(skb->dev),
- skb->dev->ifindex, 0);
+ skb->dev->ifindex, 0);
return;
}
@@ -1569,7 +1578,8 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
}
if (!ipv6_addr_equal(&ipv6_hdr(skb)->daddr, target) &&
- ipv6_addr_type(target) != (IPV6_ADDR_UNICAST|IPV6_ADDR_LINKLOCAL)) {
+ ipv6_addr_type(target) !=
+ (IPV6_ADDR_UNICAST | IPV6_ADDR_LINKLOCAL)) {
ND_PRINTK(2, warn,
"Redirect: target address is not link-local unicast\n");
return;
@@ -1587,7 +1597,7 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
if (IS_ERR(dst))
return;
- rt = (struct rt6_info *) dst;
+ rt = (struct rt6_info *)dst;
if (rt->rt6i_flags & RTF_GATEWAY) {
ND_PRINTK(2, warn,
@@ -1595,14 +1605,16 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
goto release;
}
peer = inet_getpeer_v6(net->ipv6.peers, &ipv6_hdr(skb)->saddr, 1);
- ret = inet_peer_xrlim_allow(peer, 1*HZ);
+ ret = inet_peer_xrlim_allow(peer, 1 * HZ);
if (peer)
inet_putpeer(peer);
if (!ret)
goto release;
if (dev->addr_len) {
- struct neighbour *neigh = dst_neigh_lookup(skb_dst(skb), target);
+ struct neighbour *neigh =
+ dst_neigh_lookup(skb_dst(skb), target);
+
if (!neigh) {
ND_PRINTK(2, warn,
"Redirect: no neigh for target address\n");
@@ -1617,14 +1629,16 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
optlen += ndisc_redirect_opt_addr_space(dev, neigh,
ops_data_buf,
&ops_data);
- } else
+ } else {
read_unlock_bh(&neigh->lock);
+ }
neigh_release(neigh);
}
rd_len = min_t(unsigned int,
- IPV6_MIN_MTU - sizeof(struct ipv6hdr) - sizeof(*msg) - optlen,
+ IPV6_MIN_MTU - sizeof(struct ipv6hdr) -
+ sizeof(*msg) - optlen,
skb->len + 8);
rd_len &= ~0x7;
optlen += rd_len;
@@ -1642,16 +1656,12 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
.dest = ipv6_hdr(skb)->daddr,
};
- /*
- * include target_address option
- */
+ /* include target_address option */
if (ha)
ndisc_fill_redirect_addr_option(buff, ha, ops_data);
- /*
- * build redirect option and copy skb over to the new packet.
- */
+ /* build redirect option and copy skb over to the new packet */
if (rd_len)
ndisc_fill_redirect_hdr_option(buff, skb, rd_len);
@@ -1737,7 +1747,8 @@ int ndisc_rcv(struct sk_buff *skb)
return 0;
}
-static int ndisc_netdev_event(struct notifier_block *this, unsigned long event, void *ptr)
+static int ndisc_netdev_event(struct notifier_block *this,
+ unsigned long event, void *ptr)
{
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
struct netdev_notifier_change_info *change_info;
@@ -1787,6 +1798,7 @@ static void ndisc_warn_deprecated_sysctl(struct ctl_table *ctl,
{
static char warncomm[TASK_COMM_LEN];
static int warned;
+
if (strcmp(warncomm, current->comm) && warned < 5) {
strcpy(warncomm, current->comm);
pr_warn("process `%s' is using deprecated sysctl (%s) net.ipv6.neigh.%s.%s - use net.ipv6.neigh.%s.%s_ms instead\n",
@@ -1797,7 +1809,8 @@ static void ndisc_warn_deprecated_sysctl(struct ctl_table *ctl,
}
}
-int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
+int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write,
+ void __user *buffer, size_t *lenp, loff_t *ppos)
{
struct net_device *dev = ctl->extra1;
struct inet6_dev *idev;
@@ -1805,7 +1818,8 @@ int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write, void __user *bu
if ((strcmp(ctl->procname, "retrans_time") == 0) ||
(strcmp(ctl->procname, "base_reachable_time") == 0))
- ndisc_warn_deprecated_sysctl(ctl, "syscall", dev ? dev->name : "default");
+ ndisc_warn_deprecated_sysctl(ctl, "syscall",
+ dev ? dev->name : "default");
if (strcmp(ctl->procname, "retrans_time") == 0)
ret = neigh_proc_dointvec(ctl, write, buffer, lenp, ppos);
@@ -1821,18 +1835,22 @@ int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write, void __user *bu
else
ret = -1;
- if (write && ret == 0 && dev && (idev = in6_dev_get(dev)) != NULL) {
- if (ctl->data == &NEIGH_VAR(idev->nd_parms, BASE_REACHABLE_TIME))
+ if (!write || ret || !dev)
+ return ret;
+
+ idev = in6_dev_get(dev);
+ if (idev) {
+ if (ctl->data ==
+ &NEIGH_VAR(idev->nd_parms, BASE_REACHABLE_TIME))
idev->nd_parms->reachable_time =
- neigh_rand_reach_time(NEIGH_VAR(idev->nd_parms, BASE_REACHABLE_TIME));
+ neigh_rand_reach_time(
+ NEIGH_VAR(idev->nd_parms, BASE_REACHABLE_TIME));
idev->tstamp = jiffies;
inet6_ifinfo_notify(RTM_NEWLINK, idev);
in6_dev_put(idev);
}
return ret;
}
-
-
#endif
static int __net_init ndisc_net_init(struct net *net)
@@ -1877,9 +1895,7 @@ int __init ndisc_init(void)
err = register_pernet_subsys(&ndisc_net_ops);
if (err)
return err;
- /*
- * Initialize the neighbour table
- */
+ /* Initialize the neighbour table */
neigh_table_init(NEIGH_ND_TABLE, &nd_tbl);
#ifdef CONFIG_SYSCTL
--
2.7.4
^ permalink raw reply related
* Re: [PATCH net-next] geneve: always fill CSUM6_RX configuration
From: Eric Garver @ 2017-05-20 13:35 UTC (permalink / raw)
To: Pravin Shelar; +Cc: Linux Kernel Network Developers
In-Reply-To: <CAOrHB_CKLgriV3XjG1fBHvyB9GQQ3GXOT8+ggmtLXFz3cvj56Q@mail.gmail.com>
On Fri, May 19, 2017 at 06:57:46PM -0700, Pravin Shelar wrote:
> On Thu, May 18, 2017 at 12:59 PM, Eric Garver <e@erig.me> wrote:
> > CSMU6_RX is relevant for collect_metadata as well. As such leave it
> > outside of the dev's IPv4/IPv6 checks.
> >
> Can you explain it bit? is this flag used with ipv4 tunnels?
It's used with collect_metadata as both ipv4 and ipv6 sockets will be
created.
openvswitch recently gained support for creating tunnels with rtnetlink.
It sets COLLECT_METADATA and CSUM6_RX. After create, it does a get to
verify the device got created with all the requested configuration. The
verify was failing due to CSUM6_RX not being returned.
Since ip_tunnel_info_af() defaults to returning AF_INET, we fall into
the IPv4 case and CSUM6_RX is never returned. Other relevant areas that
call ip_tunnel_info_af() do so using the info from the skb, not the
geneve_dev.
I hope that made it clear. Thanks for taking a look.
Eric.
> > Fixes: 9b4437a5b870 ("geneve: Unify LWT and netdev handling.")
> > Signed-off-by: Eric Garver <e@erig.me>
> > ---
> > drivers/net/geneve.c | 8 ++++----
> > 1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
> > index dec5d563ab19..f557d1dc3f9b 100644
> > --- a/drivers/net/geneve.c
> > +++ b/drivers/net/geneve.c
> > @@ -1311,13 +1311,13 @@ static int geneve_fill_info(struct sk_buff *skb, const struct net_device *dev)
> > if (nla_put_u8(skb, IFLA_GENEVE_UDP_ZERO_CSUM6_TX,
> > !(info->key.tun_flags & TUNNEL_CSUM)))
> > goto nla_put_failure;
> > -
> > - if (nla_put_u8(skb, IFLA_GENEVE_UDP_ZERO_CSUM6_RX,
> > - !geneve->use_udp6_rx_checksums))
> > - goto nla_put_failure;
> > #endif
> > }
> >
> > + if (nla_put_u8(skb, IFLA_GENEVE_UDP_ZERO_CSUM6_RX,
> > + !geneve->use_udp6_rx_checksums))
> > + goto nla_put_failure;
> > +
> > if (nla_put_u8(skb, IFLA_GENEVE_TTL, info->key.ttl) ||
> > nla_put_u8(skb, IFLA_GENEVE_TOS, info->key.tos) ||
> > nla_put_be32(skb, IFLA_GENEVE_LABEL, info->key.label))
> > --
> > 2.12.0
> >
^ permalink raw reply
* [patch net-next 1/2] net/sched: properly assign RCU pointer in tcf_chain_tp_insert/remove
From: Jiri Pirko @ 2017-05-20 13:01 UTC (permalink / raw)
To: netdev
Cc: davem, jhs, xiyou.wangcong, edumazet, daniel, simon.horman, mlxsw,
colin.king
From: Jiri Pirko <jiri@mellanox.com>
*p_filter_chain is rcu-dereferenced on reader path. So here in writer,
property assign the pointer.
Fixes: 2190d1d0944f ("net: sched: introduce helpers to work with filter chains")
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
net/sched/cls_api.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 4020b8d..85088ed 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -351,7 +351,7 @@ static void tcf_chain_tp_insert(struct tcf_chain *chain,
{
if (chain->p_filter_chain &&
*chain_info->pprev == chain->filter_chain)
- *chain->p_filter_chain = tp;
+ rcu_assign_pointer(*chain->p_filter_chain, tp);
RCU_INIT_POINTER(tp->next, tcf_chain_tp_prev(chain_info));
rcu_assign_pointer(*chain_info->pprev, tp);
}
@@ -363,7 +363,7 @@ static void tcf_chain_tp_remove(struct tcf_chain *chain,
struct tcf_proto *next = rtnl_dereference(chain_info->next);
if (chain->p_filter_chain && tp == chain->filter_chain)
- *chain->p_filter_chain = next;
+ RCU_INIT_POINTER(*chain->p_filter_chain, next);
RCU_INIT_POINTER(*chain_info->pprev, next);
}
--
2.9.3
^ permalink raw reply related
* [patch net-next 2/2] net/sched: fix filter flushing
From: Jiri Pirko @ 2017-05-20 13:01 UTC (permalink / raw)
To: netdev
Cc: davem, jhs, xiyou.wangcong, edumazet, daniel, simon.horman, mlxsw,
colin.king
In-Reply-To: <20170520130132.1626-1-jiri@resnulli.us>
From: Jiri Pirko <jiri@mellanox.com>
When user instructs to remove all filters from chain, we cannot destroy
the chain as other actions may hold a reference. Also the put in errout
would try to destroy it again. So instead, just walk the chain and remove
all existing filters.
Fixes: 5bc1701881e3 ("net: sched: introduce multichain support for filters")
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
net/sched/cls_api.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 85088ed..01a8b8b 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -201,15 +201,22 @@ static struct tcf_chain *tcf_chain_create(struct tcf_block *block,
return chain;
}
-static void tcf_chain_destroy(struct tcf_chain *chain)
+static void tcf_chain_flush(struct tcf_chain *chain)
{
struct tcf_proto *tp;
- list_del(&chain->list);
+ if (*chain->p_filter_chain)
+ RCU_INIT_POINTER(*chain->p_filter_chain, NULL);
while ((tp = rtnl_dereference(chain->filter_chain)) != NULL) {
RCU_INIT_POINTER(chain->filter_chain, tp->next);
tcf_proto_destroy(tp);
}
+}
+
+static void tcf_chain_destroy(struct tcf_chain *chain)
+{
+ list_del(&chain->list);
+ tcf_chain_flush(chain);
kfree(chain);
}
@@ -510,7 +517,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
if (n->nlmsg_type == RTM_DELTFILTER && prio == 0) {
tfilter_notify_chain(net, skb, n, chain, RTM_DELTFILTER);
- tcf_chain_destroy(chain);
+ tcf_chain_flush(chain);
err = 0;
goto errout;
}
--
2.9.3
^ permalink raw reply related
* [PATCH net] netfilter: do not hold dev in ipt_CLUSTERIP
From: Xin Long @ 2017-05-20 9:08 UTC (permalink / raw)
To: network dev, netfilter-devel; +Cc: davem, fw
It's a terrible thing to hold dev in iptables target. When the dev is
being removed, unregister_netdevice has to wait for the dev to become
free. dmesg will keep logging the err:
kernel:unregister_netdevice: waiting for veth0_in to become free. \
Usage count = 1
until iptables rules with this target are removed manually.
The worse thing is when deleting a netns, a virtual nic will be deleted
instead of reset to init_net in default_device_ops exit/exit_batch. As
it is earlier than to flush the iptables rules in iptable_filter_net_ops
exit, unregister_netdevice will block to wait for the nic to become free.
As unregister_netdevice is actually waiting for iptables rules flushing
while iptables rules have to be flushed after unregister_netdevice. This
'dead lock' will cause unregister_netdevice to block there forever. As
the netns is not available to operate at that moment, iptables rules can
not even be flushed manually either.
The reproducer can be:
# ip netns add test
# ip link add veth0_in type veth peer name veth0_out
# ip link set veth0_in netns test
# ip netns exec test ip link set lo up
# ip netns exec test ip link set veth0_in up
# ip netns exec test iptables -I INPUT -d 1.2.3.4 -i veth0_in -j \
CLUSTERIP --new --clustermac 89:d4:47:eb:9a:fa --total-nodes 3 \
--local-node 1 --hashmode sourceip-sourceport
# ip netns del test
This issue can be triggered by all virtual nics with ipt_CLUSTERIP.
This patch is to fix it by not holding dev in ipt_CLUSTERIP, but only
save dev->ifindex instead of dev. When removing the mc from the dev,
it will get dev by c->ifindex through dev_get_by_index.
Note that it doesn't save dev->name but dev->ifindex, as a dev->name
can be changed, it will confuse ipt_CLUSTERIP.
Reported-by: Jianlin Shi <jishi@redhat.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
net/ipv4/netfilter/ipt_CLUSTERIP.c | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c
index 038f293..d1adb2f 100644
--- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
+++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
@@ -47,7 +47,7 @@ struct clusterip_config {
__be32 clusterip; /* the IP address */
u_int8_t clustermac[ETH_ALEN]; /* the MAC address */
- struct net_device *dev; /* device */
+ int ifindex; /* device ifindex */
u_int16_t num_total_nodes; /* total number of nodes */
unsigned long local_nodes; /* node number array */
@@ -98,19 +98,23 @@ clusterip_config_put(struct clusterip_config *c)
* entry(rule) is removed, remove the config from lists, but don't free it
* yet, since proc-files could still be holding references */
static inline void
-clusterip_config_entry_put(struct clusterip_config *c)
+clusterip_config_entry_put(struct net *net, struct clusterip_config *c)
{
- struct net *net = dev_net(c->dev);
struct clusterip_net *cn = net_generic(net, clusterip_net_id);
local_bh_disable();
if (refcount_dec_and_lock(&c->entries, &cn->lock)) {
+ struct net_device *dev;
+
list_del_rcu(&c->list);
spin_unlock(&cn->lock);
local_bh_enable();
- dev_mc_del(c->dev, c->clustermac);
- dev_put(c->dev);
+ dev = dev_get_by_index(net, c->ifindex);
+ if (dev) {
+ dev_mc_del(dev, c->clustermac);
+ dev_put(dev);
+ }
/* In case anyone still accesses the file, the open/close
* functions are also incrementing the refcount on their own,
@@ -182,7 +186,7 @@ clusterip_config_init(const struct ipt_clusterip_tgt_info *i, __be32 ip,
if (!c)
return ERR_PTR(-ENOMEM);
- c->dev = dev;
+ c->ifindex = dev->ifindex;
c->clusterip = ip;
memcpy(&c->clustermac, &i->clustermac, ETH_ALEN);
c->num_total_nodes = i->num_total_nodes;
@@ -427,12 +431,14 @@ static int clusterip_tg_check(const struct xt_tgchk_param *par)
}
config = clusterip_config_init(cipinfo,
- e->ip.dst.s_addr, dev);
+ e->ip.dst.s_addr, dev);
if (IS_ERR(config)) {
dev_put(dev);
return PTR_ERR(config);
}
- dev_mc_add(config->dev, config->clustermac);
+
+ dev_mc_add(dev, config->clustermac);
+ dev_put(dev);
}
}
cipinfo->config = config;
@@ -458,7 +464,7 @@ static void clusterip_tg_destroy(const struct xt_tgdtor_param *par)
/* if no more entries are referencing the config, remove it
* from the list and destroy the proc entry */
- clusterip_config_entry_put(cipinfo->config);
+ clusterip_config_entry_put(par->net, cipinfo->config);
clusterip_config_put(cipinfo->config);
@@ -558,10 +564,9 @@ arp_mangle(void *priv,
* addresses on different interfacs. However, in the CLUSTERIP case
* this wouldn't work, since we didn't subscribe the mcast group on
* other interfaces */
- if (c->dev != state->out) {
- pr_debug("not mangling arp reply on different "
- "interface: cip'%s'-skb'%s'\n",
- c->dev->name, state->out->name);
+ if (c->ifindex != state->out->ifindex) {
+ pr_debug("not mangling arp reply on different interface: cip'%d'-skb'%d'\n",
+ c->ifindex, state->out->ifindex);
clusterip_config_put(c);
return NF_ACCEPT;
}
--
2.1.0
^ permalink raw reply related
* Re: [RFC net-next PATCH 3/5] net: introduce XDP driver features interface
From: Jesper Dangaard Brouer @ 2017-05-20 7:53 UTC (permalink / raw)
To: Daniel Borkmann
Cc: Daniel Borkmann, Alexei Starovoitov, John Fastabend, netdev,
brouer
In-Reply-To: <591F27B9.9070003@iogearbox.net>
On Fri, 19 May 2017 19:13:29 +0200
Daniel Borkmann <daniel@iogearbox.net> wrote:
> On 05/18/2017 05:41 PM, Jesper Dangaard Brouer wrote:
> > There is a fundamental difference between normal eBPF programs
> > and (XDP) eBPF programs getting attached in a driver. For normal
> > eBPF programs it is easy to add a new bpf feature, like a bpf
> > helper, because is it strongly tied to the feature being
> > available in the current core kernel code. When drivers invoke a
> > bpf_prog, then it is not sufficient to simply relying on whether
> > a bpf_helper exists or not. When a driver haven't implemented a
> > given feature yet, then it is possible to expose uninitialized
> > parts of xdp_buff. The driver pass in a pointer to xdp_buff,
> > usually "allocated" on the stack, which must not be exposed.
>
> When xdp_buff is being extended, then we should at least zero
> initialize all in-tree users that don't support or populate this
> field, thus that it's not uninitialized memory. Better would be
> to have a way to reject the prog in the first place until it's
> implemented (but further comments on feature bits below).
Going down a path where we need to zero out the xdp_buff looks a lot
like the sk_buff zeroing, which is the top perf cost associated with
SKBs see[1]. XDP is is about not repeating the same issue we had with
the SKB...
[1] https://prototype-kernel.readthedocs.io/en/latest/blogposts/xdp25_eval_generic_xdp_tx.html#analyzing-build-skb-and-memset
> > Only two user visible NETIF_F_XDP_* net_device feature flags are
> > exposed via ethtool (-k) seen as "xdp" and "xdp-partial".
> > The "xdp-partial" is detected when there is not feature equality
> > between kernel and driver, and a netdev_warn is given.
>
> I think having something like a NETIF_F_XDP_BIT for ethtool to
> indicate support as "xdp" is quite useful. Avoids having to grep
> the kernel tree for ndo_xdp callback. ;) A "xdp-partial" would
> still be unclear/confusing to the user whether his program loads
> or doesn't which is the only thing a user (or some loading infra)
> cares about eventually, so one still needs to go trying to load
> the XDP code to see whether that fails for the native case.
Good that we agree on usefulness of the NETIF_F_XDP_BIT. The
"xdp-partial" or "xdp-challenged" is an early indication to the user
that they should complain to the vendor. I tried to keep it simple
towards the user. Do you think every feature bit should be exposed to
userspace?
> > The idea is that XDP_DRV_* feature bits define a contract between
> > the driver and the kernel, giving a reliable way to know that XDP
> > features a driver promised to implement. Thus, knowing what bpf
> > side features are safe to allow.
> >
> > There are 3 levels of features: "required", "devel" and "optional".
> >
> > The motivation is pushing driver vendors forward to support all
> > the new XDP features. Once a given feature bit is moved into
> > the "required" features, the kernel will reject loading XDP
> > program if feature isn't implemented by driver. Features under
> > developement, require help from the bpf infrastrucure to detect
> > when a given helper or direct-access is used, using a bpf_prog
> > bit to mark a need for the feature, and pulling in this bit in
> > the xdp_features_check(). When all drivers have implemented
> > a "devel" feature, it can be moved to the "required" feature and
>
> The problem is that once you add bits markers to bpf_prog like we
> used to do in the past, then as you do in patch 4/5 with the
> xdp_rxhash_needed bit, they will need to be turned /on/ unconditionally
> when a prog has tail calls.
Yes, with tail calls, we have to enable all features. But that is a
good thing, as it forces vendors to quickly implement all features.
And it is no different from moving a feature into the "required" bits,
once all drivers implement it. It is only a limitation for tail calls,
and something we can fix later (for handling this for tail calls).
BPF have some nice features of evaluating the input program
"load-time", which is what I'm taking advantage of as an optimization
here (let use this nice bpf property). It is only tail calls that
cannot evaluate this "load-time". Thus, if you care about tail calls,
supporting intermediate features, we could later fix that by adding a
runtime feature check in the case of tail calls.
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer
^ permalink raw reply
* Re: [PATCH net-next v2] bridge: fix hello and hold timers starting/stopping
From: Hangbin Liu @ 2017-05-20 7:47 UTC (permalink / raw)
To: ivan.vecera
Cc: network dev, David Miller, sashok, Stephen Hemminger, bridge,
Xin Long, Nikolay Aleksandrov
In-Reply-To: <CA+Nub0aY6hjWeg8h2Qgx_c+yazh5WnA1u0D8bDtxChjWXsEHSw@mail.gmail.com>
On Sat, May 20, 2017 at 09:06:16AM +0200, Ivan Vecera wrote:
> 2017-05-20 7:57 GMT+02:00 Hangbin Liu <liuhangbin@gmail.com>:
> > On Fri, May 19, 2017 at 07:30:43PM +0200, Ivan Vecera wrote:
> >> Current bridge code incorrectly handles starting/stopping of hello and
> >> hold timers during STP enable/disable.
> >>
> >> 1. Timers are stopped in br_stp_start() during NO_STP->USER_STP
> >> transition. The timers are already stopped in NO_STP state so
> >> this is confusing no-op.
> >
> > Hi Ivan,
> >
> > Shouldn't we start hello timer in br_stp_start when NO_STP -> BR_KERNEL_STP ?
>
> As Nikolay mentioned, this is fixed by
> https://patchwork.ozlabs.org/patch/764685/
Ah, sorry. My mistake. I only saw xin's patch and your v2 patch. So I mixed
them up and thought this is xin's V2 patch. That's why I wonder we didn't
start hello timer in br_stp_start...
Now I see your v1 patch with:
The patch is a follow-up for "bridge: start hello_timer when enabling
KERNEL_STP in br_stp_start" patch from Xin Long."
Sorry for mixed them up.
>
> >>
> >> 2. During USER_STP->NO_STP transition the timers are started. This
> >> does not make sense and is confusion because the timer should not be
> >> active in NO_STP state.
> >
> > Yes, but what about BR_KERNEL_STP -> NO_STP in function br_stp_stop() ?
>
> The timer is lazily stopped by itself in its handler... or not rearmed
> respectively.
Yes, with xin's patch this timer will stoped by itself.
Thanks
Hangbin
^ permalink raw reply
* Re: [PATCH] net: sched: fix a use-after-free error on chain on the error exit path
From: Jiri Pirko @ 2017-05-20 7:13 UTC (permalink / raw)
To: Cong Wang
Cc: Colin King, Jamal Hadi Salim, David S . Miller,
Linux Kernel Network Developers, kernel-janitors, LKML
In-Reply-To: <CAM_iQpX+aSOK8+K5eU1s=2LJzZgBdCvWBkhuT3ByZSqKWpSSvw@mail.gmail.com>
Fri, May 19, 2017 at 07:17:59PM CEST, xiyou.wangcong@gmail.com wrote:
>On Thu, May 18, 2017 at 7:07 AM, Colin King <colin.king@canonical.com> wrote:
>> diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
>> index 4020b8d932a1..82ebdc3fcb2e 100644
>> --- a/net/sched/cls_api.c
>> +++ b/net/sched/cls_api.c
>> @@ -511,6 +511,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
>> if (n->nlmsg_type == RTM_DELTFILTER && prio == 0) {
>> tfilter_notify_chain(net, skb, n, chain, RTM_DELTFILTER);
>> tcf_chain_destroy(chain);
>
>
>Jiri, how does this work...? An action could hold a refcnt to a filter
>chain, but here you destroy a whole chain without respecting
>the refcnt???
Correct. I missed this. Will fix, thanks.
>
>
>> + chain = NULL;
>> err = 0;
>> goto errout;
>
>Colin, not your fault, I think we may miss something more serious
>when reviewing Jiri's patchset. ;)
>
>Thanks.
^ permalink raw reply
* Re: [PATCH net-next v2] bridge: fix hello and hold timers starting/stopping
From: Ivan Vecera @ 2017-05-20 7:06 UTC (permalink / raw)
To: Hangbin Liu
Cc: Xin Long, Nikolay Aleksandrov, network dev, bridge, David Miller
In-Reply-To: <20170520055720.GA12974@leo.usersys.redhat.com>
2017-05-20 7:57 GMT+02:00 Hangbin Liu <liuhangbin@gmail.com>:
> On Fri, May 19, 2017 at 07:30:43PM +0200, Ivan Vecera wrote:
>> Current bridge code incorrectly handles starting/stopping of hello and
>> hold timers during STP enable/disable.
>>
>> 1. Timers are stopped in br_stp_start() during NO_STP->USER_STP
>> transition. The timers are already stopped in NO_STP state so
>> this is confusing no-op.
>
> Hi Ivan,
>
> Shouldn't we start hello timer in br_stp_start when NO_STP -> BR_KERNEL_STP ?
As Nikolay mentioned, this is fixed by
https://patchwork.ozlabs.org/patch/764685/
>>
>> 2. During USER_STP->NO_STP transition the timers are started. This
>> does not make sense and is confusion because the timer should not be
>> active in NO_STP state.
>
> Yes, but what about BR_KERNEL_STP -> NO_STP in function br_stp_stop() ?
The timer is lazily stopped by itself in its handler... or not rearmed
respectively.
>> Cc: davem@davemloft.net
>> Cc: sashok@cumulusnetworks.com
>> Cc: stephen@networkplumber.org
>> Cc: bridge@lists.linux-foundation.org
>> Cc: lucien.xin@gmail.com
>> Cc: nikolay@cumulusnetworks.com
>> Signed-off-by: Ivan Vecera <cera@cera.cz>
>> ---
>> net/bridge/br_stp_if.c | 11 -----------
>> 1 file changed, 11 deletions(-)
>>
>> diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
>> index 08341d2aa9c9..a05027027513 100644
>> --- a/net/bridge/br_stp_if.c
>> +++ b/net/bridge/br_stp_if.c
>> @@ -150,7 +150,6 @@ static int br_stp_call_user(struct net_bridge *br, char *arg)
>>
>> static void br_stp_start(struct net_bridge *br)
>> {
>> - struct net_bridge_port *p;
>> int err = -ENOENT;
>>
>> if (net_eq(dev_net(br->dev), &init_net))
>> @@ -169,11 +168,6 @@ static void br_stp_start(struct net_bridge *br)
>> if (!err) {
>> br->stp_enabled = BR_USER_STP;
>> br_debug(br, "userspace STP started\n");
>> -
>> - /* Stop hello and hold timers */
>> - del_timer(&br->hello_timer);
>> - list_for_each_entry(p, &br->port_list, list)
>> - del_timer(&p->hold_timer);
>
> I'm not sure if user space daemon will send bpdu or not? In comment
> 76b91c32dd86 ("bridge: stp: when using userspace stp stop kernel hello and
> hold timers"). Nikolay said we should not handle it with BR_USER_STP.
>
>> } else {
>> br->stp_enabled = BR_KERNEL_STP;
>> br_debug(br, "using kernel STP\n");
>> @@ -187,7 +181,6 @@ static void br_stp_start(struct net_bridge *br)
>>
>> static void br_stp_stop(struct net_bridge *br)
>> {
>> - struct net_bridge_port *p;
>> int err;
>>
>> if (br->stp_enabled == BR_USER_STP) {
>> @@ -196,10 +189,6 @@ static void br_stp_stop(struct net_bridge *br)
>> br_err(br, "failed to stop userspace STP (%d)\n", err);
>>
>> /* To start timers on any ports left in blocking */
>> - mod_timer(&br->hello_timer, jiffies + br->hello_time);
>> - list_for_each_entry(p, &br->port_list, list)
>> - mod_timer(&p->hold_timer,
>> - round_jiffies(jiffies + BR_HOLD_TIME));
>
> If we do not del hello_timer. after it expired in br_hello_timer_expired(),
> Our state is br->dev->flags & IFF_UP and br->stp_enabled == NO_STP, it will
> call mod_timer(&br->hello_timer, round_jiffies(jiffies + br->hello_time))
> and we will keep sending bpdu message even after stp stoped.
>
>> spin_lock_bh(&br->lock);
>> br_port_state_selection(br);
>> spin_unlock_bh(&br->lock);
>> --
>
> So how about just like
>
> diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
> index d8ad73b..0198f62 100644
> --- a/net/bridge/br_stp_if.c
> +++ b/net/bridge/br_stp_if.c
> @@ -183,6 +183,7 @@ static void br_stp_start(struct net_bridge *br)
> } else {
> br->stp_enabled = BR_KERNEL_STP;
> br_debug(br, "using kernel STP\n");
> + mod_timer(&br->hello_timer, jiffies + br->hello_time);
>
> /* To start timers on any ports left in blocking */
> br_port_state_selection(br);
> @@ -202,7 +203,6 @@ static void br_stp_stop(struct net_bridge *br)
> br_err(br, "failed to stop userspace STP (%d)\n", err);
>
> /* To start timers on any ports left in blocking */
> - mod_timer(&br->hello_timer, jiffies + br->hello_time);
> list_for_each_entry(p, &br->port_list, list)
> mod_timer(&p->hold_timer,
> round_jiffies(jiffies + BR_HOLD_TIME));
> @@ -211,6 +211,7 @@ static void br_stp_stop(struct net_bridge *br)
> spin_unlock_bh(&br->lock);
> }
>
> + del_timer_sync(&br->hello_timer);
> br->stp_enabled = BR_NO_STP;
> }
>
> Thanks
> Hangbin
^ permalink raw reply
* Re: [PATCH net-next v2] bridge: fix hello and hold timers starting/stopping
From: Nikolay Aleksandrov @ 2017-05-20 6:55 UTC (permalink / raw)
To: Hangbin Liu, Ivan Vecera; +Cc: lucien.xin, netdev, bridge, davem
In-Reply-To: <20170520055720.GA12974@leo.usersys.redhat.com>
On 5/20/17 8:57 AM, Hangbin Liu wrote:
> On Fri, May 19, 2017 at 07:30:43PM +0200, Ivan Vecera wrote:
>> Current bridge code incorrectly handles starting/stopping of hello and
>> hold timers during STP enable/disable.
>>
>> 1. Timers are stopped in br_stp_start() during NO_STP->USER_STP
>> transition. The timers are already stopped in NO_STP state so
>> this is confusing no-op.
>
> Hi Ivan,
>
> Shouldn't we start hello timer in br_stp_start when NO_STP -> BR_KERNEL_STP ?
Please see Xin Long's recent -net patch that fixes exactly this issue.
It will answer your questions below, too.
https://patchwork.ozlabs.org/patch/764685/
>>
>> 2. During USER_STP->NO_STP transition the timers are started. This
>> does not make sense and is confusion because the timer should not be
>> active in NO_STP state.
>
> Yes, but what about BR_KERNEL_STP -> NO_STP in function br_stp_stop() ?
>>
>> Cc: davem@davemloft.net
>> Cc: sashok@cumulusnetworks.com
>> Cc: stephen@networkplumber.org
>> Cc: bridge@lists.linux-foundation.org
>> Cc: lucien.xin@gmail.com
>> Cc: nikolay@cumulusnetworks.com
>> Signed-off-by: Ivan Vecera <cera@cera.cz>
>> ---
>> net/bridge/br_stp_if.c | 11 -----------
>> 1 file changed, 11 deletions(-)
>>
>> diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
>> index 08341d2aa9c9..a05027027513 100644
>> --- a/net/bridge/br_stp_if.c
>> +++ b/net/bridge/br_stp_if.c
>> @@ -150,7 +150,6 @@ static int br_stp_call_user(struct net_bridge *br, char *arg)
>>
>> static void br_stp_start(struct net_bridge *br)
>> {
>> - struct net_bridge_port *p;
>> int err = -ENOENT;
>>
>> if (net_eq(dev_net(br->dev), &init_net))
>> @@ -169,11 +168,6 @@ static void br_stp_start(struct net_bridge *br)
>> if (!err) {
>> br->stp_enabled = BR_USER_STP;
>> br_debug(br, "userspace STP started\n");
>> -
>> - /* Stop hello and hold timers */
>> - del_timer(&br->hello_timer);
>> - list_for_each_entry(p, &br->port_list, list)
>> - del_timer(&p->hold_timer);
>
> I'm not sure if user space daemon will send bpdu or not? In comment
> 76b91c32dd86 ("bridge: stp: when using userspace stp stop kernel hello and
> hold timers"). Nikolay said we should not handle it with BR_USER_STP >
>> } else {
>> br->stp_enabled = BR_KERNEL_STP;
>> br_debug(br, "using kernel STP\n");
>> @@ -187,7 +181,6 @@ static void br_stp_start(struct net_bridge *br)
>>
>> static void br_stp_stop(struct net_bridge *br)
>> {
>> - struct net_bridge_port *p;
>> int err;
>>
>> if (br->stp_enabled == BR_USER_STP) {
>> @@ -196,10 +189,6 @@ static void br_stp_stop(struct net_bridge *br)
>> br_err(br, "failed to stop userspace STP (%d)\n", err);
>>
>> /* To start timers on any ports left in blocking */
>> - mod_timer(&br->hello_timer, jiffies + br->hello_time);
>> - list_for_each_entry(p, &br->port_list, list)
>> - mod_timer(&p->hold_timer,
>> - round_jiffies(jiffies + BR_HOLD_TIME));
>
> If we do not del hello_timer. after it expired in br_hello_timer_expired(),
> Our state is br->dev->flags & IFF_UP and br->stp_enabled == NO_STP, it will
> call mod_timer(&br->hello_timer, round_jiffies(jiffies + br->hello_time))
> and we will keep sending bpdu message even after stp stoped.
Again see Xin Long's recent -net patch.
>
>> spin_lock_bh(&br->lock);
>> br_port_state_selection(br);
>> spin_unlock_bh(&br->lock);
>> --
>
> So how about just like
>
> diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
> index d8ad73b..0198f62 100644
> --- a/net/bridge/br_stp_if.c
> +++ b/net/bridge/br_stp_if.c
> @@ -183,6 +183,7 @@ static void br_stp_start(struct net_bridge *br)
> } else {
> br->stp_enabled = BR_KERNEL_STP;
> br_debug(br, "using kernel STP\n");
> + mod_timer(&br->hello_timer, jiffies + br->hello_time);
>
> /* To start timers on any ports left in blocking */
> br_port_state_selection(br);
> @@ -202,7 +203,6 @@ static void br_stp_stop(struct net_bridge *br)
> br_err(br, "failed to stop userspace STP (%d)\n", err);
>
> /* To start timers on any ports left in blocking */
> - mod_timer(&br->hello_timer, jiffies + br->hello_time);
> list_for_each_entry(p, &br->port_list, list)
> mod_timer(&p->hold_timer,
> round_jiffies(jiffies + BR_HOLD_TIME));
> @@ -211,6 +211,7 @@ static void br_stp_stop(struct net_bridge *br)
> spin_unlock_bh(&br->lock);
> }
>
> + del_timer_sync(&br->hello_timer);
> br->stp_enabled = BR_NO_STP;
> }
>
> Thanks
> Hangbin
>
^ permalink raw reply
* Re: [PATCH net-next 6/9] xfrm: make xfrm_dev_register static
From: Steffen Klassert @ 2017-05-20 6:48 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: davem, netdev, Stephen Hemminger
In-Reply-To: <20170519165556.483-7-sthemmin@microsoft.com>
On Fri, May 19, 2017 at 09:55:53AM -0700, Stephen Hemminger wrote:
> This function is only used in this file and should not be global.
>
> Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
> ---
> net/xfrm/xfrm_device.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/xfrm/xfrm_device.c b/net/xfrm/xfrm_device.c
> index 8ec8a3fcf8d4..50ec73399b48 100644
> --- a/net/xfrm/xfrm_device.c
> +++ b/net/xfrm/xfrm_device.c
> @@ -138,7 +138,7 @@ bool xfrm_dev_offload_ok(struct sk_buff *skb, struct xfrm_state *x)
> }
> EXPORT_SYMBOL_GPL(xfrm_dev_offload_ok);
>
> -int xfrm_dev_register(struct net_device *dev)
> +static int xfrm_dev_register(struct net_device *dev)
I've applied a patch with this exact fix already to the
ipsec-next tree yesterday.
^ permalink raw reply
* Re: [PATCH net-next v2] bridge: fix hello and hold timers starting/stopping
From: Hangbin Liu @ 2017-05-20 5:57 UTC (permalink / raw)
To: Ivan Vecera; +Cc: netdev, davem, sashok, stephen, bridge, lucien.xin, nikolay
In-Reply-To: <20170519173043.10201-1-cera@cera.cz>
On Fri, May 19, 2017 at 07:30:43PM +0200, Ivan Vecera wrote:
> Current bridge code incorrectly handles starting/stopping of hello and
> hold timers during STP enable/disable.
>
> 1. Timers are stopped in br_stp_start() during NO_STP->USER_STP
> transition. The timers are already stopped in NO_STP state so
> this is confusing no-op.
Hi Ivan,
Shouldn't we start hello timer in br_stp_start when NO_STP -> BR_KERNEL_STP ?
>
> 2. During USER_STP->NO_STP transition the timers are started. This
> does not make sense and is confusion because the timer should not be
> active in NO_STP state.
Yes, but what about BR_KERNEL_STP -> NO_STP in function br_stp_stop() ?
>
> Cc: davem@davemloft.net
> Cc: sashok@cumulusnetworks.com
> Cc: stephen@networkplumber.org
> Cc: bridge@lists.linux-foundation.org
> Cc: lucien.xin@gmail.com
> Cc: nikolay@cumulusnetworks.com
> Signed-off-by: Ivan Vecera <cera@cera.cz>
> ---
> net/bridge/br_stp_if.c | 11 -----------
> 1 file changed, 11 deletions(-)
>
> diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
> index 08341d2aa9c9..a05027027513 100644
> --- a/net/bridge/br_stp_if.c
> +++ b/net/bridge/br_stp_if.c
> @@ -150,7 +150,6 @@ static int br_stp_call_user(struct net_bridge *br, char *arg)
>
> static void br_stp_start(struct net_bridge *br)
> {
> - struct net_bridge_port *p;
> int err = -ENOENT;
>
> if (net_eq(dev_net(br->dev), &init_net))
> @@ -169,11 +168,6 @@ static void br_stp_start(struct net_bridge *br)
> if (!err) {
> br->stp_enabled = BR_USER_STP;
> br_debug(br, "userspace STP started\n");
> -
> - /* Stop hello and hold timers */
> - del_timer(&br->hello_timer);
> - list_for_each_entry(p, &br->port_list, list)
> - del_timer(&p->hold_timer);
I'm not sure if user space daemon will send bpdu or not? In comment
76b91c32dd86 ("bridge: stp: when using userspace stp stop kernel hello and
hold timers"). Nikolay said we should not handle it with BR_USER_STP.
> } else {
> br->stp_enabled = BR_KERNEL_STP;
> br_debug(br, "using kernel STP\n");
> @@ -187,7 +181,6 @@ static void br_stp_start(struct net_bridge *br)
>
> static void br_stp_stop(struct net_bridge *br)
> {
> - struct net_bridge_port *p;
> int err;
>
> if (br->stp_enabled == BR_USER_STP) {
> @@ -196,10 +189,6 @@ static void br_stp_stop(struct net_bridge *br)
> br_err(br, "failed to stop userspace STP (%d)\n", err);
>
> /* To start timers on any ports left in blocking */
> - mod_timer(&br->hello_timer, jiffies + br->hello_time);
> - list_for_each_entry(p, &br->port_list, list)
> - mod_timer(&p->hold_timer,
> - round_jiffies(jiffies + BR_HOLD_TIME));
If we do not del hello_timer. after it expired in br_hello_timer_expired(),
Our state is br->dev->flags & IFF_UP and br->stp_enabled == NO_STP, it will
call mod_timer(&br->hello_timer, round_jiffies(jiffies + br->hello_time))
and we will keep sending bpdu message even after stp stoped.
> spin_lock_bh(&br->lock);
> br_port_state_selection(br);
> spin_unlock_bh(&br->lock);
> --
So how about just like
diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
index d8ad73b..0198f62 100644
--- a/net/bridge/br_stp_if.c
+++ b/net/bridge/br_stp_if.c
@@ -183,6 +183,7 @@ static void br_stp_start(struct net_bridge *br)
} else {
br->stp_enabled = BR_KERNEL_STP;
br_debug(br, "using kernel STP\n");
+ mod_timer(&br->hello_timer, jiffies + br->hello_time);
/* To start timers on any ports left in blocking */
br_port_state_selection(br);
@@ -202,7 +203,6 @@ static void br_stp_stop(struct net_bridge *br)
br_err(br, "failed to stop userspace STP (%d)\n", err);
/* To start timers on any ports left in blocking */
- mod_timer(&br->hello_timer, jiffies + br->hello_time);
list_for_each_entry(p, &br->port_list, list)
mod_timer(&p->hold_timer,
round_jiffies(jiffies + BR_HOLD_TIME));
@@ -211,6 +211,7 @@ static void br_stp_stop(struct net_bridge *br)
spin_unlock_bh(&br->lock);
}
+ del_timer_sync(&br->hello_timer);
br->stp_enabled = BR_NO_STP;
}
Thanks
Hangbin
^ permalink raw reply related
* [PATCH v2 net-next] net: ipv6: fix code style error and warning of ndisc.c
From: yuan linyu @ 2017-05-20 4:20 UTC (permalink / raw)
To: netdev; +Cc: David S . Miller, yuan linyu
From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
Signed-off-by: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
---
net/ipv6/ndisc.c | 300 ++++++++++++++++++++++++++++---------------------------
1 file changed, 155 insertions(+), 145 deletions(-)
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index d310dc4..5a3dfaa 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -12,8 +12,7 @@
* 2 of the License, or (at your option) any later version.
*/
-/*
- * Changes:
+/* Changes:
*
* Alexey I. Froloff : RFC6106 (DNSSL) support
* Pierre Ynard : export userland ND options
@@ -99,7 +98,6 @@ static const struct neigh_ops ndisc_hh_ops = {
.connected_output = neigh_resolve_output,
};
-
static const struct neigh_ops ndisc_direct_ops = {
.family = AF_INET6,
.output = neigh_direct_output,
@@ -147,13 +145,13 @@ void __ndisc_fill_addr_option(struct sk_buff *skb, int type, void *data,
u8 *opt = skb_put(skb, space);
opt[0] = type;
- opt[1] = space>>3;
+ opt[1] = space >> 3;
memset(opt + 2, 0, pad);
opt += pad;
space -= pad;
- memcpy(opt+2, data, data_len);
+ memcpy(opt + 2, data, data_len);
data_len += 2;
opt += data_len;
space -= data_len;
@@ -182,6 +180,7 @@ static struct nd_opt_hdr *ndisc_next_option(struct nd_opt_hdr *cur,
struct nd_opt_hdr *end)
{
int type;
+
if (!cur || !end || cur >= end)
return NULL;
type = cur->nd_opt_type;
@@ -222,6 +221,7 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
memset(ndopts, 0, sizeof(*ndopts));
while (opt_len) {
int l;
+
if (opt_len < sizeof(struct nd_opt_hdr))
return NULL;
l = nd_opt->nd_opt_len << 3;
@@ -240,13 +240,15 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
"%s: duplicated ND6 option found: type=%d\n",
__func__, nd_opt->nd_opt_type);
} else {
- ndopts->nd_opt_array[nd_opt->nd_opt_type] = nd_opt;
+ ndopts->nd_opt_array[nd_opt->nd_opt_type] =
+ nd_opt;
}
break;
case ND_OPT_PREFIX_INFO:
ndopts->nd_opts_pi_end = nd_opt;
if (!ndopts->nd_opt_array[nd_opt->nd_opt_type])
- ndopts->nd_opt_array[nd_opt->nd_opt_type] = nd_opt;
+ ndopts->nd_opt_array[nd_opt->nd_opt_type] =
+ nd_opt;
break;
#ifdef CONFIG_IPV6_ROUTE_INFO
case ND_OPT_ROUTE_INFO:
@@ -261,8 +263,7 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
if (!ndopts->nd_useropts)
ndopts->nd_useropts = nd_opt;
} else {
- /*
- * Unknown options must be silently ignored,
+ /* Unknown options must be silently ignored,
* to accommodate future extension to the
* protocol.
*/
@@ -280,7 +281,8 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
return ndopts;
}
-int ndisc_mc_map(const struct in6_addr *addr, char *buf, struct net_device *dev, int dir)
+int ndisc_mc_map(const struct in6_addr *addr, char *buf,
+ struct net_device *dev, int dir)
{
switch (dev->type) {
case ARPHRD_ETHER:
@@ -327,9 +329,8 @@ static int ndisc_constructor(struct neighbour *neigh)
bool is_multicast = ipv6_addr_is_multicast(addr);
in6_dev = in6_dev_get(dev);
- if (!in6_dev) {
+ if (!in6_dev)
return -EINVAL;
- }
parms = in6_dev->nd_parms;
__neigh_parms_put(neigh->parms);
@@ -344,12 +345,12 @@ static int ndisc_constructor(struct neighbour *neigh)
if (is_multicast) {
neigh->nud_state = NUD_NOARP;
ndisc_mc_map(addr, neigh->ha, dev, 1);
- } else if (dev->flags&(IFF_NOARP|IFF_LOOPBACK)) {
+ } else if (dev->flags & (IFF_NOARP | IFF_LOOPBACK)) {
neigh->nud_state = NUD_NOARP;
memcpy(neigh->ha, dev->dev_addr, dev->addr_len);
- if (dev->flags&IFF_LOOPBACK)
+ if (dev->flags & IFF_LOOPBACK)
neigh->type = RTN_LOCAL;
- } else if (dev->flags&IFF_POINTOPOINT) {
+ } else if (dev->flags & IFF_POINTOPOINT) {
neigh->nud_state = NUD_NOARP;
memcpy(neigh->ha, dev->broadcast, dev->addr_len);
}
@@ -357,7 +358,7 @@ static int ndisc_constructor(struct neighbour *neigh)
neigh->ops = &ndisc_hh_ops;
else
neigh->ops = &ndisc_generic_ops;
- if (neigh->nud_state&NUD_VALID)
+ if (neigh->nud_state & NUD_VALID)
neigh->output = neigh->ops->connected_output;
else
neigh->output = neigh->ops->output;
@@ -512,7 +513,8 @@ void ndisc_send_na(struct net_device *dev, const struct in6_addr *daddr,
in6_ifa_put(ifp);
} else {
if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
- inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
+ inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->
+ srcprefs,
&tmpaddr))
return;
src_addr = &tmpaddr;
@@ -580,7 +582,7 @@ void ndisc_send_ns(struct net_device *dev, const struct in6_addr *solicit,
if (!saddr) {
if (ipv6_get_lladdr(dev, &addr_buf,
- (IFA_F_TENTATIVE|IFA_F_OPTIMISTIC)))
+ (IFA_F_TENTATIVE | IFA_F_OPTIMISTIC)))
return;
saddr = &addr_buf;
}
@@ -629,8 +631,7 @@ void ndisc_send_rs(struct net_device *dev, const struct in6_addr *saddr,
int optlen = 0;
#ifdef CONFIG_IPV6_OPTIMISTIC_DAD
- /*
- * According to section 2.2 of RFC 4429, we must not
+ /* According to section 2.2 of RFC 4429, we must not
* send router solicitations with a sllao from
* optimistic addresses, but we may send the solicitation
* if we don't include the sllao. So here we check
@@ -641,9 +642,8 @@ void ndisc_send_rs(struct net_device *dev, const struct in6_addr *saddr,
struct inet6_ifaddr *ifp = ipv6_get_ifaddr(dev_net(dev), saddr,
dev, 1);
if (ifp) {
- if (ifp->flags & IFA_F_OPTIMISTIC) {
+ if (ifp->flags & IFA_F_OPTIMISTIC)
send_sllao = 0;
- }
in6_ifa_put(ifp);
} else {
send_sllao = 0;
@@ -672,11 +672,9 @@ void ndisc_send_rs(struct net_device *dev, const struct in6_addr *saddr,
ndisc_send_skb(skb, daddr, saddr);
}
-
static void ndisc_error_report(struct neighbour *neigh, struct sk_buff *skb)
{
- /*
- * "The sender MUST return an ICMP
+ /* "The sender MUST return an ICMP
* destination unreachable"
*/
dst_link_failure(skb);
@@ -695,7 +693,7 @@ static void ndisc_solicit(struct neighbour *neigh, struct sk_buff *skb)
if (skb && ipv6_chk_addr_and_flags(dev_net(dev), &ipv6_hdr(skb)->saddr,
dev, 1,
- IFA_F_TENTATIVE|IFA_F_OPTIMISTIC))
+ IFA_F_TENTATIVE | IFA_F_OPTIMISTIC))
saddr = &ipv6_hdr(skb)->saddr;
probes -= NEIGH_VAR(neigh->parms, UCAST_PROBES);
if (probes < 0) {
@@ -705,11 +703,14 @@ static void ndisc_solicit(struct neighbour *neigh, struct sk_buff *skb)
__func__, target);
}
ndisc_send_ns(dev, target, target, saddr, 0);
- } else if ((probes -= NEIGH_VAR(neigh->parms, APP_PROBES)) < 0) {
- neigh_app_ns(neigh);
} else {
- addrconf_addr_solict_mult(target, &mcaddr);
- ndisc_send_ns(dev, target, &mcaddr, saddr, 0);
+ probes -= NEIGH_VAR(neigh->parms, APP_PROBES);
+ if (probes < 0) {
+ neigh_app_ns(neigh);
+ } else {
+ addrconf_addr_solict_mult(target, &mcaddr);
+ ndisc_send_ns(dev, target, &mcaddr, saddr, 0);
+ }
}
}
@@ -765,8 +766,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
return;
}
- /*
- * RFC2461 7.1.1:
+ /* RFC2461 7.1.1:
* DAD has to be destined for solicited node multicast address.
*/
if (dad && !ipv6_addr_is_solict_mult(daddr)) {
@@ -806,7 +806,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
ifp = ipv6_get_ifaddr(dev_net(dev), &msg->target, dev, 1);
if (ifp) {
have_ifp:
- if (ifp->flags & (IFA_F_TENTATIVE|IFA_F_OPTIMISTIC)) {
+ if (ifp->flags & (IFA_F_TENTATIVE | IFA_F_OPTIMISTIC)) {
if (dad) {
if (nonce != 0 && ifp->dad_nonce == nonce) {
u8 *np = (u8 *)&nonce;
@@ -817,23 +817,21 @@ static void ndisc_recv_ns(struct sk_buff *skb)
&ifp->addr, np);
goto out;
}
- /*
- * We are colliding with another node
+ /* We are colliding with another node
* who is doing DAD
* so fail our DAD process
*/
addrconf_dad_failure(ifp);
return;
- } else {
- /*
- * This is not a dad solicitation.
- * If we are an optimistic node,
- * we should respond.
- * Otherwise, we should ignore it.
- */
- if (!(ifp->flags & IFA_F_OPTIMISTIC))
- goto out;
}
+
+ /* This is not a dad solicitation.
+ * If we are an optimistic node,
+ * we should respond.
+ * Otherwise, we should ignore it.
+ */
+ if (!(ifp->flags & IFA_F_OPTIMISTIC))
+ goto out;
}
idev = ifp->idev;
@@ -846,7 +844,8 @@ static void ndisc_recv_ns(struct sk_buff *skb)
mdev = netdev_master_upper_dev_get_rcu(dev);
if (mdev) {
- ifp = ipv6_get_ifaddr(net, &msg->target, mdev, 1);
+ ifp = ipv6_get_ifaddr(net, &msg->target,
+ mdev, 1);
if (ifp)
goto have_ifp;
}
@@ -858,28 +857,31 @@ static void ndisc_recv_ns(struct sk_buff *skb)
return;
}
+ is_router = pndisc_is_router(&msg->target, dev);
if (ipv6_chk_acast_addr(net, dev, &msg->target) ||
(idev->cnf.forwarding &&
- (net->ipv6.devconf_all->proxy_ndp || idev->cnf.proxy_ndp) &&
- (is_router = pndisc_is_router(&msg->target, dev)) >= 0)) {
+ (net->ipv6.devconf_all->proxy_ndp ||
+ idev->cnf.proxy_ndp) && is_router >= 0)) {
if (!(NEIGH_CB(skb)->flags & LOCALLY_ENQUEUED) &&
skb->pkt_type != PACKET_HOST &&
inc &&
NEIGH_VAR(idev->nd_parms, PROXY_DELAY) != 0) {
- /*
- * for anycast or proxy,
+ /* for anycast or proxy,
* sender should delay its response
* by a random time between 0 and
* MAX_ANYCAST_DELAY_TIME seconds.
* (RFC2461) -- yoshfuji
*/
struct sk_buff *n = skb_clone(skb, GFP_ATOMIC);
+
if (n)
- pneigh_enqueue(&nd_tbl, idev->nd_parms, n);
+ pneigh_enqueue(&nd_tbl,
+ idev->nd_parms, n);
goto out;
}
- } else
+ } else {
goto out;
+ }
}
if (is_router < 0)
@@ -887,7 +889,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
if (dad) {
ndisc_send_na(dev, &in6addr_linklocal_allnodes, &msg->target,
- !!is_router, false, (ifp != NULL), true);
+ !!is_router, false, ifp, true);
goto out;
}
@@ -896,20 +898,19 @@ static void ndisc_recv_ns(struct sk_buff *skb)
else
NEIGH_CACHE_STAT_INC(&nd_tbl, rcv_probes_ucast);
- /*
- * update / create cache entry
+ /* update / create cache entry
* for the source address
*/
neigh = __neigh_lookup(&nd_tbl, saddr, dev,
!inc || lladdr || !dev->addr_len);
if (neigh)
ndisc_update(dev, neigh, lladdr, NUD_STALE,
- NEIGH_UPDATE_F_WEAK_OVERRIDE|
+ NEIGH_UPDATE_F_WEAK_OVERRIDE |
NEIGH_UPDATE_F_OVERRIDE,
NDISC_NEIGHBOUR_SOLICITATION, &ndopts);
if (neigh || !dev->header_ops) {
ndisc_send_na(dev, saddr, &msg->target, !!is_router,
- true, (ifp != NULL && inc), inc);
+ true, (ifp && inc), inc);
if (neigh)
neigh_release(neigh);
}
@@ -973,19 +974,19 @@ static void ndisc_recv_na(struct sk_buff *skb)
}
ifp = ipv6_get_ifaddr(dev_net(dev), &msg->target, dev, 1);
if (ifp) {
- if (skb->pkt_type != PACKET_LOOPBACK
- && (ifp->flags & IFA_F_TENTATIVE)) {
- addrconf_dad_failure(ifp);
- return;
+ if (skb->pkt_type != PACKET_LOOPBACK &&
+ (ifp->flags & IFA_F_TENTATIVE)) {
+ addrconf_dad_failure(ifp);
+ return;
}
/* What should we make now? The advertisement
- is invalid, but ndisc specs say nothing
- about it. It could be misconfiguration, or
- an smart proxy agent tries to help us :-)
-
- We should not print the error if NA has been
- received from loopback - it is just our own
- unsolicited advertisement.
+ * is invalid, but ndisc specs say nothing
+ * about it. It could be misconfiguration, or
+ * an smart proxy agent tries to help us :-)
+ *
+ * We should not print the error if NA has been
+ * received from loopback - it is just our own
+ * unsolicited advertisement.
*/
if (skb->pkt_type != PACKET_LOOPBACK)
ND_PRINTK(1, warn,
@@ -1003,30 +1004,31 @@ static void ndisc_recv_na(struct sk_buff *skb)
if (neigh->nud_state & NUD_FAILED)
goto out;
- /*
- * Don't update the neighbor cache entry on a proxy NA from
+ /* Don't update the neighbor cache entry on a proxy NA from
* ourselves because either the proxied node is off link or it
* has already sent a NA to us.
*/
if (lladdr && !memcmp(lladdr, dev->dev_addr, dev->addr_len) &&
- net->ipv6.devconf_all->forwarding && net->ipv6.devconf_all->proxy_ndp &&
+ net->ipv6.devconf_all->forwarding &&
+ net->ipv6.devconf_all->proxy_ndp &&
pneigh_lookup(&nd_tbl, net, &msg->target, dev, 0)) {
/* XXX: idev->cnf.proxy_ndp */
goto out;
}
ndisc_update(dev, neigh, lladdr,
- msg->icmph.icmp6_solicited ? NUD_REACHABLE : NUD_STALE,
- NEIGH_UPDATE_F_WEAK_OVERRIDE|
- (msg->icmph.icmp6_override ? NEIGH_UPDATE_F_OVERRIDE : 0)|
- NEIGH_UPDATE_F_OVERRIDE_ISROUTER|
- (msg->icmph.icmp6_router ? NEIGH_UPDATE_F_ISROUTER : 0),
+ msg->icmph.icmp6_solicited ?
+ NUD_REACHABLE : NUD_STALE,
+ NEIGH_UPDATE_F_WEAK_OVERRIDE |
+ (msg->icmph.icmp6_override ?
+ NEIGH_UPDATE_F_OVERRIDE : 0) |
+ NEIGH_UPDATE_F_OVERRIDE_ISROUTER |
+ (msg->icmph.icmp6_router ?
+ NEIGH_UPDATE_F_ISROUTER : 0),
NDISC_NEIGHBOUR_ADVERTISEMENT, &ndopts);
if ((old_flags & ~neigh->flags) & NTF_ROUTER) {
- /*
- * Change: router to host
- */
+ /* Change: router to host */
rt6_clean_tohost(dev_net(dev), saddr);
}
@@ -1058,8 +1060,7 @@ static void ndisc_recv_rs(struct sk_buff *skb)
if (!idev->cnf.forwarding)
goto out;
- /*
- * Don't update NCE if src = ::;
+ /* Don't update NCE if src = ::;
* this implies that the source node has no ip address assigned yet.
*/
if (ipv6_addr_any(saddr))
@@ -1081,8 +1082,8 @@ static void ndisc_recv_rs(struct sk_buff *skb)
neigh = __neigh_lookup(&nd_tbl, saddr, skb->dev, 1);
if (neigh) {
ndisc_update(skb->dev, neigh, lladdr, NUD_STALE,
- NEIGH_UPDATE_F_WEAK_OVERRIDE|
- NEIGH_UPDATE_F_OVERRIDE|
+ NEIGH_UPDATE_F_WEAK_OVERRIDE |
+ NEIGH_UPDATE_F_OVERRIDE |
NEIGH_UPDATE_F_OVERRIDE_ISROUTER,
NDISC_ROUTER_SOLICITATION, &ndopts);
neigh_release(neigh);
@@ -1110,9 +1111,8 @@ static void ndisc_ra_useropt(struct sk_buff *ra, struct nd_opt_hdr *opt)
}
nlh = nlmsg_put(skb, 0, 0, RTM_NEWNDUSEROPT, base_size, 0);
- if (!nlh) {
+ if (!nlh)
goto nla_put_failure;
- }
ndmsg = nlmsg_data(nlh);
ndmsg->nduseropt_family = AF_INET6;
@@ -1174,9 +1174,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
}
#endif
- /*
- * set the RA_RECV flag in the interface
- */
+ /* set the RA_RECV flag in the interface */
in6_dev = __in6_dev_get(skb->dev);
if (!in6_dev) {
@@ -1208,15 +1206,13 @@ static void ndisc_router_discovery(struct sk_buff *skb)
#endif
if (in6_dev->if_flags & IF_RS_SENT) {
- /*
- * flag that an RA was received after an RS was sent
+ /* flag that an RA was received after an RS was sent
* out on this interface.
*/
in6_dev->if_flags |= IF_RA_RCVD;
}
- /*
- * Remember the managed/otherconf flags from most recently
+ /* Remember the managed/otherconf flags from most recently
* received RA message (RFC 2462) -- yoshfuji
*/
old_if_flags = in6_dev->if_flags;
@@ -1299,77 +1295,79 @@ static void ndisc_router_discovery(struct sk_buff *skb)
}
neigh->flags |= NTF_ROUTER;
} else if (rt) {
- rt->rt6i_flags = (rt->rt6i_flags & ~RTF_PREF_MASK) | RTF_PREF(pref);
+ rt->rt6i_flags =
+ (rt->rt6i_flags & ~RTF_PREF_MASK) | RTF_PREF(pref);
}
if (rt)
rt6_set_expires(rt, jiffies + (HZ * lifetime));
if (in6_dev->cnf.accept_ra_min_hop_limit < 256 &&
ra_msg->icmph.icmp6_hop_limit) {
- if (in6_dev->cnf.accept_ra_min_hop_limit <= ra_msg->icmph.icmp6_hop_limit) {
+ if (in6_dev->cnf.accept_ra_min_hop_limit <=
+ ra_msg->icmph.icmp6_hop_limit) {
in6_dev->cnf.hop_limit = ra_msg->icmph.icmp6_hop_limit;
if (rt)
dst_metric_set(&rt->dst, RTAX_HOPLIMIT,
ra_msg->icmph.icmp6_hop_limit);
} else {
- ND_PRINTK(2, warn, "RA: Got route advertisement with lower hop_limit than minimum\n");
+ ND_PRINTK(2, warn,
+ "RA: Got route advertisement with lower hop_limit than minimum\n");
}
}
skip_defrtr:
- /*
- * Update Reachable Time and Retrans Timer
- */
+ /* Update Reachable Time and Retrans Timer */
if (in6_dev->nd_parms) {
unsigned long rtime = ntohl(ra_msg->retrans_timer);
- if (rtime && rtime/1000 < MAX_SCHEDULE_TIMEOUT/HZ) {
- rtime = (rtime*HZ)/1000;
- if (rtime < HZ/10)
- rtime = HZ/10;
+ if (rtime && rtime / 1000 < MAX_SCHEDULE_TIMEOUT / HZ) {
+ rtime = (rtime * HZ) / 1000;
+ if (rtime < HZ / 10)
+ rtime = HZ / 10;
NEIGH_VAR_SET(in6_dev->nd_parms, RETRANS_TIME, rtime);
in6_dev->tstamp = jiffies;
send_ifinfo_notify = true;
}
rtime = ntohl(ra_msg->reachable_time);
- if (rtime && rtime/1000 < MAX_SCHEDULE_TIMEOUT/(3*HZ)) {
- rtime = (rtime*HZ)/1000;
+ if (rtime && rtime / 1000 < MAX_SCHEDULE_TIMEOUT / (3 * HZ)) {
+ rtime = (rtime * HZ) / 1000;
- if (rtime < HZ/10)
- rtime = HZ/10;
+ if (rtime < HZ / 10)
+ rtime = HZ / 10;
- if (rtime != NEIGH_VAR(in6_dev->nd_parms, BASE_REACHABLE_TIME)) {
+ if (rtime != NEIGH_VAR(in6_dev->nd_parms,
+ BASE_REACHABLE_TIME)) {
NEIGH_VAR_SET(in6_dev->nd_parms,
BASE_REACHABLE_TIME, rtime);
NEIGH_VAR_SET(in6_dev->nd_parms,
GC_STALETIME, 3 * rtime);
- in6_dev->nd_parms->reachable_time = neigh_rand_reach_time(rtime);
+ in6_dev->nd_parms->reachable_time =
+ neigh_rand_reach_time(rtime);
in6_dev->tstamp = jiffies;
send_ifinfo_notify = true;
}
}
}
- /*
- * Send a notify if RA changed managed/otherconf flags or timer settings
+ /* Send a notify if RA changed managed/otherconf flags
+ * or timer settings
*/
if (send_ifinfo_notify)
inet6_ifinfo_notify(RTM_NEWLINK, in6_dev);
skip_linkparms:
- /*
- * Process options.
- */
+ /* Process options */
if (!neigh)
neigh = __neigh_lookup(&nd_tbl, &ipv6_hdr(skb)->saddr,
skb->dev, 1);
if (neigh) {
u8 *lladdr = NULL;
+
if (ndopts.nd_opts_src_lladdr) {
lladdr = ndisc_opt_addr_data(ndopts.nd_opts_src_lladdr,
skb->dev);
@@ -1380,9 +1378,9 @@ static void ndisc_router_discovery(struct sk_buff *skb)
}
}
ndisc_update(skb->dev, neigh, lladdr, NUD_STALE,
- NEIGH_UPDATE_F_WEAK_OVERRIDE|
- NEIGH_UPDATE_F_OVERRIDE|
- NEIGH_UPDATE_F_OVERRIDE_ISROUTER|
+ NEIGH_UPDATE_F_WEAK_OVERRIDE |
+ NEIGH_UPDATE_F_OVERRIDE |
+ NEIGH_UPDATE_F_OVERRIDE_ISROUTER |
NEIGH_UPDATE_F_ISROUTER,
NDISC_ROUTER_ADVERTISEMENT, &ndopts);
}
@@ -1406,6 +1404,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
if (in6_dev->cnf.accept_ra_rtr_pref && ndopts.nd_opts_ri) {
struct nd_opt_hdr *p;
+
for (p = ndopts.nd_opts_ri;
p;
p = ndisc_next_option(p, ndopts.nd_opts_ri_end)) {
@@ -1418,9 +1417,11 @@ static void ndisc_router_discovery(struct sk_buff *skb)
if (ri->prefix_len == 0 &&
!in6_dev->cnf.accept_ra_defrtr)
continue;
- if (ri->prefix_len < in6_dev->cnf.accept_ra_rt_info_min_plen)
+ if (ri->prefix_len <
+ in6_dev->cnf.accept_ra_rt_info_min_plen)
continue;
- if (ri->prefix_len > in6_dev->cnf.accept_ra_rt_info_max_plen)
+ if (ri->prefix_len >
+ in6_dev->cnf.accept_ra_rt_info_max_plen)
continue;
rt6_route_rcv(skb->dev, (u8 *)p, (p->nd_opt_len) << 3,
&ipv6_hdr(skb)->saddr);
@@ -1442,12 +1443,13 @@ static void ndisc_router_discovery(struct sk_buff *skb)
if (in6_dev->cnf.accept_ra_pinfo && ndopts.nd_opts_pi) {
struct nd_opt_hdr *p;
+
for (p = ndopts.nd_opts_pi;
p;
p = ndisc_next_option(p, ndopts.nd_opts_pi_end)) {
addrconf_prefix_rcv(skb->dev, (u8 *)p,
(p->nd_opt_len) << 3,
- ndopts.nd_opts_src_lladdr != NULL);
+ ndopts.nd_opts_src_lladdr);
}
}
@@ -1455,7 +1457,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
__be32 n;
u32 mtu;
- memcpy(&n, ((u8 *)(ndopts.nd_opts_mtu+1))+2, sizeof(mtu));
+ memcpy(&n, ((u8 *)(ndopts.nd_opts_mtu + 1)) + 2, sizeof(mtu));
mtu = ntohl(n);
if (mtu < IPV6_MIN_MTU || mtu > skb->dev->mtu) {
@@ -1472,6 +1474,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
if (ndopts.nd_useropts) {
struct nd_opt_hdr *p;
+
for (p = ndopts.nd_useropts;
p;
p = ndisc_next_useropt(skb->dev, p,
@@ -1480,9 +1483,9 @@ static void ndisc_router_discovery(struct sk_buff *skb)
}
}
- if (ndopts.nd_opts_tgt_lladdr || ndopts.nd_opts_rh) {
+ if (ndopts.nd_opts_tgt_lladdr || ndopts.nd_opts_rh)
ND_PRINTK(2, warn, "RA: invalid RA options\n");
- }
+
out:
ip6_rt_put(rt);
if (neigh)
@@ -1518,7 +1521,7 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
if (!ndopts.nd_opts_rh) {
ip6_redirect_no_header(skb, dev_net(skb->dev),
- skb->dev->ifindex, 0);
+ skb->dev->ifindex, 0);
return;
}
@@ -1569,7 +1572,8 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
}
if (!ipv6_addr_equal(&ipv6_hdr(skb)->daddr, target) &&
- ipv6_addr_type(target) != (IPV6_ADDR_UNICAST|IPV6_ADDR_LINKLOCAL)) {
+ ipv6_addr_type(target) !=
+ (IPV6_ADDR_UNICAST | IPV6_ADDR_LINKLOCAL)) {
ND_PRINTK(2, warn,
"Redirect: target address is not link-local unicast\n");
return;
@@ -1587,7 +1591,7 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
if (IS_ERR(dst))
return;
- rt = (struct rt6_info *) dst;
+ rt = (struct rt6_info *)dst;
if (rt->rt6i_flags & RTF_GATEWAY) {
ND_PRINTK(2, warn,
@@ -1595,14 +1599,16 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
goto release;
}
peer = inet_getpeer_v6(net->ipv6.peers, &ipv6_hdr(skb)->saddr, 1);
- ret = inet_peer_xrlim_allow(peer, 1*HZ);
+ ret = inet_peer_xrlim_allow(peer, 1 * HZ);
if (peer)
inet_putpeer(peer);
if (!ret)
goto release;
if (dev->addr_len) {
- struct neighbour *neigh = dst_neigh_lookup(skb_dst(skb), target);
+ struct neighbour *neigh =
+ dst_neigh_lookup(skb_dst(skb), target);
+
if (!neigh) {
ND_PRINTK(2, warn,
"Redirect: no neigh for target address\n");
@@ -1617,14 +1623,16 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
optlen += ndisc_redirect_opt_addr_space(dev, neigh,
ops_data_buf,
&ops_data);
- } else
+ } else {
read_unlock_bh(&neigh->lock);
+ }
neigh_release(neigh);
}
rd_len = min_t(unsigned int,
- IPV6_MIN_MTU - sizeof(struct ipv6hdr) - sizeof(*msg) - optlen,
+ IPV6_MIN_MTU - sizeof(struct ipv6hdr) -
+ sizeof(*msg) - optlen,
skb->len + 8);
rd_len &= ~0x7;
optlen += rd_len;
@@ -1642,16 +1650,12 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
.dest = ipv6_hdr(skb)->daddr,
};
- /*
- * include target_address option
- */
+ /* include target_address option */
if (ha)
ndisc_fill_redirect_addr_option(buff, ha, ops_data);
- /*
- * build redirect option and copy skb over to the new packet.
- */
+ /* build redirect option and copy skb over to the new packet */
if (rd_len)
ndisc_fill_redirect_hdr_option(buff, skb, rd_len);
@@ -1737,7 +1741,8 @@ int ndisc_rcv(struct sk_buff *skb)
return 0;
}
-static int ndisc_netdev_event(struct notifier_block *this, unsigned long event, void *ptr)
+static int ndisc_netdev_event(struct notifier_block *this,
+ unsigned long event, void *ptr)
{
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
struct netdev_notifier_change_info *change_info;
@@ -1787,6 +1792,7 @@ static void ndisc_warn_deprecated_sysctl(struct ctl_table *ctl,
{
static char warncomm[TASK_COMM_LEN];
static int warned;
+
if (strcmp(warncomm, current->comm) && warned < 5) {
strcpy(warncomm, current->comm);
pr_warn("process `%s' is using deprecated sysctl (%s) net.ipv6.neigh.%s.%s - use net.ipv6.neigh.%s.%s_ms instead\n",
@@ -1797,7 +1803,8 @@ static void ndisc_warn_deprecated_sysctl(struct ctl_table *ctl,
}
}
-int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
+int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write,
+ void __user *buffer, size_t *lenp, loff_t *ppos)
{
struct net_device *dev = ctl->extra1;
struct inet6_dev *idev;
@@ -1805,7 +1812,8 @@ int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write, void __user *bu
if ((strcmp(ctl->procname, "retrans_time") == 0) ||
(strcmp(ctl->procname, "base_reachable_time") == 0))
- ndisc_warn_deprecated_sysctl(ctl, "syscall", dev ? dev->name : "default");
+ ndisc_warn_deprecated_sysctl(ctl, "syscall",
+ dev ? dev->name : "default");
if (strcmp(ctl->procname, "retrans_time") == 0)
ret = neigh_proc_dointvec(ctl, write, buffer, lenp, ppos);
@@ -1821,18 +1829,22 @@ int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write, void __user *bu
else
ret = -1;
- if (write && ret == 0 && dev && (idev = in6_dev_get(dev)) != NULL) {
- if (ctl->data == &NEIGH_VAR(idev->nd_parms, BASE_REACHABLE_TIME))
+ if (!write || ret || !dev)
+ return ret;
+
+ idev = in6_dev_get(dev);
+ if (idev) {
+ if (ctl->data ==
+ &NEIGH_VAR(idev->nd_parms, BASE_REACHABLE_TIME))
idev->nd_parms->reachable_time =
- neigh_rand_reach_time(NEIGH_VAR(idev->nd_parms, BASE_REACHABLE_TIME));
+ neigh_rand_reach_time(
+ NEIGH_VAR(idev->nd_parms, BASE_REACHABLE_TIME));
idev->tstamp = jiffies;
inet6_ifinfo_notify(RTM_NEWLINK, idev);
in6_dev_put(idev);
}
return ret;
}
-
-
#endif
static int __net_init ndisc_net_init(struct net *net)
@@ -1877,9 +1889,7 @@ int __init ndisc_init(void)
err = register_pernet_subsys(&ndisc_net_ops);
if (err)
return err;
- /*
- * Initialize the neighbour table
- */
+ /* Initialize the neighbour table */
neigh_table_init(NEIGH_ND_TABLE, &nd_tbl);
#ifdef CONFIG_SYSCTL
--
2.7.4
^ permalink raw reply related
* [net-next] net: ipv6: fix code style error and warning of ndisc.c
From: yuan linyu @ 2017-05-20 4:16 UTC (permalink / raw)
To: netdev; +Cc: David S . Miller, yuan linyu
From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
Signed-off-by: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
---
net/ipv6/ndisc.c | 300 ++++++++++++++++++++++++++++---------------------------
1 file changed, 155 insertions(+), 145 deletions(-)
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index d310dc4..5a3dfaa 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -12,8 +12,7 @@
* 2 of the License, or (at your option) any later version.
*/
-/*
- * Changes:
+/* Changes:
*
* Alexey I. Froloff : RFC6106 (DNSSL) support
* Pierre Ynard : export userland ND options
@@ -99,7 +98,6 @@ static const struct neigh_ops ndisc_hh_ops = {
.connected_output = neigh_resolve_output,
};
-
static const struct neigh_ops ndisc_direct_ops = {
.family = AF_INET6,
.output = neigh_direct_output,
@@ -147,13 +145,13 @@ void __ndisc_fill_addr_option(struct sk_buff *skb, int type, void *data,
u8 *opt = skb_put(skb, space);
opt[0] = type;
- opt[1] = space>>3;
+ opt[1] = space >> 3;
memset(opt + 2, 0, pad);
opt += pad;
space -= pad;
- memcpy(opt+2, data, data_len);
+ memcpy(opt + 2, data, data_len);
data_len += 2;
opt += data_len;
space -= data_len;
@@ -182,6 +180,7 @@ static struct nd_opt_hdr *ndisc_next_option(struct nd_opt_hdr *cur,
struct nd_opt_hdr *end)
{
int type;
+
if (!cur || !end || cur >= end)
return NULL;
type = cur->nd_opt_type;
@@ -222,6 +221,7 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
memset(ndopts, 0, sizeof(*ndopts));
while (opt_len) {
int l;
+
if (opt_len < sizeof(struct nd_opt_hdr))
return NULL;
l = nd_opt->nd_opt_len << 3;
@@ -240,13 +240,15 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
"%s: duplicated ND6 option found: type=%d\n",
__func__, nd_opt->nd_opt_type);
} else {
- ndopts->nd_opt_array[nd_opt->nd_opt_type] = nd_opt;
+ ndopts->nd_opt_array[nd_opt->nd_opt_type] =
+ nd_opt;
}
break;
case ND_OPT_PREFIX_INFO:
ndopts->nd_opts_pi_end = nd_opt;
if (!ndopts->nd_opt_array[nd_opt->nd_opt_type])
- ndopts->nd_opt_array[nd_opt->nd_opt_type] = nd_opt;
+ ndopts->nd_opt_array[nd_opt->nd_opt_type] =
+ nd_opt;
break;
#ifdef CONFIG_IPV6_ROUTE_INFO
case ND_OPT_ROUTE_INFO:
@@ -261,8 +263,7 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
if (!ndopts->nd_useropts)
ndopts->nd_useropts = nd_opt;
} else {
- /*
- * Unknown options must be silently ignored,
+ /* Unknown options must be silently ignored,
* to accommodate future extension to the
* protocol.
*/
@@ -280,7 +281,8 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
return ndopts;
}
-int ndisc_mc_map(const struct in6_addr *addr, char *buf, struct net_device *dev, int dir)
+int ndisc_mc_map(const struct in6_addr *addr, char *buf,
+ struct net_device *dev, int dir)
{
switch (dev->type) {
case ARPHRD_ETHER:
@@ -327,9 +329,8 @@ static int ndisc_constructor(struct neighbour *neigh)
bool is_multicast = ipv6_addr_is_multicast(addr);
in6_dev = in6_dev_get(dev);
- if (!in6_dev) {
+ if (!in6_dev)
return -EINVAL;
- }
parms = in6_dev->nd_parms;
__neigh_parms_put(neigh->parms);
@@ -344,12 +345,12 @@ static int ndisc_constructor(struct neighbour *neigh)
if (is_multicast) {
neigh->nud_state = NUD_NOARP;
ndisc_mc_map(addr, neigh->ha, dev, 1);
- } else if (dev->flags&(IFF_NOARP|IFF_LOOPBACK)) {
+ } else if (dev->flags & (IFF_NOARP | IFF_LOOPBACK)) {
neigh->nud_state = NUD_NOARP;
memcpy(neigh->ha, dev->dev_addr, dev->addr_len);
- if (dev->flags&IFF_LOOPBACK)
+ if (dev->flags & IFF_LOOPBACK)
neigh->type = RTN_LOCAL;
- } else if (dev->flags&IFF_POINTOPOINT) {
+ } else if (dev->flags & IFF_POINTOPOINT) {
neigh->nud_state = NUD_NOARP;
memcpy(neigh->ha, dev->broadcast, dev->addr_len);
}
@@ -357,7 +358,7 @@ static int ndisc_constructor(struct neighbour *neigh)
neigh->ops = &ndisc_hh_ops;
else
neigh->ops = &ndisc_generic_ops;
- if (neigh->nud_state&NUD_VALID)
+ if (neigh->nud_state & NUD_VALID)
neigh->output = neigh->ops->connected_output;
else
neigh->output = neigh->ops->output;
@@ -512,7 +513,8 @@ void ndisc_send_na(struct net_device *dev, const struct in6_addr *daddr,
in6_ifa_put(ifp);
} else {
if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
- inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
+ inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->
+ srcprefs,
&tmpaddr))
return;
src_addr = &tmpaddr;
@@ -580,7 +582,7 @@ void ndisc_send_ns(struct net_device *dev, const struct in6_addr *solicit,
if (!saddr) {
if (ipv6_get_lladdr(dev, &addr_buf,
- (IFA_F_TENTATIVE|IFA_F_OPTIMISTIC)))
+ (IFA_F_TENTATIVE | IFA_F_OPTIMISTIC)))
return;
saddr = &addr_buf;
}
@@ -629,8 +631,7 @@ void ndisc_send_rs(struct net_device *dev, const struct in6_addr *saddr,
int optlen = 0;
#ifdef CONFIG_IPV6_OPTIMISTIC_DAD
- /*
- * According to section 2.2 of RFC 4429, we must not
+ /* According to section 2.2 of RFC 4429, we must not
* send router solicitations with a sllao from
* optimistic addresses, but we may send the solicitation
* if we don't include the sllao. So here we check
@@ -641,9 +642,8 @@ void ndisc_send_rs(struct net_device *dev, const struct in6_addr *saddr,
struct inet6_ifaddr *ifp = ipv6_get_ifaddr(dev_net(dev), saddr,
dev, 1);
if (ifp) {
- if (ifp->flags & IFA_F_OPTIMISTIC) {
+ if (ifp->flags & IFA_F_OPTIMISTIC)
send_sllao = 0;
- }
in6_ifa_put(ifp);
} else {
send_sllao = 0;
@@ -672,11 +672,9 @@ void ndisc_send_rs(struct net_device *dev, const struct in6_addr *saddr,
ndisc_send_skb(skb, daddr, saddr);
}
-
static void ndisc_error_report(struct neighbour *neigh, struct sk_buff *skb)
{
- /*
- * "The sender MUST return an ICMP
+ /* "The sender MUST return an ICMP
* destination unreachable"
*/
dst_link_failure(skb);
@@ -695,7 +693,7 @@ static void ndisc_solicit(struct neighbour *neigh, struct sk_buff *skb)
if (skb && ipv6_chk_addr_and_flags(dev_net(dev), &ipv6_hdr(skb)->saddr,
dev, 1,
- IFA_F_TENTATIVE|IFA_F_OPTIMISTIC))
+ IFA_F_TENTATIVE | IFA_F_OPTIMISTIC))
saddr = &ipv6_hdr(skb)->saddr;
probes -= NEIGH_VAR(neigh->parms, UCAST_PROBES);
if (probes < 0) {
@@ -705,11 +703,14 @@ static void ndisc_solicit(struct neighbour *neigh, struct sk_buff *skb)
__func__, target);
}
ndisc_send_ns(dev, target, target, saddr, 0);
- } else if ((probes -= NEIGH_VAR(neigh->parms, APP_PROBES)) < 0) {
- neigh_app_ns(neigh);
} else {
- addrconf_addr_solict_mult(target, &mcaddr);
- ndisc_send_ns(dev, target, &mcaddr, saddr, 0);
+ probes -= NEIGH_VAR(neigh->parms, APP_PROBES);
+ if (probes < 0) {
+ neigh_app_ns(neigh);
+ } else {
+ addrconf_addr_solict_mult(target, &mcaddr);
+ ndisc_send_ns(dev, target, &mcaddr, saddr, 0);
+ }
}
}
@@ -765,8 +766,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
return;
}
- /*
- * RFC2461 7.1.1:
+ /* RFC2461 7.1.1:
* DAD has to be destined for solicited node multicast address.
*/
if (dad && !ipv6_addr_is_solict_mult(daddr)) {
@@ -806,7 +806,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
ifp = ipv6_get_ifaddr(dev_net(dev), &msg->target, dev, 1);
if (ifp) {
have_ifp:
- if (ifp->flags & (IFA_F_TENTATIVE|IFA_F_OPTIMISTIC)) {
+ if (ifp->flags & (IFA_F_TENTATIVE | IFA_F_OPTIMISTIC)) {
if (dad) {
if (nonce != 0 && ifp->dad_nonce == nonce) {
u8 *np = (u8 *)&nonce;
@@ -817,23 +817,21 @@ static void ndisc_recv_ns(struct sk_buff *skb)
&ifp->addr, np);
goto out;
}
- /*
- * We are colliding with another node
+ /* We are colliding with another node
* who is doing DAD
* so fail our DAD process
*/
addrconf_dad_failure(ifp);
return;
- } else {
- /*
- * This is not a dad solicitation.
- * If we are an optimistic node,
- * we should respond.
- * Otherwise, we should ignore it.
- */
- if (!(ifp->flags & IFA_F_OPTIMISTIC))
- goto out;
}
+
+ /* This is not a dad solicitation.
+ * If we are an optimistic node,
+ * we should respond.
+ * Otherwise, we should ignore it.
+ */
+ if (!(ifp->flags & IFA_F_OPTIMISTIC))
+ goto out;
}
idev = ifp->idev;
@@ -846,7 +844,8 @@ static void ndisc_recv_ns(struct sk_buff *skb)
mdev = netdev_master_upper_dev_get_rcu(dev);
if (mdev) {
- ifp = ipv6_get_ifaddr(net, &msg->target, mdev, 1);
+ ifp = ipv6_get_ifaddr(net, &msg->target,
+ mdev, 1);
if (ifp)
goto have_ifp;
}
@@ -858,28 +857,31 @@ static void ndisc_recv_ns(struct sk_buff *skb)
return;
}
+ is_router = pndisc_is_router(&msg->target, dev);
if (ipv6_chk_acast_addr(net, dev, &msg->target) ||
(idev->cnf.forwarding &&
- (net->ipv6.devconf_all->proxy_ndp || idev->cnf.proxy_ndp) &&
- (is_router = pndisc_is_router(&msg->target, dev)) >= 0)) {
+ (net->ipv6.devconf_all->proxy_ndp ||
+ idev->cnf.proxy_ndp) && is_router >= 0)) {
if (!(NEIGH_CB(skb)->flags & LOCALLY_ENQUEUED) &&
skb->pkt_type != PACKET_HOST &&
inc &&
NEIGH_VAR(idev->nd_parms, PROXY_DELAY) != 0) {
- /*
- * for anycast or proxy,
+ /* for anycast or proxy,
* sender should delay its response
* by a random time between 0 and
* MAX_ANYCAST_DELAY_TIME seconds.
* (RFC2461) -- yoshfuji
*/
struct sk_buff *n = skb_clone(skb, GFP_ATOMIC);
+
if (n)
- pneigh_enqueue(&nd_tbl, idev->nd_parms, n);
+ pneigh_enqueue(&nd_tbl,
+ idev->nd_parms, n);
goto out;
}
- } else
+ } else {
goto out;
+ }
}
if (is_router < 0)
@@ -887,7 +889,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
if (dad) {
ndisc_send_na(dev, &in6addr_linklocal_allnodes, &msg->target,
- !!is_router, false, (ifp != NULL), true);
+ !!is_router, false, ifp, true);
goto out;
}
@@ -896,20 +898,19 @@ static void ndisc_recv_ns(struct sk_buff *skb)
else
NEIGH_CACHE_STAT_INC(&nd_tbl, rcv_probes_ucast);
- /*
- * update / create cache entry
+ /* update / create cache entry
* for the source address
*/
neigh = __neigh_lookup(&nd_tbl, saddr, dev,
!inc || lladdr || !dev->addr_len);
if (neigh)
ndisc_update(dev, neigh, lladdr, NUD_STALE,
- NEIGH_UPDATE_F_WEAK_OVERRIDE|
+ NEIGH_UPDATE_F_WEAK_OVERRIDE |
NEIGH_UPDATE_F_OVERRIDE,
NDISC_NEIGHBOUR_SOLICITATION, &ndopts);
if (neigh || !dev->header_ops) {
ndisc_send_na(dev, saddr, &msg->target, !!is_router,
- true, (ifp != NULL && inc), inc);
+ true, (ifp && inc), inc);
if (neigh)
neigh_release(neigh);
}
@@ -973,19 +974,19 @@ static void ndisc_recv_na(struct sk_buff *skb)
}
ifp = ipv6_get_ifaddr(dev_net(dev), &msg->target, dev, 1);
if (ifp) {
- if (skb->pkt_type != PACKET_LOOPBACK
- && (ifp->flags & IFA_F_TENTATIVE)) {
- addrconf_dad_failure(ifp);
- return;
+ if (skb->pkt_type != PACKET_LOOPBACK &&
+ (ifp->flags & IFA_F_TENTATIVE)) {
+ addrconf_dad_failure(ifp);
+ return;
}
/* What should we make now? The advertisement
- is invalid, but ndisc specs say nothing
- about it. It could be misconfiguration, or
- an smart proxy agent tries to help us :-)
-
- We should not print the error if NA has been
- received from loopback - it is just our own
- unsolicited advertisement.
+ * is invalid, but ndisc specs say nothing
+ * about it. It could be misconfiguration, or
+ * an smart proxy agent tries to help us :-)
+ *
+ * We should not print the error if NA has been
+ * received from loopback - it is just our own
+ * unsolicited advertisement.
*/
if (skb->pkt_type != PACKET_LOOPBACK)
ND_PRINTK(1, warn,
@@ -1003,30 +1004,31 @@ static void ndisc_recv_na(struct sk_buff *skb)
if (neigh->nud_state & NUD_FAILED)
goto out;
- /*
- * Don't update the neighbor cache entry on a proxy NA from
+ /* Don't update the neighbor cache entry on a proxy NA from
* ourselves because either the proxied node is off link or it
* has already sent a NA to us.
*/
if (lladdr && !memcmp(lladdr, dev->dev_addr, dev->addr_len) &&
- net->ipv6.devconf_all->forwarding && net->ipv6.devconf_all->proxy_ndp &&
+ net->ipv6.devconf_all->forwarding &&
+ net->ipv6.devconf_all->proxy_ndp &&
pneigh_lookup(&nd_tbl, net, &msg->target, dev, 0)) {
/* XXX: idev->cnf.proxy_ndp */
goto out;
}
ndisc_update(dev, neigh, lladdr,
- msg->icmph.icmp6_solicited ? NUD_REACHABLE : NUD_STALE,
- NEIGH_UPDATE_F_WEAK_OVERRIDE|
- (msg->icmph.icmp6_override ? NEIGH_UPDATE_F_OVERRIDE : 0)|
- NEIGH_UPDATE_F_OVERRIDE_ISROUTER|
- (msg->icmph.icmp6_router ? NEIGH_UPDATE_F_ISROUTER : 0),
+ msg->icmph.icmp6_solicited ?
+ NUD_REACHABLE : NUD_STALE,
+ NEIGH_UPDATE_F_WEAK_OVERRIDE |
+ (msg->icmph.icmp6_override ?
+ NEIGH_UPDATE_F_OVERRIDE : 0) |
+ NEIGH_UPDATE_F_OVERRIDE_ISROUTER |
+ (msg->icmph.icmp6_router ?
+ NEIGH_UPDATE_F_ISROUTER : 0),
NDISC_NEIGHBOUR_ADVERTISEMENT, &ndopts);
if ((old_flags & ~neigh->flags) & NTF_ROUTER) {
- /*
- * Change: router to host
- */
+ /* Change: router to host */
rt6_clean_tohost(dev_net(dev), saddr);
}
@@ -1058,8 +1060,7 @@ static void ndisc_recv_rs(struct sk_buff *skb)
if (!idev->cnf.forwarding)
goto out;
- /*
- * Don't update NCE if src = ::;
+ /* Don't update NCE if src = ::;
* this implies that the source node has no ip address assigned yet.
*/
if (ipv6_addr_any(saddr))
@@ -1081,8 +1082,8 @@ static void ndisc_recv_rs(struct sk_buff *skb)
neigh = __neigh_lookup(&nd_tbl, saddr, skb->dev, 1);
if (neigh) {
ndisc_update(skb->dev, neigh, lladdr, NUD_STALE,
- NEIGH_UPDATE_F_WEAK_OVERRIDE|
- NEIGH_UPDATE_F_OVERRIDE|
+ NEIGH_UPDATE_F_WEAK_OVERRIDE |
+ NEIGH_UPDATE_F_OVERRIDE |
NEIGH_UPDATE_F_OVERRIDE_ISROUTER,
NDISC_ROUTER_SOLICITATION, &ndopts);
neigh_release(neigh);
@@ -1110,9 +1111,8 @@ static void ndisc_ra_useropt(struct sk_buff *ra, struct nd_opt_hdr *opt)
}
nlh = nlmsg_put(skb, 0, 0, RTM_NEWNDUSEROPT, base_size, 0);
- if (!nlh) {
+ if (!nlh)
goto nla_put_failure;
- }
ndmsg = nlmsg_data(nlh);
ndmsg->nduseropt_family = AF_INET6;
@@ -1174,9 +1174,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
}
#endif
- /*
- * set the RA_RECV flag in the interface
- */
+ /* set the RA_RECV flag in the interface */
in6_dev = __in6_dev_get(skb->dev);
if (!in6_dev) {
@@ -1208,15 +1206,13 @@ static void ndisc_router_discovery(struct sk_buff *skb)
#endif
if (in6_dev->if_flags & IF_RS_SENT) {
- /*
- * flag that an RA was received after an RS was sent
+ /* flag that an RA was received after an RS was sent
* out on this interface.
*/
in6_dev->if_flags |= IF_RA_RCVD;
}
- /*
- * Remember the managed/otherconf flags from most recently
+ /* Remember the managed/otherconf flags from most recently
* received RA message (RFC 2462) -- yoshfuji
*/
old_if_flags = in6_dev->if_flags;
@@ -1299,77 +1295,79 @@ static void ndisc_router_discovery(struct sk_buff *skb)
}
neigh->flags |= NTF_ROUTER;
} else if (rt) {
- rt->rt6i_flags = (rt->rt6i_flags & ~RTF_PREF_MASK) | RTF_PREF(pref);
+ rt->rt6i_flags =
+ (rt->rt6i_flags & ~RTF_PREF_MASK) | RTF_PREF(pref);
}
if (rt)
rt6_set_expires(rt, jiffies + (HZ * lifetime));
if (in6_dev->cnf.accept_ra_min_hop_limit < 256 &&
ra_msg->icmph.icmp6_hop_limit) {
- if (in6_dev->cnf.accept_ra_min_hop_limit <= ra_msg->icmph.icmp6_hop_limit) {
+ if (in6_dev->cnf.accept_ra_min_hop_limit <=
+ ra_msg->icmph.icmp6_hop_limit) {
in6_dev->cnf.hop_limit = ra_msg->icmph.icmp6_hop_limit;
if (rt)
dst_metric_set(&rt->dst, RTAX_HOPLIMIT,
ra_msg->icmph.icmp6_hop_limit);
} else {
- ND_PRINTK(2, warn, "RA: Got route advertisement with lower hop_limit than minimum\n");
+ ND_PRINTK(2, warn,
+ "RA: Got route advertisement with lower hop_limit than minimum\n");
}
}
skip_defrtr:
- /*
- * Update Reachable Time and Retrans Timer
- */
+ /* Update Reachable Time and Retrans Timer */
if (in6_dev->nd_parms) {
unsigned long rtime = ntohl(ra_msg->retrans_timer);
- if (rtime && rtime/1000 < MAX_SCHEDULE_TIMEOUT/HZ) {
- rtime = (rtime*HZ)/1000;
- if (rtime < HZ/10)
- rtime = HZ/10;
+ if (rtime && rtime / 1000 < MAX_SCHEDULE_TIMEOUT / HZ) {
+ rtime = (rtime * HZ) / 1000;
+ if (rtime < HZ / 10)
+ rtime = HZ / 10;
NEIGH_VAR_SET(in6_dev->nd_parms, RETRANS_TIME, rtime);
in6_dev->tstamp = jiffies;
send_ifinfo_notify = true;
}
rtime = ntohl(ra_msg->reachable_time);
- if (rtime && rtime/1000 < MAX_SCHEDULE_TIMEOUT/(3*HZ)) {
- rtime = (rtime*HZ)/1000;
+ if (rtime && rtime / 1000 < MAX_SCHEDULE_TIMEOUT / (3 * HZ)) {
+ rtime = (rtime * HZ) / 1000;
- if (rtime < HZ/10)
- rtime = HZ/10;
+ if (rtime < HZ / 10)
+ rtime = HZ / 10;
- if (rtime != NEIGH_VAR(in6_dev->nd_parms, BASE_REACHABLE_TIME)) {
+ if (rtime != NEIGH_VAR(in6_dev->nd_parms,
+ BASE_REACHABLE_TIME)) {
NEIGH_VAR_SET(in6_dev->nd_parms,
BASE_REACHABLE_TIME, rtime);
NEIGH_VAR_SET(in6_dev->nd_parms,
GC_STALETIME, 3 * rtime);
- in6_dev->nd_parms->reachable_time = neigh_rand_reach_time(rtime);
+ in6_dev->nd_parms->reachable_time =
+ neigh_rand_reach_time(rtime);
in6_dev->tstamp = jiffies;
send_ifinfo_notify = true;
}
}
}
- /*
- * Send a notify if RA changed managed/otherconf flags or timer settings
+ /* Send a notify if RA changed managed/otherconf flags
+ * or timer settings
*/
if (send_ifinfo_notify)
inet6_ifinfo_notify(RTM_NEWLINK, in6_dev);
skip_linkparms:
- /*
- * Process options.
- */
+ /* Process options */
if (!neigh)
neigh = __neigh_lookup(&nd_tbl, &ipv6_hdr(skb)->saddr,
skb->dev, 1);
if (neigh) {
u8 *lladdr = NULL;
+
if (ndopts.nd_opts_src_lladdr) {
lladdr = ndisc_opt_addr_data(ndopts.nd_opts_src_lladdr,
skb->dev);
@@ -1380,9 +1378,9 @@ static void ndisc_router_discovery(struct sk_buff *skb)
}
}
ndisc_update(skb->dev, neigh, lladdr, NUD_STALE,
- NEIGH_UPDATE_F_WEAK_OVERRIDE|
- NEIGH_UPDATE_F_OVERRIDE|
- NEIGH_UPDATE_F_OVERRIDE_ISROUTER|
+ NEIGH_UPDATE_F_WEAK_OVERRIDE |
+ NEIGH_UPDATE_F_OVERRIDE |
+ NEIGH_UPDATE_F_OVERRIDE_ISROUTER |
NEIGH_UPDATE_F_ISROUTER,
NDISC_ROUTER_ADVERTISEMENT, &ndopts);
}
@@ -1406,6 +1404,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
if (in6_dev->cnf.accept_ra_rtr_pref && ndopts.nd_opts_ri) {
struct nd_opt_hdr *p;
+
for (p = ndopts.nd_opts_ri;
p;
p = ndisc_next_option(p, ndopts.nd_opts_ri_end)) {
@@ -1418,9 +1417,11 @@ static void ndisc_router_discovery(struct sk_buff *skb)
if (ri->prefix_len == 0 &&
!in6_dev->cnf.accept_ra_defrtr)
continue;
- if (ri->prefix_len < in6_dev->cnf.accept_ra_rt_info_min_plen)
+ if (ri->prefix_len <
+ in6_dev->cnf.accept_ra_rt_info_min_plen)
continue;
- if (ri->prefix_len > in6_dev->cnf.accept_ra_rt_info_max_plen)
+ if (ri->prefix_len >
+ in6_dev->cnf.accept_ra_rt_info_max_plen)
continue;
rt6_route_rcv(skb->dev, (u8 *)p, (p->nd_opt_len) << 3,
&ipv6_hdr(skb)->saddr);
@@ -1442,12 +1443,13 @@ static void ndisc_router_discovery(struct sk_buff *skb)
if (in6_dev->cnf.accept_ra_pinfo && ndopts.nd_opts_pi) {
struct nd_opt_hdr *p;
+
for (p = ndopts.nd_opts_pi;
p;
p = ndisc_next_option(p, ndopts.nd_opts_pi_end)) {
addrconf_prefix_rcv(skb->dev, (u8 *)p,
(p->nd_opt_len) << 3,
- ndopts.nd_opts_src_lladdr != NULL);
+ ndopts.nd_opts_src_lladdr);
}
}
@@ -1455,7 +1457,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
__be32 n;
u32 mtu;
- memcpy(&n, ((u8 *)(ndopts.nd_opts_mtu+1))+2, sizeof(mtu));
+ memcpy(&n, ((u8 *)(ndopts.nd_opts_mtu + 1)) + 2, sizeof(mtu));
mtu = ntohl(n);
if (mtu < IPV6_MIN_MTU || mtu > skb->dev->mtu) {
@@ -1472,6 +1474,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
if (ndopts.nd_useropts) {
struct nd_opt_hdr *p;
+
for (p = ndopts.nd_useropts;
p;
p = ndisc_next_useropt(skb->dev, p,
@@ -1480,9 +1483,9 @@ static void ndisc_router_discovery(struct sk_buff *skb)
}
}
- if (ndopts.nd_opts_tgt_lladdr || ndopts.nd_opts_rh) {
+ if (ndopts.nd_opts_tgt_lladdr || ndopts.nd_opts_rh)
ND_PRINTK(2, warn, "RA: invalid RA options\n");
- }
+
out:
ip6_rt_put(rt);
if (neigh)
@@ -1518,7 +1521,7 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
if (!ndopts.nd_opts_rh) {
ip6_redirect_no_header(skb, dev_net(skb->dev),
- skb->dev->ifindex, 0);
+ skb->dev->ifindex, 0);
return;
}
@@ -1569,7 +1572,8 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
}
if (!ipv6_addr_equal(&ipv6_hdr(skb)->daddr, target) &&
- ipv6_addr_type(target) != (IPV6_ADDR_UNICAST|IPV6_ADDR_LINKLOCAL)) {
+ ipv6_addr_type(target) !=
+ (IPV6_ADDR_UNICAST | IPV6_ADDR_LINKLOCAL)) {
ND_PRINTK(2, warn,
"Redirect: target address is not link-local unicast\n");
return;
@@ -1587,7 +1591,7 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
if (IS_ERR(dst))
return;
- rt = (struct rt6_info *) dst;
+ rt = (struct rt6_info *)dst;
if (rt->rt6i_flags & RTF_GATEWAY) {
ND_PRINTK(2, warn,
@@ -1595,14 +1599,16 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
goto release;
}
peer = inet_getpeer_v6(net->ipv6.peers, &ipv6_hdr(skb)->saddr, 1);
- ret = inet_peer_xrlim_allow(peer, 1*HZ);
+ ret = inet_peer_xrlim_allow(peer, 1 * HZ);
if (peer)
inet_putpeer(peer);
if (!ret)
goto release;
if (dev->addr_len) {
- struct neighbour *neigh = dst_neigh_lookup(skb_dst(skb), target);
+ struct neighbour *neigh =
+ dst_neigh_lookup(skb_dst(skb), target);
+
if (!neigh) {
ND_PRINTK(2, warn,
"Redirect: no neigh for target address\n");
@@ -1617,14 +1623,16 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
optlen += ndisc_redirect_opt_addr_space(dev, neigh,
ops_data_buf,
&ops_data);
- } else
+ } else {
read_unlock_bh(&neigh->lock);
+ }
neigh_release(neigh);
}
rd_len = min_t(unsigned int,
- IPV6_MIN_MTU - sizeof(struct ipv6hdr) - sizeof(*msg) - optlen,
+ IPV6_MIN_MTU - sizeof(struct ipv6hdr) -
+ sizeof(*msg) - optlen,
skb->len + 8);
rd_len &= ~0x7;
optlen += rd_len;
@@ -1642,16 +1650,12 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
.dest = ipv6_hdr(skb)->daddr,
};
- /*
- * include target_address option
- */
+ /* include target_address option */
if (ha)
ndisc_fill_redirect_addr_option(buff, ha, ops_data);
- /*
- * build redirect option and copy skb over to the new packet.
- */
+ /* build redirect option and copy skb over to the new packet */
if (rd_len)
ndisc_fill_redirect_hdr_option(buff, skb, rd_len);
@@ -1737,7 +1741,8 @@ int ndisc_rcv(struct sk_buff *skb)
return 0;
}
-static int ndisc_netdev_event(struct notifier_block *this, unsigned long event, void *ptr)
+static int ndisc_netdev_event(struct notifier_block *this,
+ unsigned long event, void *ptr)
{
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
struct netdev_notifier_change_info *change_info;
@@ -1787,6 +1792,7 @@ static void ndisc_warn_deprecated_sysctl(struct ctl_table *ctl,
{
static char warncomm[TASK_COMM_LEN];
static int warned;
+
if (strcmp(warncomm, current->comm) && warned < 5) {
strcpy(warncomm, current->comm);
pr_warn("process `%s' is using deprecated sysctl (%s) net.ipv6.neigh.%s.%s - use net.ipv6.neigh.%s.%s_ms instead\n",
@@ -1797,7 +1803,8 @@ static void ndisc_warn_deprecated_sysctl(struct ctl_table *ctl,
}
}
-int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
+int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write,
+ void __user *buffer, size_t *lenp, loff_t *ppos)
{
struct net_device *dev = ctl->extra1;
struct inet6_dev *idev;
@@ -1805,7 +1812,8 @@ int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write, void __user *bu
if ((strcmp(ctl->procname, "retrans_time") == 0) ||
(strcmp(ctl->procname, "base_reachable_time") == 0))
- ndisc_warn_deprecated_sysctl(ctl, "syscall", dev ? dev->name : "default");
+ ndisc_warn_deprecated_sysctl(ctl, "syscall",
+ dev ? dev->name : "default");
if (strcmp(ctl->procname, "retrans_time") == 0)
ret = neigh_proc_dointvec(ctl, write, buffer, lenp, ppos);
@@ -1821,18 +1829,22 @@ int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write, void __user *bu
else
ret = -1;
- if (write && ret == 0 && dev && (idev = in6_dev_get(dev)) != NULL) {
- if (ctl->data == &NEIGH_VAR(idev->nd_parms, BASE_REACHABLE_TIME))
+ if (!write || ret || !dev)
+ return ret;
+
+ idev = in6_dev_get(dev);
+ if (idev) {
+ if (ctl->data ==
+ &NEIGH_VAR(idev->nd_parms, BASE_REACHABLE_TIME))
idev->nd_parms->reachable_time =
- neigh_rand_reach_time(NEIGH_VAR(idev->nd_parms, BASE_REACHABLE_TIME));
+ neigh_rand_reach_time(
+ NEIGH_VAR(idev->nd_parms, BASE_REACHABLE_TIME));
idev->tstamp = jiffies;
inet6_ifinfo_notify(RTM_NEWLINK, idev);
in6_dev_put(idev);
}
return ret;
}
-
-
#endif
static int __net_init ndisc_net_init(struct net *net)
@@ -1877,9 +1889,7 @@ int __init ndisc_init(void)
err = register_pernet_subsys(&ndisc_net_ops);
if (err)
return err;
- /*
- * Initialize the neighbour table
- */
+ /* Initialize the neighbour table */
neigh_table_init(NEIGH_ND_TABLE, &nd_tbl);
#ifdef CONFIG_SYSCTL
--
2.7.4
^ permalink raw reply related
* Re: [RFC net-next PATCH 4/5] net: new XDP feature for reading HW rxhash from drivers
From: Jakub Kicinski @ 2017-05-20 4:13 UTC (permalink / raw)
To: Alexei Starovoitov; +Cc: Jesper Dangaard Brouer, Daniel Borkmann, netdev
In-Reply-To: <20170520033358.hjz7ocy2fupwplym@ast-mbp>
On Fri, 19 May 2017 20:34:00 -0700, Alexei Starovoitov wrote:
> On Fri, May 19, 2017 at 08:21:47PM -0700, Jakub Kicinski wrote:
> > On Fri, 19 May 2017 20:07:52 -0700, Alexei Starovoitov wrote:
> > > How about exposing 'struct mlx5_cqe64 *' to XDP programs as-is?
> > > We can make sure that XDP program does read only access into it and
> > > it will see cqe->rss_hash_result, cqe->rss_hash_type and everything else
> > > in there, but this will not be uapi and it will be pretty obvious
> > > to program authors that their programs are vendor specific.
> > > 'not uapi' here means that mellanox is free to change their HW descriptor
> > > and its contents as they wish.
> >
> > Hm.. Would that mean we have to teach the verifier about all possible
> > drivers and their metadata structures (i.e. sizes thereof). And add an
> > UAPI enum of known drivers?
>
> why? no uapi other than a pointer to this hw rx descriptor.
> Different sizeof(hw_rx_descriptor) is not a problem.
> We deal with it already in tracing. All tracepoints have different
> sizeof(*ctx), yet the safety is preserved.
Ack, quick read of tracing code reveals this indeed should work.
^ permalink raw reply
* Re: [RFC net-next PATCH 4/5] net: new XDP feature for reading HW rxhash from drivers
From: Alexei Starovoitov @ 2017-05-20 3:34 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Jesper Dangaard Brouer, Daniel Borkmann, John Fastabend, netdev
In-Reply-To: <20170519202147.3c6bda7f@cakuba.netronome.com>
On Fri, May 19, 2017 at 08:21:47PM -0700, Jakub Kicinski wrote:
> On Fri, 19 May 2017 20:07:52 -0700, Alexei Starovoitov wrote:
> > How about exposing 'struct mlx5_cqe64 *' to XDP programs as-is?
> > We can make sure that XDP program does read only access into it and
> > it will see cqe->rss_hash_result, cqe->rss_hash_type and everything else
> > in there, but this will not be uapi and it will be pretty obvious
> > to program authors that their programs are vendor specific.
> > 'not uapi' here means that mellanox is free to change their HW descriptor
> > and its contents as they wish.
>
> Hm.. Would that mean we have to teach the verifier about all possible
> drivers and their metadata structures (i.e. sizes thereof). And add an
> UAPI enum of known drivers?
why? no uapi other than a pointer to this hw rx descriptor.
Different sizeof(hw_rx_descriptor) is not a problem.
We deal with it already in tracing. All tracepoints have different
sizeof(*ctx), yet the safety is preserved.
> Other idea I floated in early days was to standardize the fields but
> let the driver "JIT" the accesses to look at the right offset of the
> right structure. Admittedly that would be a lot more work.
'standardize the fields' sounds nice, but failed here already.
As far as I can see the meaning of packet 'hash' is quite different
across the drivers and 'hash' is just a beginning.
I hope we can standardize on 'csum' field and make it checksum_complete,
but so far out of 10+G nics only mlx5 and nfp do it in hw.
We need it at least for mlx4, but it can only fake it via expensive math.
^ permalink raw reply
* Re: [RFC net-next PATCH 4/5] net: new XDP feature for reading HW rxhash from drivers
From: Jakub Kicinski @ 2017-05-20 3:21 UTC (permalink / raw)
To: Alexei Starovoitov
Cc: Jesper Dangaard Brouer, Daniel Borkmann, John Fastabend, netdev
In-Reply-To: <20170520030750.c2b55oqdms5n764c@ast-mbp>
On Fri, 19 May 2017 20:07:52 -0700, Alexei Starovoitov wrote:
> How about exposing 'struct mlx5_cqe64 *' to XDP programs as-is?
> We can make sure that XDP program does read only access into it and
> it will see cqe->rss_hash_result, cqe->rss_hash_type and everything else
> in there, but this will not be uapi and it will be pretty obvious
> to program authors that their programs are vendor specific.
> 'not uapi' here means that mellanox is free to change their HW descriptor
> and its contents as they wish.
Hm.. Would that mean we have to teach the verifier about all possible
drivers and their metadata structures (i.e. sizes thereof). And add an
UAPI enum of known drivers?
Other idea I floated in early days was to standardize the fields but
let the driver "JIT" the accesses to look at the right offset of the
right structure. Admittedly that would be a lot more work.
^ permalink raw reply
* Re: [RFC net-next PATCH 4/5] net: new XDP feature for reading HW rxhash from drivers
From: Alexei Starovoitov @ 2017-05-20 3:07 UTC (permalink / raw)
To: Jesper Dangaard Brouer; +Cc: Daniel Borkmann, John Fastabend, netdev
In-Reply-To: <149512210827.14733.13997041998775151648.stgit@firesoul>
On Thu, May 18, 2017 at 05:41:48PM +0200, Jesper Dangaard Brouer wrote:
>
> +/* XDP rxhash have an associated type, which is related to the RSS
> + * (Receive Side Scaling) standard, but NIC HW have different mapping
> + * and support. Thus, create mapping that is interesting for XDP. XDP
> + * would primarly want insight into L3 and L4 protocol info.
> + *
> + * TODO: Likely need to get extended with "L3_IPV6_EX" due RSS standard
> + *
> + * The HASH_TYPE will be returned from bpf helper as the top 32-bit of
> + * the 64-bit rxhash (internally type stored in xdp_buff->flags).
> + */
> +#define XDP_HASH(x) ((x) & ((1ULL << 32)-1))
> +#define XDP_HASH_TYPE(x) ((x) >> 32)
> +
> +#define XDP_HASH_TYPE_L3_SHIFT 0
> +#define XDP_HASH_TYPE_L3_BITS 3
> +#define XDP_HASH_TYPE_L3_MASK ((1ULL << XDP_HASH_TYPE_L3_BITS)-1)
> +#define XDP_HASH_TYPE_L3(x) ((x) & XDP_HASH_TYPE_L3_MASK)
> +enum {
> + XDP_HASH_TYPE_L3_IPV4 = 1,
> + XDP_HASH_TYPE_L3_IPV6,
> +};
> +
> +#define XDP_HASH_TYPE_L4_SHIFT XDP_HASH_TYPE_L3_BITS
> +#define XDP_HASH_TYPE_L4_BITS 5
> +#define XDP_HASH_TYPE_L4_MASK \
> + (((1ULL << XDP_HASH_TYPE_L4_BITS)-1) << XDP_HASH_TYPE_L4_SHIFT)
> +#define XDP_HASH_TYPE_L4(x) ((x) & XDP_HASH_TYPE_L4_MASK)
> +enum {
> + _XDP_HASH_TYPE_L4_TCP = 1,
> + _XDP_HASH_TYPE_L4_UDP,
> +};
> +#define XDP_HASH_TYPE_L4_TCP (_XDP_HASH_TYPE_L4_TCP << XDP_HASH_TYPE_L4_SHIFT)
> +#define XDP_HASH_TYPE_L4_UDP (_XDP_HASH_TYPE_L4_UDP << XDP_HASH_TYPE_L4_SHIFT)
imo this is dangerous territory.
As far as I can see this information doesn't exist in the current drivers at all
and you're enabling it in the patch 5 via fancy:
+ u32 ht = (mlx5_htype_l4_to_xdp[((cht & CQE_RSS_HTYPE_L4) >> 6)] | \
+ mlx5_htype_l3_to_xdp[((cht & CQE_RSS_HTYPE_IP) >> 2)]);
It's pretty cool that you've discovered this hidden mlx5 feature
Did you find it in some hw spec ?
And it looks useful to me, but
1. i'm worried that we'd be relying on something that mellanox didn't
implement in their drivers before. Was it tested and guarnteed to exist
in the future revisions of firmware? Is it cx4 or cx4-lx or cx5 feature?
2. but the main concern that it is mellanox only feature. At least I cannot
see anything like this in broadcom and intel nics
In the very beginning we discussed that XDP programs should be as generic as
possible and HW independent while at the same time we want to expose HW
specific features to XDP programs.
So I'm totally fine to expose this fancy hw hash and ipv4 vs v6 and tcp vs udp
flags to xdp programs somehow, but I'm completely against making it into uapi.
How about exposing 'struct mlx5_cqe64 *' to XDP programs as-is?
We can make sure that XDP program does read only access into it and
it will see cqe->rss_hash_result, cqe->rss_hash_type and everything else
in there, but this will not be uapi and it will be pretty obvious
to program authors that their programs are vendor specific.
'not uapi' here means that mellanox is free to change their HW descriptor
and its contents as they wish.
Also no copies and bit conversions will be necessary, so the cost will
be zero to programs that don't use it and we wouldn't need to change
verifier to discover access to this stuff.
Note that bpf programs already have access to all in-kernel data structures
on the tracing side, so this is nothing new and tracing program authors
got used to structures changing from kernel to kernel.
XDP program authors can do the same for vendor specific bits while we
keep core XDP uapi generic across all nics.
^ permalink raw reply
* RE: [PATCH v3 net-next 1/5] dsa: add support for Microchip KSZ tail tagging
From: Woojung.Huh @ 2017-05-20 2:12 UTC (permalink / raw)
To: f.fainelli, andrew, vivien.didelot, sergei.shtylyov
Cc: netdev, davem, UNGLinuxDriver
In-Reply-To: <11dd6b8d-855c-0c97-a10b-79b2b7865eeb@gmail.com>
>> + if (padlen) {
>> + u8 *pad = skb_put(nskb, padlen);
>> +
>> + memset(pad, 0, padlen);
>> + }
>
>Can you use skb_put_padto() here instead of open coding this?
>
>> +
>> + tag = skb_put(nskb, KSZ_INGRESS_TAG_LEN);
>> + tag[0] = 0;
>> + tag[1] = 1 << p->dp->index; /* destnation port */
>
>typo: destination port
>
>With that fixed:
>
>Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
HI Florian,
Thanks for prompt reviews. Will submit another version.
- Woojung
^ permalink raw reply
* Re: [PATCH net-next] geneve: always fill CSUM6_RX configuration
From: Pravin Shelar @ 2017-05-20 1:57 UTC (permalink / raw)
To: Eric Garver; +Cc: Linux Kernel Network Developers
In-Reply-To: <20170518195956.12686-1-e@erig.me>
On Thu, May 18, 2017 at 12:59 PM, Eric Garver <e@erig.me> wrote:
> CSMU6_RX is relevant for collect_metadata as well. As such leave it
> outside of the dev's IPv4/IPv6 checks.
>
Can you explain it bit? is this flag used with ipv4 tunnels?
> Fixes: 9b4437a5b870 ("geneve: Unify LWT and netdev handling.")
> Signed-off-by: Eric Garver <e@erig.me>
> ---
> drivers/net/geneve.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
> index dec5d563ab19..f557d1dc3f9b 100644
> --- a/drivers/net/geneve.c
> +++ b/drivers/net/geneve.c
> @@ -1311,13 +1311,13 @@ static int geneve_fill_info(struct sk_buff *skb, const struct net_device *dev)
> if (nla_put_u8(skb, IFLA_GENEVE_UDP_ZERO_CSUM6_TX,
> !(info->key.tun_flags & TUNNEL_CSUM)))
> goto nla_put_failure;
> -
> - if (nla_put_u8(skb, IFLA_GENEVE_UDP_ZERO_CSUM6_RX,
> - !geneve->use_udp6_rx_checksums))
> - goto nla_put_failure;
> #endif
> }
>
> + if (nla_put_u8(skb, IFLA_GENEVE_UDP_ZERO_CSUM6_RX,
> + !geneve->use_udp6_rx_checksums))
> + goto nla_put_failure;
> +
> if (nla_put_u8(skb, IFLA_GENEVE_TTL, info->key.ttl) ||
> nla_put_u8(skb, IFLA_GENEVE_TOS, info->key.tos) ||
> nla_put_be32(skb, IFLA_GENEVE_LABEL, info->key.label))
> --
> 2.12.0
>
^ permalink raw reply
* [PATCH] i40e: Fix incorrect pf->flags
From: Tushar Dave @ 2017-05-20 1:01 UTC (permalink / raw)
To: jeffrey.t.kirsher, intel-wired-lan, netdev
Fix bug introduced by 'commit 47994c119a36e ("i40e: remove
hw_disabled_flags in favor of using separate flag bits")' that
mistakenly wipes out pf->flags.
Signed-off-by: Tushar Dave <tushar.n.dave@oracle.com>
---
drivers/net/ethernet/intel/i40e/i40e_main.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index d5c9c9e..6b98d34 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -8821,9 +8821,9 @@ static int i40e_sw_init(struct i40e_pf *pf)
(pf->hw.aq.api_min_ver > 4))) {
/* Supported in FW API version higher than 1.4 */
pf->flags |= I40E_FLAG_GENEVE_OFFLOAD_CAPABLE;
- pf->flags = I40E_FLAG_HW_ATR_EVICT_CAPABLE;
+ pf->flags |= I40E_FLAG_HW_ATR_EVICT_CAPABLE;
} else {
- pf->flags = I40E_FLAG_HW_ATR_EVICT_CAPABLE;
+ pf->flags |= I40E_FLAG_HW_ATR_EVICT_CAPABLE;
}
pf->eeprom_version = 0xDEAD;
--
1.9.1
^ permalink raw reply related
* Re: [PATCH v2 1/3] bpf: Use 1<<16 as ceiling for immediate alignment in verifier.
From: Alexei Starovoitov @ 2017-05-20 0:20 UTC (permalink / raw)
To: David Miller; +Cc: ecree, daniel, alexei.starovoitov, netdev
In-Reply-To: <20170519.191615.136362788931426782.davem@davemloft.net>
On 5/19/17 4:16 PM, David Miller wrote:
> From: Alexei Starovoitov <ast@fb.com>
> Date: Fri, 19 May 2017 14:37:56 -0700
>
>> On 5/19/17 1:41 PM, David Miller wrote:
>>> From: Edward Cree <ecree@solarflare.com>
>>> Date: Fri, 19 May 2017 18:17:42 +0100
>>>
>>>> One question: is there a way to build the verifier as userland code
>>>> (or at least as a module), or will I have to reboot every time I
>>>> want to test a change?
>>>
>>> There currently is no such machanism, you will have to reboot every
>>> time.
>>>
>>> I have considered working on making the code buildable outside of the
>>> kernel. It shouldn't be too hard.
>>
>> it's not hard.
>> We did it twice and both times abandoned.
>> First time to have 'user space verifier' to check programs before
>> loading and second time for fuzzing via llvm.
>> Abandoned since it diverges very quickly from kernel.
>>
>
> Well, my idea was the create an environment in which kernel verifier.c
> could be built as-is.
>
> Maybe there would be some small compromises in verifier.c such as an
> ifdef test or two, but that should be it.
that's exactly what we did the first time. Added few ifdef to verifier.c
Second time we went even further by compiling kernel/bpf/verifier.c
as-is and linking everything magically via user space hooks
all the way that test_verifier.c runs as-is but calling
bpf_check() function that was compiled for user space via clang.
That code is here:
https://github.com/iovisor/bpf-fuzzer
It's definitely possible to refresh it and make it work again.
My point that unless we put such 'lets build verifier.c for user space'
as part of tools/testing/selftests/ or something, such project is
destined to bit rot.
^ permalink raw reply
* Re: [PATCH v3 net-next 3/5] dsa: add DSA switch driver for Microchip KSZ9477
From: Florian Fainelli @ 2017-05-20 0:10 UTC (permalink / raw)
To: Woojung.Huh, andrew, vivien.didelot, sergei.shtylyov
Cc: netdev, davem, UNGLinuxDriver
In-Reply-To: <9235D6609DB808459E95D78E17F2E43D40A7C023@CHN-SV-EXMX02.mchp-main.com>
On 05/19/2017 03:57 PM, Woojung.Huh@microchip.com wrote:
> From: Woojung Huh <Woojung.Huh@microchip.com>
>
> The KSZ9477 is a fully integrated layer 2, managed, 7 ports GigE switch
> with numerous advanced features. 5 ports incorporate 10/100/1000 Mbps PHYs.
> The other 2 ports have interfaces that can be configured as SGMII, RGMII, MII
> or RMII. Either of these may connect directly to a host processor or
> to an external PHY. The SGMII port may interface to a fiber optic transceiver.
>
> This driver currently supports vlan, fdb, mdb & mirror dsa switch operations.
>
> Signed-off-by: Woojung Huh <Woojung.Huh@microchip.com>
Looks great, thanks Woojung!
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
--
Florian
^ permalink raw reply
* Re: [PATCH v3 net-next 4/5] dsa: Add spi support to Microchip KSZ switches
From: Florian Fainelli @ 2017-05-20 0:05 UTC (permalink / raw)
To: Woojung.Huh, andrew, vivien.didelot, sergei.shtylyov
Cc: netdev, davem, UNGLinuxDriver
In-Reply-To: <9235D6609DB808459E95D78E17F2E43D40A7C042@CHN-SV-EXMX02.mchp-main.com>
On 05/19/2017 03:57 PM, Woojung.Huh@microchip.com wrote:
> From: Woojung Huh <Woojung.Huh@microchip.com>
>
> A sample SPI configuration for Microchip KSZ switches.
>
> Signed-off-by: Woojung Huh <Woojung.Huh@microchip.com>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Subject should be something like:
dt-bindings: net: dsa: Add Microchip KSZ switches binding
With that fixed and the nits below:
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
> Documentation/devicetree/bindings/net/dsa/ksz.txt | 73 +++++++++++++++++++++++
> 1 file changed, 73 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/net/dsa/ksz.txt
>
> diff --git a/Documentation/devicetree/bindings/net/dsa/ksz.txt b/Documentation/devicetree/bindings/net/dsa/ksz.txt
> new file mode 100644
> index 0000000..8a13966
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/dsa/ksz.txt
> @@ -0,0 +1,73 @@
> +Microchip KSZ Series Ethernet switches
> +==================================
> +
> +Required properties:
> +
> +- compatible: For external switch chips, compatible string must be exactly one
> + of: "microchip,ksz9477"
> +
> +See Documentation/devicetree/bindings/dsa/dsa.txt for a list of additional
> +required and optional properties.
> +
> +Examples:
> +
> +Ethernet switch connected via SPI to the host, CPU port wired to eth0:
> +
> + eth0: ethernet@10001000 {
> + fixed-link {
> + reg = <7>
There is a missing semicolon, and for a fixed-link, there is no "reg"
property.
> + speed = <1000>;
> + duplex-full;
Actually the correct property is named "full-duplex" (like you put it
for the switch)
> + };
> + };
> +
> + spi1: spi@f8008000 {
> + pinctrl-0 = <&pinctrl_spi_ksz>;
> + cs-gpios = <&pioC 25 0>;
> + id = <1>;
> + status = "okay";
> +
> + ksz9477: ksz9477@0 {
> + compatible = "microchip,ksz9477";
> + reg = <0>;
> +
> + spi-max-frequency = <44000000>;
> + spi-cpha;
> + spi-cpol;
> +
> + status = "okay";
> + ports {
> + #address-cells = <1>;
> + #size-cells = <0>;
> + port@0 {
> + reg = <0>;
> + label = "lan1";
> + };
> + port@1 {
> + reg = <1>;
> + label = "lan2";
> + };
> + port@2 {
> + reg = <2>;
> + label = "lan3";
> + };
> + port@3 {
> + reg = <3>;
> + label = "lan4";
> + };
> + port@4 {
> + reg = <4>;
> + label = "lan5";
> + };
> + port@5 {
> + reg = <5>;
> + label = "cpu";
> + ethernet = <ð0>;
> + fixed-link {
> + speed = <1000>;
> + full-duplex;
> + };
> + };
> + };
> + };
> + };
>
--
Florian
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox