* 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: 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: 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: [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
* [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
* [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-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
* 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 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
* [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 0/2] vhost/scsi: Adjustments for five function implementations
From: SF Markus Elfring @ 2017-05-20 14:30 UTC (permalink / raw)
To: kvm, netdev, virtualization, Jason Wang, Michael S. Tsirkin
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 20 May 2017 16:25:04 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Improve a size determination in four functions
Delete error messages for failed memory allocations in five functions
drivers/vhost/scsi.c | 33 +++++++++++----------------------
1 file changed, 11 insertions(+), 22 deletions(-)
--
2.13.0
^ permalink raw reply
* [PATCH 1/2] vhost/scsi: Improve a size determination in four functions
From: SF Markus Elfring @ 2017-05-20 14:31 UTC (permalink / raw)
To: kvm, netdev, virtualization, Jason Wang, Michael S. Tsirkin
Cc: LKML, kernel-janitors
In-Reply-To: <bafa65e4-08fe-efdb-d836-7657e8a64749@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 20 May 2017 13:48:44 +0200
Replace the specification of four data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/vhost/scsi.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index fd6c8b66f06f..650533916c19 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -597,8 +597,7 @@ vhost_scsi_get_tag(struct vhost_virtqueue *vq, struct vhost_scsi_tpg *tpg,
sg = cmd->tvc_sgl;
prot_sg = cmd->tvc_prot_sgl;
pages = cmd->tvc_upages;
- memset(cmd, 0, sizeof(struct vhost_scsi_cmd));
-
+ memset(cmd, 0, sizeof(*cmd));
cmd->tvc_sgl = sg;
cmd->tvc_prot_sgl = prot_sg;
cmd->tvc_upages = pages;
@@ -1757,5 +1756,5 @@ static int vhost_scsi_make_nexus(struct vhost_scsi_tpg *tpg,
return -EEXIST;
}
- tv_nexus = kzalloc(sizeof(struct vhost_scsi_nexus), GFP_KERNEL);
+ tv_nexus = kzalloc(sizeof(*tv_nexus), GFP_KERNEL);
if (!tv_nexus) {
@@ -1958,5 +1957,5 @@ vhost_scsi_make_tpg(struct se_wwn *wwn,
if (kstrtou16(name + 5, 10, &tpgt) || tpgt >= VHOST_SCSI_MAX_TARGET)
return ERR_PTR(-EINVAL);
- tpg = kzalloc(sizeof(struct vhost_scsi_tpg), GFP_KERNEL);
+ tpg = kzalloc(sizeof(*tpg), GFP_KERNEL);
if (!tpg) {
@@ -2012,5 +2011,5 @@ vhost_scsi_make_tport(struct target_fabric_configfs *tf,
/* if (vhost_scsi_parse_wwn(name, &wwpn, 1) < 0)
return ERR_PTR(-EINVAL); */
- tport = kzalloc(sizeof(struct vhost_scsi_tport), GFP_KERNEL);
+ tport = kzalloc(sizeof(*tport), GFP_KERNEL);
if (!tport) {
--
2.13.0
^ permalink raw reply related
* [PATCH 2/2] vhost/scsi: Delete error messages for failed memory allocations in five functions
From: SF Markus Elfring @ 2017-05-20 14:32 UTC (permalink / raw)
To: kvm, netdev, virtualization, Jason Wang, Michael S. Tsirkin
Cc: LKML, kernel-janitors, Wolfram Sang
In-Reply-To: <bafa65e4-08fe-efdb-d836-7657e8a64749@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 20 May 2017 15:50:30 +0200
Omit seven extra messages for memory allocation failures in these functions.
This issue was detected by using the Coccinelle software.
Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/vhost/scsi.c | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index 650533916c19..49d07950e2e5 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -417,5 +417,4 @@ vhost_scsi_allocate_evt(struct vhost_scsi *vs,
if (!evt) {
- vq_err(vq, "Failed to allocate vhost_scsi_evt\n");
vs->vs_events_missed = true;
return NULL;
}
@@ -1722,21 +1721,15 @@ static int vhost_scsi_nexus_cb(struct se_portal_group *se_tpg,
- if (!tv_cmd->tvc_sgl) {
- pr_err("Unable to allocate tv_cmd->tvc_sgl\n");
+ if (!tv_cmd->tvc_sgl)
goto out;
- }
tv_cmd->tvc_upages = kzalloc(sizeof(struct page *) *
VHOST_SCSI_PREALLOC_UPAGES, GFP_KERNEL);
- if (!tv_cmd->tvc_upages) {
- pr_err("Unable to allocate tv_cmd->tvc_upages\n");
+ if (!tv_cmd->tvc_upages)
goto out;
- }
tv_cmd->tvc_prot_sgl = kzalloc(sizeof(struct scatterlist) *
VHOST_SCSI_PREALLOC_PROT_SGLS, GFP_KERNEL);
- if (!tv_cmd->tvc_prot_sgl) {
- pr_err("Unable to allocate tv_cmd->tvc_prot_sgl\n");
+ if (!tv_cmd->tvc_prot_sgl)
goto out;
- }
}
return 0;
out:
@@ -1760,6 +1753,5 @@ static int vhost_scsi_make_nexus(struct vhost_scsi_tpg *tpg,
if (!tv_nexus) {
mutex_unlock(&tpg->tv_tpg_mutex);
- pr_err("Unable to allocate struct vhost_scsi_nexus\n");
return -ENOMEM;
}
/*
@@ -1961,7 +1953,6 @@ vhost_scsi_make_tpg(struct se_wwn *wwn,
- if (!tpg) {
- pr_err("Unable to allocate struct vhost_scsi_tpg");
+ if (!tpg)
return ERR_PTR(-ENOMEM);
- }
+
mutex_init(&tpg->tv_tpg_mutex);
INIT_LIST_HEAD(&tpg->tv_tpg_list);
tpg->tport = tport;
@@ -2015,7 +2006,6 @@ vhost_scsi_make_tport(struct target_fabric_configfs *tf,
- if (!tport) {
- pr_err("Unable to allocate struct vhost_scsi_tport");
+ if (!tport)
return ERR_PTR(-ENOMEM);
- }
+
tport->tport_wwpn = wwpn;
/*
* Determine the emulated Protocol Identifier and Target Port Name
--
2.13.0
^ permalink raw reply related
* Re: [PATCH net-next v4] net: ipv6: fix code style error and warning of ndisc.c
From: Joe Perches @ 2017-05-20 14:55 UTC (permalink / raw)
To: yuan linyu, netdev; +Cc: David S . Miller, yuan linyu
In-Reply-To: <1495288650-17072-1-git-send-email-cugyly@163.com>
On Sat, 2017-05-20 at 21:57 +0800, yuan linyu wrote:
> From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
[]
> diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
[]
> @@ -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:
If you are going to do these 80 column line length changes,
(and they are not really useful or necessary here), perhaps
it'd be better to use a temporary to reduce the line length.
Something like:
---
net/ipv6/ndisc.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index d310dc41209a..a8521bc86795 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -234,20 +234,28 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
case ND_OPT_TARGET_LL_ADDR:
case ND_OPT_MTU:
case ND_OPT_NONCE:
- case ND_OPT_REDIRECT_HDR:
- if (ndopts->nd_opt_array[nd_opt->nd_opt_type]) {
+ case ND_OPT_REDIRECT_HDR: {
+ struct nd_opt_hdr **hdr;
+
+ hdr = &ndopts->nd_opt_array[nd_opt->nd_opt_type];
+ if (*hdr) {
ND_PRINTK(2, warn,
"%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;
+ *hdr = nd_opt;
}
break;
- case ND_OPT_PREFIX_INFO:
+ }
+ case ND_OPT_PREFIX_INFO: {
+ struct nd_opt_hdr **hdr;
+
+ hdr = &ndopts->nd_opt_array[nd_opt->nd_opt_type];
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;
+ if (!*hdr)
+ *hdr = nd_opt;
break;
+ }
#ifdef CONFIG_IPV6_ROUTE_INFO
case ND_OPT_ROUTE_INFO:
ndopts->nd_opts_ri_end = nd_opt;
^ permalink raw reply related
* Re: [RFC net-next PATCH 4/5] net: new XDP feature for reading HW rxhash from drivers
From: Tom Herbert @ 2017-05-20 16:16 UTC (permalink / raw)
To: Jesper Dangaard Brouer
Cc: Daniel Borkmann, Alexei Starovoitov, John Fastabend,
Linux Kernel Network Developers
In-Reply-To: <149512210827.14733.13997041998775151648.stgit@firesoul>
On Thu, May 18, 2017 at 8:41 AM, Jesper Dangaard Brouer
<brouer@redhat.com> wrote:
> Introducing a new XDP feature and associated bpf helper bpf_xdp_rxhash.
>
> The rxhash and type allow filtering on packets without touching
> packet memory. The performance difference on my system with a
> 100 Gbit/s mlx5 NIC is 12Mpps to 19Mpps.
>
> TODO: desc RXHASH and associated type, and how XDP choose to map
> and export these to bpf_prog's.
>
> TODO: desc how this interacts with XDP driver features system.
> ---
> include/linux/filter.h | 31 ++++++++++++++++-
> include/linux/netdev_features.h | 4 ++
> include/uapi/linux/bpf.h | 56 +++++++++++++++++++++++++++++-
> kernel/bpf/verifier.c | 3 ++
> net/core/dev.c | 16 ++++++++-
> net/core/filter.c | 73 +++++++++++++++++++++++++++++++++++++++
> samples/bpf/bpf_helpers.h | 2 +
> tools/include/uapi/linux/bpf.h | 10 +++++
> 8 files changed, 190 insertions(+), 5 deletions(-)
>
> diff --git a/include/linux/filter.h b/include/linux/filter.h
> index 9a7786db14fa..33a254ccd47d 100644
> --- a/include/linux/filter.h
> +++ b/include/linux/filter.h
> @@ -413,7 +413,8 @@ struct bpf_prog {
> locked:1, /* Program image locked? */
> gpl_compatible:1, /* Is filter GPL compatible? */
> cb_access:1, /* Is control block accessed? */
> - dst_needed:1; /* Do we need dst entry? */
> + dst_needed:1, /* Do we need dst entry? */
> + xdp_rxhash_needed:1;/* Req XDP RXHASH support */
> kmemcheck_bitfield_end(meta);
> enum bpf_prog_type type; /* Type of BPF program */
> u32 len; /* Number of filter blocks */
> @@ -444,12 +445,40 @@ struct bpf_skb_data_end {
> void *data_end;
> };
>
> +/* Kernel internal xdp_buff->flags */
> +#define XDP_CTX_F_RXHASH_TYPE_MASK XDP_HASH_TYPE_MASK
> +#define XDP_CTX_F_RXHASH_TYPE_BITS XDP_HASH_TYPE_BITS
> +#define XDP_CTX_F_RXHASH_SW (1ULL << XDP_CTX_F_RXHASH_TYPE_BITS)
> +#define XDP_CTX_F_RXHASH_HW (1ULL << (XDP_CTX_F_RXHASH_TYPE_BITS+1))
> +
> struct xdp_buff {
> void *data;
> void *data_end;
> void *data_hard_start;
> + u64 flags;
> + u32 rxhash;
> };
>
> +/* helper functions for driver setting rxhash */
> +static inline void
> +xdp_record_hash(struct xdp_buff *xdp, u32 hash, u32 type)
> +{
> + xdp->flags |= XDP_CTX_F_RXHASH_HW;
> + xdp->flags |= type & XDP_CTX_F_RXHASH_TYPE_MASK;
> + xdp->rxhash = hash;
> +}
> +
> +static inline void
> +xdp_set_skb_hash(struct xdp_buff *xdp, struct sk_buff *skb)
> +{
> + if (likely(xdp->flags & (XDP_CTX_F_RXHASH_HW|XDP_CTX_F_RXHASH_SW))) {
> + bool is_sw = !!(xdp->flags | XDP_CTX_F_RXHASH_SW);
> + bool is_l4 = !!(xdp->flags & XDP_HASH_TYPE_L4_MASK);
> +
> + __skb_set_hash(skb, xdp->rxhash, is_sw, is_l4);
> + }
> +}
> +
> /* compute the linear packet data range [data, data_end) which
> * will be accessed by cls_bpf, act_bpf and lwt programs
> */
> diff --git a/include/linux/netdev_features.h b/include/linux/netdev_features.h
> index ff81ee231410..4b50e8c606c5 100644
> --- a/include/linux/netdev_features.h
> +++ b/include/linux/netdev_features.h
> @@ -219,11 +219,13 @@ enum {
> /* XDP driver flags */
> enum {
> XDP_DRV_F_ENABLED_BIT,
> + XDP_DRV_F_RXHASH_BIT,
> };
>
> #define __XDP_DRV_F_BIT(bit) ((netdev_features_t)1 << (bit))
> #define __XDP_DRV_F(name) __XDP_DRV_F_BIT(XDP_DRV_F_##name##_BIT)
> #define XDP_DRV_F_ENABLED __XDP_DRV_F(ENABLED)
> +#define XDP_DRV_F_RXHASH __XDP_DRV_F(RXHASH)
>
> /* XDP driver MUST support these features, else kernel MUST reject
> * bpf_prog to guarantee safe access to data structures
> @@ -233,7 +235,7 @@ enum {
> /* Some XDP features are under development. Based on bpf_prog loading
> * detect if kernel feature can be activated.
> */
> -#define XDP_DRV_FEATURES_DEVEL 0
> +#define XDP_DRV_FEATURES_DEVEL XDP_DRV_F_RXHASH
>
> /* Some XDP features are optional, like action return code, as they
> * are handled safely runtime.
> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
> index 945a1f5f63c5..1d9d3a46217d 100644
> --- a/include/uapi/linux/bpf.h
> +++ b/include/uapi/linux/bpf.h
> @@ -482,6 +482,9 @@ union bpf_attr {
> * Get the owner uid of the socket stored inside sk_buff.
> * @skb: pointer to skb
> * Return: uid of the socket owner on success or overflowuid if failed.
> + *
> + * u64 bpf_xdp_rxhash(xdp_md, new_hash, type, flags)
> + * TODO: MISSING DESC
> */
> #define __BPF_FUNC_MAPPER(FN) \
> FN(unspec), \
> @@ -531,7 +534,8 @@ union bpf_attr {
> FN(xdp_adjust_head), \
> FN(probe_read_str), \
> FN(get_socket_cookie), \
> - FN(get_socket_uid),
> + FN(get_socket_uid), \
> + FN(xdp_rxhash),
>
> /* integer value in 'imm' field of BPF_CALL instruction selects which helper
> * function eBPF program intends to call
> @@ -581,6 +585,10 @@ enum bpf_func_id {
> /* BPF_FUNC_perf_event_output for sk_buff input context. */
> #define BPF_F_CTXLEN_MASK (0xfffffULL << 32)
>
> +/* BPF_FUNC_xdp_rxhash flags */
> +#define BPF_F_RXHASH_SET 0ULL
> +#define BPF_F_RXHASH_GET (1ULL << 0)
> +
> /* user accessible mirror of in-kernel sk_buff.
> * new fields can only be added to the end of this structure
> */
> @@ -660,6 +668,52 @@ enum xdp_action {
> struct xdp_md {
> __u32 data;
> __u32 data_end;
> + __u32 rxhash;
> + /* (FIXME delete comment)
> + * Discussion: If choosing to support direct read, then I
> + * (believe) having a separate 'rxhash_type' is easier and
> + * faster to implement. (Else I have to do BPF instruction
> + * hacks to move the type into upper bits of 'rxhash', which I
> + * couldn't figureout how to do ;-))
> + */
> + __u32 rxhash_type;
> };
>
> +/* 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)
> +
Hi Jesper,
Why do we need these indicators for protocol specific hash? It seems
like L4 and L3 is useful differentiation and protocol agnostic (I'm
still holding out hope that SCTP will be deployed some day ;-) )
Tom
> +#define XDP_HASH_TYPE_BITS (XDP_HASH_TYPE_L3_BITS + XDP_HASH_TYPE_L4_BITS)
> +#define XDP_HASH_TYPE_MASK (XDP_HASH_TYPE_L3_MASK | XDP_HASH_TYPE_L4_MASK)
> +
> #endif /* _UAPI__LINUX_BPF_H__ */
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 6f8b6ed690be..248bc113ad18 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -3346,6 +3346,8 @@ static int fixup_bpf_calls(struct bpf_verifier_env *env)
> prog->dst_needed = 1;
> if (insn->imm == BPF_FUNC_get_prandom_u32)
> bpf_user_rnd_init_once();
> + if (insn->imm == BPF_FUNC_xdp_rxhash)
> + prog->xdp_rxhash_needed = 1;
> if (insn->imm == BPF_FUNC_tail_call) {
> /* If we tail call into other programs, we
> * cannot make any assumptions since they can
> @@ -3353,6 +3355,7 @@ static int fixup_bpf_calls(struct bpf_verifier_env *env)
> * the program array.
> */
> prog->cb_access = 1;
> + prog->xdp_rxhash_needed = 1;
>
> /* mark bpf_tail_call as different opcode to avoid
> * conditional branch in the interpeter for every normal
> diff --git a/net/core/dev.c b/net/core/dev.c
> index b4af5fbbd9da..28082067ac00 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -4318,9 +4318,13 @@ static u32 netif_receive_generic_xdp(struct sk_buff *skb,
> xdp.data_end = xdp.data + hlen;
> xdp.data_hard_start = skb->data - skb_headroom(skb);
> orig_data = xdp.data;
> + xdp.flags = 0;
> + xdp.rxhash = skb->hash;
>
> act = bpf_prog_run_xdp(xdp_prog, &xdp);
>
> + xdp_set_skb_hash(&xdp, skb);
> +
> off = xdp.data - orig_data;
> if (off > 0)
> __skb_pull(skb, off);
> @@ -6851,10 +6855,20 @@ int dev_change_proto_down(struct net_device *dev, bool proto_down)
> }
> EXPORT_SYMBOL(dev_change_proto_down);
>
> +netdev_features_t bpf_get_xdp_features(struct bpf_prog *prog)
> +{
> + netdev_features_t features = XDP_DRV_FEATURES_REQUIRED;
> +
> + if (prog->xdp_rxhash_needed)
> + features |= XDP_DRV_F_RXHASH;
> +
> + return features;
> +}
> +
> bool xdp_features_check(struct net_device *dev, struct bpf_prog *xdp_prog,
> struct netlink_ext_ack *extack, u32 flags)
> {
> - netdev_features_t req_features = XDP_DRV_FEATURES_REQUIRED;
> + netdev_features_t req_features = bpf_get_xdp_features(xdp_prog);
> netdev_features_t dev_xdp_features;
>
> /* Generic XDP naturally support all features */
> diff --git a/net/core/filter.c b/net/core/filter.c
> index a253a6197e6b..df04ac73f581 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -2272,6 +2272,54 @@ static const struct bpf_func_proto bpf_xdp_adjust_head_proto = {
> .arg2_type = ARG_ANYTHING,
> };
>
> +BPF_CALL_4(bpf_xdp_rxhash, struct xdp_buff *, xdp, u32, new_hash, u32, type,
> + unsigned int, flags)
> +{
> + /* Read+write access to xdp_buff->rxhash is safe, because
> + * fixup_bpf_calls() detect when helper is used, and drivers
> + * not implemeting rxhash will not be allowed to load bpf_prog.
> + */
> +
> + /* Set hash and type */
> + if (flags == BPF_F_RXHASH_SET) {
> + xdp->rxhash = new_hash;
> + xdp->flags |= XDP_CTX_F_RXHASH_SW; /* Need for skb "is_sw" */
> + xdp->flags |= type & XDP_CTX_F_RXHASH_TYPE_MASK;
> + }
> +
> + /* Get can specify "type" interested in */
> + if ((flags == BPF_F_RXHASH_GET) &&
> + (type & XDP_CTX_F_RXHASH_TYPE_MASK)) {
> + u32 f_type = (xdp->flags & XDP_CTX_F_RXHASH_TYPE_MASK);
> + bool match = false;
> +
> + /* Match on either L3 or L4 type rxhash */
> + if (!((type ^ f_type) & XDP_HASH_TYPE_L3_MASK))
> + match = true;
> + if (!((type ^ f_type) & XDP_HASH_TYPE_L4_MASK))
> + match = true;
> + if (match == false)
> + return 0;
> + }
> +
> + /* Drivers only xdp_record_hash if NETIF_F_RXHASH enabled */
> + if (likely(xdp->flags & (XDP_CTX_F_RXHASH_HW|XDP_CTX_F_RXHASH_SW))) {
> + u64 rxhash_type = xdp->flags & XDP_CTX_F_RXHASH_TYPE_MASK;
> +
> + return (u64)(xdp->rxhash | (rxhash_type << 32));
> + }
> + return 0;
> +}
> +
> +static const struct bpf_func_proto bpf_xdp_rxhash_proto = {
> + .func = bpf_xdp_rxhash,
> + .gpl_only = false,
> + .ret_type = RET_INTEGER, // Q: how do I say "u64" ?
> + .arg1_type = ARG_PTR_TO_CTX,
> + .arg2_type = ARG_ANYTHING,
> + .arg3_type = ARG_ANYTHING,
> +};
> +
> bool bpf_helper_changes_pkt_data(void *func)
> {
> if (func == bpf_skb_vlan_push ||
> @@ -2760,6 +2808,8 @@ xdp_func_proto(enum bpf_func_id func_id)
> return &bpf_get_smp_processor_id_proto;
> case BPF_FUNC_xdp_adjust_head:
> return &bpf_xdp_adjust_head_proto;
> + case BPF_FUNC_xdp_rxhash:
> + return &bpf_xdp_rxhash_proto;
> default:
> return bpf_base_func_proto(func_id);
> }
> @@ -3308,6 +3358,29 @@ static u32 xdp_convert_ctx_access(enum bpf_access_type type,
> si->dst_reg, si->src_reg,
> offsetof(struct xdp_buff, data_end));
> break;
> + case offsetof(struct xdp_md, rxhash):
> + /* Direct read-access to rxhash is safe, as drivers
> + * not implementing will not be allowed to load bpf_prog.
> + *
> + * Driver gotchas: Even if NETIF_F_RXHASH is disabled
> + * drivers must init xdp_buff->rxhash, due to this
> + * direct read.
> + */
> + prog->xdp_rxhash_needed = 1;
> +
> + BUILD_BUG_ON(FIELD_SIZEOF(struct xdp_buff, rxhash) != 4);
> + *insn++ = BPF_LDX_MEM(BPF_W, si->dst_reg, si->src_reg,
> + offsetof(struct xdp_buff, rxhash));
> + break;
> + case offsetof(struct xdp_md, rxhash_type):
> + /* rxhash_type stored in lower 8-bits of xdp_buff->flags */
> + prog->xdp_rxhash_needed = 1;
> +
> + BUILD_BUG_ON(XDP_HASH_TYPE_BITS != 8);
> + /* Load first 8 bits (BPF_B) of flags */
> + *insn++ = BPF_LDX_MEM(BPF_B, si->dst_reg, si->src_reg,
> + offsetof(struct xdp_buff, flags));
> + break;
> }
>
> return insn - insn_buf;
> diff --git a/samples/bpf/bpf_helpers.h b/samples/bpf/bpf_helpers.h
> index 9a9c95f2c9fb..634a976a02c6 100644
> --- a/samples/bpf/bpf_helpers.h
> +++ b/samples/bpf/bpf_helpers.h
> @@ -59,6 +59,8 @@ static unsigned long long (*bpf_get_prandom_u32)(void) =
> (void *) BPF_FUNC_get_prandom_u32;
> static int (*bpf_xdp_adjust_head)(void *ctx, int offset) =
> (void *) BPF_FUNC_xdp_adjust_head;
> +static unsigned long long (*bpf_xdp_rxhash)(void *ctx, __u32 new_hash, __u32 type, unsigned int flags) =
> + (void *) BPF_FUNC_xdp_rxhash;
>
> /* llvm builtin functions that eBPF C program may use to
> * emit BPF_LD_ABS and BPF_LD_IND instructions
> diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
> index e553529929f6..a38c544bf6f0 100644
> --- a/tools/include/uapi/linux/bpf.h
> +++ b/tools/include/uapi/linux/bpf.h
> @@ -483,6 +483,9 @@ union bpf_attr {
> * @skb: pointer to skb
> * Return: uid of the socket owner on success or 0 if the socket pointer
> * inside sk_buff is NULL
> + *
> + * u64 bpf_xdp_rxhash(xdp_md, new_hash, type, flags)
> + * FIXME: Copy desc from include/uapi/linux/bpf.h
> */
> #define __BPF_FUNC_MAPPER(FN) \
> FN(unspec), \
> @@ -532,7 +535,8 @@ union bpf_attr {
> FN(xdp_adjust_head), \
> FN(probe_read_str), \
> FN(get_socket_cookie), \
> - FN(get_socket_uid),
> + FN(get_socket_uid), \
> + FN(xdp_rxhash),
>
> /* integer value in 'imm' field of BPF_CALL instruction selects which helper
> * function eBPF program intends to call
> @@ -661,6 +665,10 @@ enum xdp_action {
> struct xdp_md {
> __u32 data;
> __u32 data_end;
> + __u32 rxhash;
> + __u32 rxhash_type;
> };
>
> +// FIXME: Sync with include/uapi/linux/bpf.h
> +
> #endif /* _UAPI__LINUX_BPF_H__ */
>
^ permalink raw reply
* Re: arch: arm: bpf: Converting cBPF to eBPF for arm 32 bit
From: Shubham Bansal @ 2017-05-20 20:01 UTC (permalink / raw)
To: Daniel Borkmann
Cc: Kees Cook, David Miller, Mircea Gherzan, Network Development,
kernel-hardening@lists.openwall.com,
linux-arm-kernel@lists.infradead.org, ast
In-Reply-To: <591A07A1.1030006@iogearbox.net>
Hi Daniel and Kees,
Before I send the patch, I have tested the JIT compiler on ARMv7 but
not on ARMv5 or ARMv6. So can you tell me which arch versions I should
test it for?
Also for my testing, CONFIG_FRAME_POINTER and CONFIG_CPU_BIG_ENDIAN
are both disabled. But I need to test JIT with these flags as well.
Whenever I put these flags in .config file, the arm kernel is not
getting compiler with these flags. Can you tell me why? If you need
more information regarding this, please let me know.
With current config for ARMv7, benchmarks are :
[root@vexpress modules]# insmod test_bpf.ko
[ 25.797766] test_bpf: #0 TAX jited:1 180 170 169 PASS
[ 25.811395] test_bpf: #1 TXA jited:1 93 89 111 PASS
[ 25.815073] test_bpf: #2 ADD_SUB_MUL_K jited:1 94 PASS
[ 25.816779] test_bpf: #3 DIV_MOD_KX jited:1 983 PASS
[ 25.827310] test_bpf: #4 AND_OR_LSH_K jited:1 94 93 PASS
[ 25.829843] test_bpf: #5 LD_IMM_0 jited:1 83 PASS
[ 25.831260] test_bpf: #6 LD_IND jited:1 338 266 305 PASS
[ 25.840970] test_bpf: #7 LD_ABS jited:1 343 304 289 PASS
[ 25.851005] test_bpf: #8 LD_ABS_LL jited:1 362 300 PASS
[ 25.858119] test_bpf: #9 LD_IND_LL jited:1 244 241 245 PASS
[ 25.865994] test_bpf: #10 LD_ABS_NET jited:1 318 316 PASS
[ 25.872829] test_bpf: #11 LD_IND_NET jited:1 243 196 196 PASS
[ 25.879717] test_bpf: #12 LD_PKTTYPE jited:1 129 140 PASS
[ 25.883034] test_bpf: #13 LD_MARK jited:1 113 88 PASS
[ 25.885545] test_bpf: #14 LD_RXHASH jited:1 81 79 PASS
[ 25.887506] test_bpf: #15 LD_QUEUE jited:1 88 85 PASS
[ 25.889593] test_bpf: #16 LD_PROTOCOL jited:1 322 353 PASS
[ 25.896894] test_bpf: #17 LD_VLAN_TAG jited:1 92 92 PASS
[ 25.899173] test_bpf: #18 LD_VLAN_TAG_PRESENT jited:1 85 88 PASS
[ 25.901310] test_bpf: #19 LD_IFINDEX jited:1 94 130 PASS
[ 25.904110] test_bpf: #20 LD_HATYPE jited:1 98 91 PASS
[ 25.906393] test_bpf: #21 LD_CPU
[ 25.906651] bpf_jit: *** NOT YET: opcode 85 ***
[ 25.906795] jited:0 705 691 PASS
[ 25.921007] test_bpf: #22 LD_NLATTR jited:0 577 668 PASS
[ 25.933870] test_bpf: #23 LD_NLATTR_NEST jited:0 2253 3006 PASS
[ 25.987020] test_bpf: #24 LD_PAYLOAD_OFF jited:0 3840 4922 PASS
[ 26.075119] test_bpf: #25 LD_ANC_XOR jited:1 107 94 PASS
[ 26.077583] test_bpf: #26 SPILL_FILL jited:1 159 148 173 PASS
[ 26.083259] test_bpf: #27 JEQ jited:1 274 183 181 PASS
[ 26.090383] test_bpf: #28 JGT jited:1 255 194 165 PASS
[ 26.097163] test_bpf: #29 JGE jited:1 187 190 246 PASS
[ 26.103932] test_bpf: #30 JSET jited:1 178 184 192 PASS
[ 26.110229] test_bpf: #31 tcpdump port 22 jited:1 266 698 717 PASS
[ 26.127698] test_bpf: #32 tcpdump complex jited:1 267 729 1129 PASS
[ 26.149727] test_bpf: #33 RET_A jited:1 94 88 PASS
[ 26.152114] test_bpf: #34 INT: ADD trivial jited:1 87 PASS
[ 26.153900] test_bpf: #35 INT: MUL_X jited:1 95 PASS
[ 26.155384] test_bpf: #36 INT: MUL_X2 jited:1 82 PASS
[ 26.156606] test_bpf: #37 INT: MUL32_X jited:1 91 PASS
[ 26.157846] test_bpf: #38 INT: ADD 64-bit jited:1 1055 PASS
[ 26.169280] test_bpf: #39 INT: ADD 32-bit jited:1 701 PASS
[ 26.177039] test_bpf: #40 INT: SUB jited:1 931 PASS
[ 26.187108] test_bpf: #41 INT: XOR jited:1 355 PASS
[ 26.191364] test_bpf: #42 INT: MUL jited:1 389 PASS
[ 26.196286] test_bpf: #43 MOV REG64 jited:1 267 PASS
[ 26.199759] test_bpf: #44 MOV REG32 jited:1 176 PASS
[ 26.202060] test_bpf: #45 LD IMM64 jited:1 194 PASS
[ 26.204607] test_bpf: #46 INT: ALU MIX jited:0 1174 PASS
[ 26.216896] test_bpf: #47 INT: shifts by register jited:1 211 PASS
[ 26.219956] test_bpf: #48 INT: DIV + ABS jited:1 559 517 PASS
[ 26.231347] test_bpf: #49 INT: DIV by zero jited:1 395 277 PASS
[ 26.238862] test_bpf: #50 check: missing ret PASS
[ 26.239288] test_bpf: #51 check: div_k_0 PASS
[ 26.239492] test_bpf: #52 check: unknown insn PASS
[ 26.239640] test_bpf: #53 check: out of range spill/fill PASS
[ 26.239803] test_bpf: #54 JUMPS + HOLES jited:1 295 PASS
[ 26.243343] test_bpf: #55 check: RET X PASS
[ 26.244065] test_bpf: #56 check: LDX + RET X PASS
[ 26.244224] test_bpf: #57 M[]: alt STX + LDX jited:1 433 PASS
[ 26.249126] test_bpf: #58 M[]: full STX + full LDX jited:1 427 PASS
[ 26.254123] test_bpf: #59 check: SKF_AD_MAX PASS
[ 26.254509] test_bpf: #60 LD [SKF_AD_OFF-1] jited:1 298 PASS
[ 26.257882] test_bpf: #61 load 64-bit immediate jited:1 128 PASS
[ 26.259813] test_bpf: #62 nmap reduced jited:1 655 PASS
[ 26.267216] test_bpf: #63 ALU_MOV_X: dst = 2 jited:1 89 PASS
[ 26.268766] test_bpf: #64 ALU_MOV_X: dst = 4294967295 jited:1 72 PASS
[ 26.270126] test_bpf: #65 ALU64_MOV_X: dst = 2 jited:1 94 PASS
[ 26.271768] test_bpf: #66 ALU64_MOV_X: dst = 4294967295 jited:1 145 PASS
[ 26.274152] test_bpf: #67 ALU_MOV_K: dst = 2 jited:1 93 PASS
[ 26.275673] test_bpf: #68 ALU_MOV_K: dst = 4294967295 jited:1 103 PASS
[ 26.277371] test_bpf: #69 ALU_MOV_K: 0x0000ffffffff0000 =
0x00000000ffffffff jited:1 99 PASS
[ 26.278966] test_bpf: #70 ALU64_MOV_K: dst = 2 jited:1 110 PASS
[ 26.280440] test_bpf: #71 ALU64_MOV_K: dst = 2147483647 jited:1 96 PASS
[ 26.281843] test_bpf: #72 ALU64_OR_K: dst = 0x0 jited:1 103 PASS
[ 26.283682] test_bpf: #73 ALU64_MOV_K: dst = -1 jited:1 96 PASS
[ 26.285147] test_bpf: #74 ALU_ADD_X: 1 + 2 = 3 jited:1 85 PASS
[ 26.286373] test_bpf: #75 ALU_ADD_X: 1 + 4294967294 = 4294967295
jited:1 108 PASS
[ 26.288079] test_bpf: #76 ALU_ADD_X: 2 + 4294967294 = 0 jited:1 112 PASS
[ 26.289653] test_bpf: #77 ALU64_ADD_X: 1 + 2 = 3 jited:1 70 PASS
[ 26.290666] test_bpf: #78 ALU64_ADD_X: 1 + 4294967294 = 4294967295
jited:1 85 PASS
[ 26.291897] test_bpf: #79 ALU64_ADD_X: 2 + 4294967294 = 4294967296
jited:1 95 PASS
[ 26.293429] test_bpf: #80 ALU_ADD_K: 1 + 2 = 3 jited:1 96 PASS
[ 26.294794] test_bpf: #81 ALU_ADD_K: 3 + 0 = 3 jited:1 79 PASS
[ 26.295956] test_bpf: #82 ALU_ADD_K: 1 + 4294967294 = 4294967295
jited:1 70 PASS
[ 26.297026] test_bpf: #83 ALU_ADD_K: 4294967294 + 2 = 0 jited:1 77 PASS
[ 26.298109] test_bpf: #84 ALU_ADD_K: 0 + (-1) = 0x00000000ffffffff
jited:1 120 PASS
[ 26.299705] test_bpf: #85 ALU_ADD_K: 0 + 0xffff = 0xffff jited:1 85 PASS
[ 26.300902] test_bpf: #86 ALU_ADD_K: 0 + 0x7fffffff = 0x7fffffff
jited:1 121 PASS
[ 26.302578] test_bpf: #87 ALU_ADD_K: 0 + 0x80000000 = 0x80000000
jited:1 115 PASS
[ 26.304134] test_bpf: #88 ALU_ADD_K: 0 + 0x80008000 = 0x80008000
jited:1 136 PASS
[ 26.305881] test_bpf: #89 ALU64_ADD_K: 1 + 2 = 3 jited:1 119 PASS
[ 26.307481] test_bpf: #90 ALU64_ADD_K: 3 + 0 = 3 jited:1 90 PASS
[ 26.308784] test_bpf: #91 ALU64_ADD_K: 1 + 2147483646 = 2147483647
jited:1 83 PASS
[ 26.310091] test_bpf: #92 ALU64_ADD_K: 4294967294 + 2 = 4294967296
jited:1 82 PASS
[ 26.311534] test_bpf: #93 ALU64_ADD_K: 2147483646 + -2147483647 =
-1 jited:1 71 PASS
[ 26.312842] test_bpf: #94 ALU64_ADD_K: 1 + 0 = 1 jited:1 143 PASS
[ 26.315010] test_bpf: #95 ALU64_ADD_K: 0 + (-1) =
0xffffffffffffffff jited:1 116 PASS
[ 26.317106] test_bpf: #96 ALU64_ADD_K: 0 + 0xffff = 0xffff jited:1 119 PASS
[ 26.318834] test_bpf: #97 ALU64_ADD_K: 0 + 0x7fffffff = 0x7fffffff
jited:1 119 PASS
[ 26.320484] test_bpf: #98 ALU64_ADD_K: 0 + 0x80000000 =
0xffffffff80000000 jited:1 110 PASS
[ 26.322003] test_bpf: #99 ALU_ADD_K: 0 + 0x80008000 =
0xffffffff80008000 jited:1 117 PASS
[ 26.323841] test_bpf: #100 ALU_SUB_X: 3 - 1 = 2 jited:1 84 PASS
[ 26.325043] test_bpf: #101 ALU_SUB_X: 4294967295 - 4294967294 = 1
jited:1 84 PASS
[ 26.326300] test_bpf: #102 ALU64_SUB_X: 3 - 1 = 2 jited:1 97 PASS
[ 26.327661] test_bpf: #103 ALU64_SUB_X: 4294967295 - 4294967294 = 1
jited:1 74 PASS
[ 26.328760] test_bpf: #104 ALU_SUB_K: 3 - 1 = 2 jited:1 80 PASS
[ 26.329880] test_bpf: #105 ALU_SUB_K: 3 - 0 = 3 jited:1 93 PASS
[ 26.331166] test_bpf: #106 ALU_SUB_K: 4294967295 - 4294967294 = 1
jited:1 81 PASS
[ 26.332348] test_bpf: #107 ALU64_SUB_K: 3 - 1 = 2 jited:1 89 PASS
[ 26.333616] test_bpf: #108 ALU64_SUB_K: 3 - 0 = 3 jited:1 73 PASS
[ 26.334796] test_bpf: #109 ALU64_SUB_K: 4294967294 - 4294967295 =
-1 jited:1 75 PASS
[ 26.335880] test_bpf: #110 ALU64_ADD_K: 2147483646 - 2147483647 =
-1 jited:1 88 PASS
[ 26.337138] test_bpf: #111 ALU_MUL_X: 2 * 3 = 6 jited:1 113 PASS
[ 26.338609] test_bpf: #112 ALU_MUL_X: 2 * 0x7FFFFFF8 = 0xFFFFFFF0
jited:1 99 PASS
[ 26.339983] test_bpf: #113 ALU_MUL_X: -1 * -1 = 1 jited:1 70 PASS
[ 26.341036] test_bpf: #114 ALU64_MUL_X: 2 * 3 = 6 jited:1 75 PASS
[ 26.342242] test_bpf: #115 ALU64_MUL_X: 1 * 2147483647 = 2147483647
jited:1 91 PASS
[ 26.343719] test_bpf: #116 ALU_MUL_K: 2 * 3 = 6 jited:1 83 PASS
[ 26.344945] test_bpf: #117 ALU_MUL_K: 3 * 1 = 3 jited:1 84 PASS
[ 26.346135] test_bpf: #118 ALU_MUL_K: 2 * 0x7FFFFFF8 = 0xFFFFFFF0
jited:1 69 PASS
[ 26.347240] test_bpf: #119 ALU_MUL_K: 1 * (-1) = 0x00000000ffffffff
jited:1 99 PASS
[ 26.348596] test_bpf: #120 ALU64_MUL_K: 2 * 3 = 6 jited:1 73 PASS
[ 26.349749] test_bpf: #121 ALU64_MUL_K: 3 * 1 = 3 jited:1 89 PASS
[ 26.350992] test_bpf: #122 ALU64_MUL_K: 1 * 2147483647 = 2147483647
jited:1 101 PASS
[ 26.352436] test_bpf: #123 ALU64_MUL_K: 1 * -2147483647 =
-2147483647 jited:1 112 PASS
[ 26.354144] test_bpf: #124 ALU64_MUL_K: 1 * (-1) =
0xffffffffffffffff jited:1 145 PASS
[ 26.356392] test_bpf: #125 ALU_DIV_X: 6 / 2 = 3 jited:1 204 PASS
[ 26.359242] test_bpf: #126 ALU_DIV_X: 4294967295 / 4294967295 = 1
jited:1 232 PASS
[ 26.362516] test_bpf: #127 ALU64_DIV_X: 6 / 2 = 3 jited:0 593 PASS
[ 26.368978] test_bpf: #128 ALU64_DIV_X: 2147483647 / 2147483647 = 1
jited:0 517 PASS
[ 26.374539] test_bpf: #129 ALU64_DIV_X: 0xffffffffffffffff / (-1) =
0x0000000000000001 jited:0 666 PASS
[ 26.381642] test_bpf: #130 ALU_DIV_K: 6 / 2 = 3 jited:1 225 PASS
[ 26.384418] test_bpf: #131 ALU_DIV_K: 3 / 1 = 3 jited:1 199 PASS
[ 26.386820] test_bpf: #132 ALU_DIV_K: 4294967295 / 4294967295 = 1
jited:1 195 PASS
[ 26.389428] test_bpf: #133 ALU_DIV_K: 0xffffffffffffffff / (-1) =
0x1 jited:1 354 PASS
[ 26.393537] test_bpf: #134 ALU64_DIV_K: 6 / 2 = 3 jited:0 403 PASS
[ 26.398414] test_bpf: #135 ALU64_DIV_K: 3 / 1 = 3 jited:0 388 PASS
[ 26.403006] test_bpf: #136 ALU64_DIV_K: 2147483647 / 2147483647 = 1
jited:0 387 PASS
[ 26.407619] test_bpf: #137 ALU64_DIV_K: 0xffffffffffffffff / (-1) =
0x0000000000000001 jited:0 577 PASS
[ 26.413875] test_bpf: #138 ALU_MOD_X: 3 % 2 = 1 jited:1 284 PASS
[ 26.417106] test_bpf: #139 ALU_MOD_X: 4294967295 % 4294967293 = 2
jited:1 298 PASS
[ 26.420489] test_bpf: #140 ALU64_MOD_X: 3 % 2 = 1 jited:0 609 PASS
[ 26.426958] test_bpf: #141 ALU64_MOD_X: 2147483647 % 2147483645 = 2
jited:0 588 PASS
[ 26.433454] test_bpf: #142 ALU_MOD_K: 3 % 2 = 1 jited:1 301 PASS
[ 26.436831] test_bpf: #143 ALU_MOD_K: 3 % 1 = 0 jited:1 PASS
[ 26.437152] test_bpf: #144 ALU_MOD_K: 4294967295 % 4294967293 = 2
jited:1 316 PASS
[ 26.440713] test_bpf: #145 ALU64_MOD_K: 3 % 2 = 1 jited:0 612 PASS
[ 26.447535] test_bpf: #146 ALU64_MOD_K: 3 % 1 = 0 jited:0 PASS
[ 26.448057] test_bpf: #147 ALU64_MOD_K: 2147483647 % 2147483645 = 2
jited:0 612 PASS
[ 26.454579] test_bpf: #148 ALU_AND_X: 3 & 2 = 2 jited:1 112 PASS
[ 26.456065] test_bpf: #149 ALU_AND_X: 0xffffffff & 0xffffffff =
0xffffffff jited:1 76 PASS
[ 26.457168] test_bpf: #150 ALU64_AND_X: 3 & 2 = 2 jited:1 84 PASS
[ 26.458350] test_bpf: #151 ALU64_AND_X: 0xffffffff & 0xffffffff =
0xffffffff jited:1 78 PASS
[ 26.459582] test_bpf: #152 ALU_AND_K: 3 & 2 = 2 jited:1 81 PASS
[ 26.460724] test_bpf: #153 ALU_AND_K: 0xffffffff & 0xffffffff =
0xffffffff jited:1 89 PASS
[ 26.462005] test_bpf: #154 ALU64_AND_K: 3 & 2 = 2 jited:1 99 PASS
[ 26.463622] test_bpf: #155 ALU64_AND_K: 0xffffffff & 0xffffffff =
0xffffffff jited:1 86 PASS
[ 26.464833] test_bpf: #156 ALU64_AND_K: 0x0000ffffffff0000 & 0x0 =
0x0000ffff00000000 jited:1 100 PASS
[ 26.466244] test_bpf: #157 ALU64_AND_K: 0x0000ffffffff0000 & -1 =
0x0000ffffffffffff jited:1 126 PASS
[ 26.467904] test_bpf: #158 ALU64_AND_K: 0xffffffffffffffff & -1 =
0xffffffffffffffff jited:1 105 PASS
[ 26.469357] test_bpf: #159 ALU_OR_X: 1 | 2 = 3 jited:1 71 PASS
[ 26.470510] test_bpf: #160 ALU_OR_X: 0x0 | 0xffffffff = 0xffffffff
jited:1 72 PASS
[ 26.471626] test_bpf: #161 ALU64_OR_X: 1 | 2 = 3 jited:1 71 PASS
[ 26.472684] test_bpf: #162 ALU64_OR_X: 0 | 0xffffffff = 0xffffffff
jited:1 87 PASS
[ 26.473892] test_bpf: #163 ALU_OR_K: 1 | 2 = 3 jited:1 94 PASS
[ 26.475174] test_bpf: #164 ALU_OR_K: 0 & 0xffffffff = 0xffffffff
jited:1 84 PASS
[ 26.476385] test_bpf: #165 ALU64_OR_K: 1 | 2 = 3 jited:1 71 PASS
[ 26.477586] test_bpf: #166 ALU64_OR_K: 0 & 0xffffffff = 0xffffffff
jited:1 80 PASS
[ 26.478723] test_bpf: #167 ALU64_OR_K: 0x0000ffffffff0000 | 0x0 =
0x0000ffff00000000 jited:1 124 PASS
[ 26.480417] test_bpf: #168 ALU64_OR_K: 0x0000ffffffff0000 | -1 =
0xffffffffffffffff jited:1 94 PASS
[ 26.481820] test_bpf: #169 ALU64_OR_K: 0x000000000000000 | -1 =
0xffffffffffffffff jited:1 150 PASS
[ 26.483952] test_bpf: #170 ALU_XOR_X: 5 ^ 6 = 3 jited:1 72 PASS
[ 26.485195] test_bpf: #171 ALU_XOR_X: 0x1 ^ 0xffffffff = 0xfffffffe
jited:1 89 PASS
[ 26.486648] test_bpf: #172 ALU64_XOR_X: 5 ^ 6 = 3 jited:1 80 PASS
[ 26.488214] test_bpf: #173 ALU64_XOR_X: 1 ^ 0xffffffff = 0xfffffffe
jited:1 71 PASS
[ 26.489566] test_bpf: #174 ALU_XOR_K: 5 ^ 6 = 3 jited:1 79 PASS
[ 26.490791] test_bpf: #175 ALU_XOR_K: 1 ^ 0xffffffff = 0xfffffffe
jited:1 105 PASS
[ 26.492548] test_bpf: #176 ALU64_XOR_K: 5 ^ 6 = 3 jited:1 128 PASS
[ 26.494713] test_bpf: #177 ALU64_XOR_K: 1 & 0xffffffff = 0xfffffffe
jited:1 86 PASS
[ 26.496072] test_bpf: #178 ALU64_XOR_K: 0x0000ffffffff0000 ^ 0x0 =
0x0000ffffffff0000 jited:1 102 PASS
[ 26.497612] test_bpf: #179 ALU64_XOR_K: 0x0000ffffffff0000 ^ -1 =
0xffff00000000ffff jited:1 88 PASS
[ 26.498906] test_bpf: #180 ALU64_XOR_K: 0x000000000000000 ^ -1 =
0xffffffffffffffff jited:1 98 PASS
[ 26.500256] test_bpf: #181 ALU_LSH_X: 1 << 1 = 2 jited:1 107 PASS
[ 26.501668] test_bpf: #182 ALU_LSH_X: 1 << 31 = 0x80000000 jited:1 70 PASS
[ 26.502690] test_bpf: #183 ALU64_LSH_X: 1 << 1 = 2 jited:1 100 PASS
[ 26.504077] test_bpf: #184 ALU64_LSH_X: 1 << 31 = 0x80000000 jited:1 78 PASS
[ 26.505197] test_bpf: #185 ALU_LSH_K: 1 << 1 = 2 jited:1 76 PASS
[ 26.506268] test_bpf: #186 ALU_LSH_K: 1 << 31 = 0x80000000 jited:1 71 PASS
[ 26.507301] test_bpf: #187 ALU64_LSH_K: 1 << 1 = 2 jited:1 69 PASS
[ 26.508374] test_bpf: #188 ALU64_LSH_K: 1 << 31 = 0x80000000 jited:1 78 PASS
[ 26.509494] test_bpf: #189 ALU_RSH_X: 2 >> 1 = 1 jited:1 76 PASS
[ 26.510665] test_bpf: #190 ALU_RSH_X: 0x80000000 >> 31 = 1 jited:1 77 PASS
[ 26.511787] test_bpf: #191 ALU64_RSH_X: 2 >> 1 = 1 jited:1 79 PASS
[ 26.513033] test_bpf: #192 ALU64_RSH_X: 0x80000000 >> 31 = 1 jited:1 95 PASS
[ 26.514382] test_bpf: #193 ALU_RSH_K: 2 >> 1 = 1 jited:1 80 PASS
[ 26.515648] test_bpf: #194 ALU_RSH_K: 0x80000000 >> 31 = 1 jited:1 72 PASS
[ 26.516778] test_bpf: #195 ALU64_RSH_K: 2 >> 1 = 1 jited:1 86 PASS
[ 26.517971] test_bpf: #196 ALU64_RSH_K: 0x80000000 >> 31 = 1 jited:1 78 PASS
[ 26.519188] test_bpf: #197 ALU_ARSH_X: 0xff00ff0000000000 >> 40 =
0xffffffffffff00ff jited:1 90 PASS
[ 26.520458] test_bpf: #198 ALU_ARSH_K: 0xff00ff0000000000 >> 40 =
0xffffffffffff00ff jited:1 69 PASS
[ 26.521509] test_bpf: #199 ALU_NEG: -(3) = -3 jited:1 79 PASS
[ 26.522692] test_bpf: #200 ALU_NEG: -(-3) = 3 jited:1 101 PASS
[ 26.524066] test_bpf: #201 ALU64_NEG: -(3) = -3 jited:1 69 PASS
[ 26.525152] test_bpf: #202 ALU64_NEG: -(-3) = 3 jited:1 69 PASS
[ 26.526264] test_bpf: #203 ALU_END_FROM_BE 16: 0x0123456789abcdef
-> 0xcdef jited:1 112 PASS
[ 26.527879] test_bpf: #204 ALU_END_FROM_BE 32: 0x0123456789abcdef
-> 0x89abcdef jited:1 75 PASS
[ 26.529323] test_bpf: #205 ALU_END_FROM_BE 64: 0x0123456789abcdef
-> 0x89abcdef jited:1 88 PASS
[ 26.530801] test_bpf: #206 ALU_END_FROM_LE 16: 0x0123456789abcdef
-> 0xefcd jited:1 103 PASS
[ 26.532789] test_bpf: #207 ALU_END_FROM_LE 32: 0x0123456789abcdef
-> 0xefcdab89 jited:1 121 PASS
[ 26.534881] test_bpf: #208 ALU_END_FROM_LE 64: 0x0123456789abcdef
-> 0x67452301 jited:1 74 PASS
[ 26.536388] test_bpf: #209 ST_MEM_B: Store/Load byte: max negative
jited:1 139 PASS
[ 26.538618] test_bpf: #210 ST_MEM_B: Store/Load byte: max positive
jited:1 93 PASS
[ 26.540104] test_bpf: #211 STX_MEM_B: Store/Load byte: max negative
jited:1 87 PASS
[ 26.541494] test_bpf: #212 ST_MEM_H: Store/Load half word: max
negative jited:1 104 PASS
[ 26.543038] test_bpf: #213 ST_MEM_H: Store/Load half word: max
positive jited:1 111 PASS
[ 26.544554] test_bpf: #214 STX_MEM_H: Store/Load half word: max
negative jited:1 92 PASS
[ 26.545885] test_bpf: #215 ST_MEM_W: Store/Load word: max negative
jited:1 124 PASS
[ 26.547523] test_bpf: #216 ST_MEM_W: Store/Load word: max positive
jited:1 83 PASS
[ 26.548753] test_bpf: #217 STX_MEM_W: Store/Load word: max negative
jited:1 87 PASS
[ 26.550001] test_bpf: #218 ST_MEM_DW: Store/Load double word: max
negative jited:1 91 PASS
[ 26.551660] test_bpf: #219 ST_MEM_DW: Store/Load double word: max
negative 2 jited:1 117 PASS
[ 26.553320] test_bpf: #220 ST_MEM_DW: Store/Load double word: max
positive jited:1 103 PASS
[ 26.554733] test_bpf: #221 STX_MEM_DW: Store/Load double word: max
negative jited:1 85 PASS
[ 26.555984] test_bpf: #222 STX_XADD_W: Test: 0x12 + 0x10 = 0x22
jited:0 289 PASS
[ 26.559204] test_bpf: #223 STX_XADD_W: Test side-effects, r10: 0x12
+ 0x10 = 0x22 jited:0 PASS
[ 26.559438] test_bpf: #224 STX_XADD_W: Test side-effects, r0: 0x12
+ 0x10 = 0x22 jited:0 242 PASS
[ 26.562189] test_bpf: #225 STX_XADD_W: X + 1 + 1 + 1 + ... jited:0
141847 PASS
[ 27.981183] test_bpf: #226 STX_XADD_DW: Test: 0x12 + 0x10 = 0x22
jited:0 374 PASS
[ 27.985739] test_bpf: #227 STX_XADD_DW: Test side-effects, r10:
0x12 + 0x10 = 0x22 jited:0 PASS
[ 27.985990] test_bpf: #228 STX_XADD_DW: Test side-effects, r0: 0x12
+ 0x10 = 0x22 jited:0 274 PASS
[ 27.989010] test_bpf: #229 STX_XADD_DW: X + 1 + 1 + 1 + ... jited:0
340041 PASS
[ 31.389811] test_bpf: #230 JMP_EXIT jited:1 73 PASS
[ 31.391325] test_bpf: #231 JMP_JA: Unconditional jump: if (true)
return 1 jited:1 90 PASS
[ 31.392672] test_bpf: #232 JMP_JSGT_K: Signed jump: if (-1 > -2)
return 1 jited:1 101 PASS
[ 31.394242] test_bpf: #233 JMP_JSGT_K: Signed jump: if (-1 > -1)
return 0 jited:1 76 PASS
[ 31.395380] test_bpf: #234 JMP_JSGE_K: Signed jump: if (-1 >= -2)
return 1 jited:1 83 PASS
[ 31.396628] test_bpf: #235 JMP_JSGE_K: Signed jump: if (-1 >= -1)
return 1 jited:1 80 PASS
[ 31.397766] test_bpf: #236 JMP_JGT_K: if (3 > 2) return 1 jited:1 79 PASS
[ 31.398935] test_bpf: #237 JMP_JGT_K: Unsigned jump: if (-1 > 1)
return 1 jited:1 124 PASS
[ 31.400772] test_bpf: #238 JMP_JGE_K: if (3 >= 2) return 1 jited:1 181 PASS
[ 31.403241] test_bpf: #239 JMP_JGT_K: if (3 > 2) return 1 (jump
backwards) jited:1 97 PASS
[ 31.404772] test_bpf: #240 JMP_JGE_K: if (3 >= 3) return 1 jited:1 80 PASS
[ 31.405965] test_bpf: #241 JMP_JNE_K: if (3 != 2) return 1 jited:1 79 PASS
[ 31.407146] test_bpf: #242 JMP_JEQ_K: if (3 == 3) return 1 jited:1 88 PASS
[ 31.408357] test_bpf: #243 JMP_JSET_K: if (0x3 & 0x2) return 1
jited:1 115 PASS
[ 31.409855] test_bpf: #244 JMP_JSET_K: if (0x3 & 0xffffffff) return
1 jited:1 89 PASS
[ 31.411190] test_bpf: #245 JMP_JSGT_X: Signed jump: if (-1 > -2)
return 1 jited:1 93 PASS
[ 31.412513] test_bpf: #246 JMP_JSGT_X: Signed jump: if (-1 > -1)
return 0 jited:1 90 PASS
[ 31.413820] test_bpf: #247 JMP_JSGE_X: Signed jump: if (-1 >= -2)
return 1 jited:1 93 PASS
[ 31.415252] test_bpf: #248 JMP_JSGE_X: Signed jump: if (-1 >= -1)
return 1 jited:1 94 PASS
[ 31.416629] test_bpf: #249 JMP_JGT_X: if (3 > 2) return 1 jited:1 88 PASS
[ 31.417834] test_bpf: #250 JMP_JGT_X: Unsigned jump: if (-1 > 1)
return 1 jited:1 77 PASS
[ 31.419077] test_bpf: #251 JMP_JGE_X: if (3 >= 2) return 1 jited:1 95 PASS
[ 31.420402] test_bpf: #252 JMP_JGE_X: if (3 >= 3) return 1 jited:1 97 PASS
[ 31.421841] test_bpf: #253 JMP_JGE_X: ldimm64 test 1 jited:1 110 PASS
[ 31.423894] test_bpf: #254 JMP_JGE_X: ldimm64 test 2 jited:1 94 PASS
[ 31.425370] test_bpf: #255 JMP_JGE_X: ldimm64 test 3 jited:1 107 PASS
[ 31.427259] test_bpf: #256 JMP_JNE_X: if (3 != 2) return 1 jited:1 101 PASS
[ 31.428931] test_bpf: #257 JMP_JEQ_X: if (3 == 3) return 1 jited:1 94 PASS
[ 31.430449] test_bpf: #258 JMP_JSET_X: if (0x3 & 0x2) return 1
jited:1 96 PASS
[ 31.431873] test_bpf: #259 JMP_JSET_X: if (0x3 & 0xffffffff) return
1 jited:1 217 PASS
[ 31.434897] test_bpf: #260 JMP_JA: Jump, gap, jump, ... jited:1 145 PASS
[ 31.437097] test_bpf: #261 BPF_MAXINSNS: Maximum possible literals
jited:1 184 PASS
[ 31.460982] test_bpf: #262 BPF_MAXINSNS: Single literal jited:1 250 PASS
[ 31.487721] test_bpf: #263 BPF_MAXINSNS: Run/add until end jited:1 6762 PASS
[ 31.569308] test_bpf: #264 BPF_MAXINSNS: Too many instructions PASS
[ 31.569438] test_bpf: #265 BPF_MAXINSNS: Very long jump jited:1 141 PASS
[ 31.585479] test_bpf: #266 BPF_MAXINSNS: Ctx heavy transformations
jited:1 31891 25898 PASS
[ 32.183199] test_bpf: #267 BPF_MAXINSNS: Call heavy transformations
jited:0 822248 831950 PASS
[ 48.732702] test_bpf: #268 BPF_MAXINSNS: Jump heavy test jited:1 136555 PASS
[ 50.117439] test_bpf: #269 BPF_MAXINSNS: Very long jump backwards
jited:1 168 PASS
[ 50.127426] test_bpf: #270 BPF_MAXINSNS: Edge hopping nuthouse
jited:1 255760 PASS
[ 52.690619] test_bpf: #271 BPF_MAXINSNS: Jump, gap, jump, ...
jited:1 1146 PASS
[ 52.724995] test_bpf: #272 BPF_MAXINSNS: ld_abs+get_processor_id
jited:0 562650 PASS
[ 58.361997] test_bpf: #273 BPF_MAXINSNS: ld_abs+vlan_push/pop
jited:0 527825 PASS
[ 63.641315] test_bpf: #274 LD_IND byte frag jited:1 649 PASS
[ 63.649443] test_bpf: #275 LD_IND halfword frag jited:1 640 PASS
[ 63.656527] test_bpf: #276 LD_IND word frag jited:1 668 PASS
[ 63.664376] test_bpf: #277 LD_IND halfword mixed head/frag jited:1 990 PASS
[ 63.675745] test_bpf: #278 LD_IND word mixed head/frag jited:1 971 PASS
[ 63.686341] test_bpf: #279 LD_ABS byte frag jited:1 778 PASS
[ 63.694965] test_bpf: #280 LD_ABS halfword frag jited:1 982 PASS
[ 63.705562] test_bpf: #281 LD_ABS word frag jited:1 737 PASS
[ 63.714005] test_bpf: #282 LD_ABS halfword mixed head/frag jited:1 997 PASS
[ 63.724868] test_bpf: #283 LD_ABS word mixed head/frag jited:1 1037 PASS
[ 63.736399] test_bpf: #284 LD_IND byte default X jited:1 270 PASS
[ 63.740296] test_bpf: #285 LD_IND byte positive offset jited:1 214 PASS
[ 63.743487] test_bpf: #286 LD_IND byte negative offset jited:1 251 PASS
[ 63.747173] test_bpf: #287 LD_IND halfword positive offset jited:1 191 PASS
[ 63.749669] test_bpf: #288 LD_IND halfword negative offset jited:1 188 PASS
[ 63.752163] test_bpf: #289 LD_IND halfword unaligned jited:1 212 PASS
[ 63.754834] test_bpf: #290 LD_IND word positive offset jited:1 187 PASS
[ 63.757257] test_bpf: #291 LD_IND word negative offset jited:1 180 PASS
[ 63.759764] test_bpf: #292 LD_IND word unaligned (addr & 3 == 2)
jited:1 211 PASS
[ 63.762621] test_bpf: #293 LD_IND word unaligned (addr & 3 == 1)
jited:1 276 PASS
[ 63.766332] test_bpf: #294 LD_IND word unaligned (addr & 3 == 3)
jited:1 270 PASS
[ 63.769931] test_bpf: #295 LD_ABS byte jited:1 253 PASS
[ 63.773492] test_bpf: #296 LD_ABS halfword jited:1 251 PASS
[ 63.777622] test_bpf: #297 LD_ABS halfword unaligned jited:1 259 PASS
[ 63.781554] test_bpf: #298 LD_ABS word jited:1 216 PASS
[ 63.784630] test_bpf: #299 LD_ABS word unaligned (addr & 3 == 2)
jited:1 198 PASS
[ 63.787174] test_bpf: #300 LD_ABS word unaligned (addr & 3 == 1)
jited:1 177 PASS
[ 63.789367] test_bpf: #301 LD_ABS word unaligned (addr & 3 == 3)
jited:1 235 PASS
[ 63.792235] test_bpf: #302 ADD default X jited:1 85 PASS
[ 63.793953] test_bpf: #303 ADD default A jited:1 87 PASS
[ 63.795439] test_bpf: #304 SUB default X jited:1 113 PASS
[ 63.797128] test_bpf: #305 SUB default A jited:1 94 PASS
[ 63.798801] test_bpf: #306 MUL default X jited:1 95 PASS
[ 63.800387] test_bpf: #307 MUL default A jited:1 83 PASS
[ 63.801704] test_bpf: #308 DIV default X jited:1 100 PASS
[ 63.803305] test_bpf: #309 DIV default A jited:1 216 PASS
[ 63.806105] test_bpf: #310 MOD default X jited:1 94 PASS
[ 63.807447] test_bpf: #311 MOD default A jited:1 270 PASS
[ 63.810667] test_bpf: #312 JMP EQ default A jited:1 94 PASS
[ 63.812321] test_bpf: #313 JMP EQ default X jited:1 163 PASS
[ 63.814754] test_bpf: Summary: 314 PASSED, 0 FAILED, [278/306 JIT'ed]
Let me know if you need more information.
Best,
Shubham Bansal
On Tue, May 16, 2017 at 1:25 AM, Daniel Borkmann <daniel@iogearbox.net> wrote:
> On 05/13/2017 11:38 PM, Shubham Bansal wrote:
>>
>> Finally finished testing.
>>
>> "test_bpf: Summary: 314 PASSED, 0 FAILED, [274/306 JIT'ed]"
>
>
> What are the missing pieces and how is the performance compared
> to the interpreter?
>
> Thanks,
> Daniel
^ permalink raw reply
* Re: [PATCH 0/4] Configuring traffic classes via new hardware offload mechanism in tc/mqprio
From: Or Gerlitz @ 2017-05-20 21:15 UTC (permalink / raw)
To: Amritha Nambiar
Cc: intel-wired-lan, Alexander Duyck, kiran.patil, Samudrala, Sridhar,
Mitch Williams, Neerav Parikh, Jeff Kirsher, Linux Netdev List
In-Reply-To: <149524122523.11022.4541073724650541658.stgit@anamdev.jf.intel.com>
On Sat, May 20, 2017 at 3:58 AM, Amritha Nambiar
<amritha.nambiar@intel.com> wrote:
> The following series introduces a new harware offload mode in tc/mqprio
Wait, we have already a HW QoS model introduced by John F and Co
couple of years ago, right?
Please elaborate in few sentence if you are extending it/replacing it,
why we want to do that and what are the implications on existing
applications UAPI wise.
Below you just say in the new mode Qos is configured with knobs XYZ --
this is way not enough
> where the TCs, the queue configurations and bandwidth rate limits
> are offloaded to the hardware.
> The i40e driver enables the new mqprio hardware offload mechanism factoring the TCs, queue configuration and bandwidth rates by creating HW channel VSIs.
>
> In this mode, the priority to traffic class mapping and the user specified queue ranges are used to configure the traffic class when the 'hw' option is set to 2. This is achieved by creating HW channels(VSI). A new channel is created for each of the traffic class configuration offloaded via mqprio framework except for the first TC (TC0) which is for the main VSI. TC0 for the main VSI is also reconfigured as per user provided queue parameters. Finally, bandwidth rate limits are set on these traffic classes through the mqprio offload framework by sending these rates in addition to the number of TCs and the queue configurations.
^ permalink raw reply
* [PATCH] include stdint.h explicitly for UINT16_MAX)
From: Khem Raj @ 2017-05-20 21:28 UTC (permalink / raw)
To: netdev; +Cc: Khem Raj
Fixes
| tc_core.c:190:29: error: 'UINT16_MAX' undeclared (first use in this function); did you mean '__INT16_MAX__'?
| if ((sz >> s->size_log) > UINT16_MAX) {
| ^~~~~~~~~~
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
tc/tc_core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tc/tc_core.c b/tc/tc_core.c
index 7bbe0d7..821b741 100644
--- a/tc/tc_core.c
+++ b/tc/tc_core.c
@@ -12,6 +12,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <stdint.h>
#include <unistd.h>
#include <syslog.h>
#include <fcntl.h>
--
2.13.0
^ permalink raw reply related
* Re: [patch net-next 2/2] net/sched: fix filter flushing
From: Cong Wang @ 2017-05-21 0:16 UTC (permalink / raw)
To: Jiri Pirko
Cc: Linux Kernel Network Developers, David Miller, Jamal Hadi Salim,
Eric Dumazet, Daniel Borkmann, Simon Horman, mlxsw, Colin King
In-Reply-To: <20170520130132.1626-2-jiri@resnulli.us>
On Sat, May 20, 2017 at 6:01 AM, Jiri Pirko <jiri@resnulli.us> wrote:
> +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);
I wonder if we should return EBUSY and do nothing in case of busy?
The chain is no longer visual to new actions after your list_del(), but
the old one could still use and see it.
^ permalink raw reply
* [PATCH net-next v5] net: ipv6: fix code style error and warning of ndisc.c
From: yuan linyu @ 2017-05-21 0:55 UTC (permalink / raw)
To: netdev; +Cc: David S . Miller, Joe Perches, yuan linyu
From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index d310dc4..5cf25bc 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;
@@ -234,20 +234,28 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
case ND_OPT_TARGET_LL_ADDR:
case ND_OPT_MTU:
case ND_OPT_NONCE:
- case ND_OPT_REDIRECT_HDR:
- if (ndopts->nd_opt_array[nd_opt->nd_opt_type]) {
+ case ND_OPT_REDIRECT_HDR: {
+ struct nd_opt_hdr **hdr;
+
+ hdr = &ndopts->nd_opt_array[nd_opt->nd_opt_type];
+ if (*hdr) {
ND_PRINTK(2, warn,
"%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;
+ *hdr = nd_opt;
}
break;
- case ND_OPT_PREFIX_INFO:
+ }
+ case ND_OPT_PREFIX_INFO: {
+ struct nd_opt_hdr **hdr;
+
+ hdr = &ndopts->nd_opt_array[nd_opt->nd_opt_type];
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;
+ if (!*hdr)
+ *hdr = nd_opt;
break;
+ }
#ifdef CONFIG_IPV6_ROUTE_INFO
case ND_OPT_ROUTE_INFO:
ndopts->nd_opts_ri_end = nd_opt;
@@ -261,8 +269,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 +287,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 +335,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 +351,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 +364,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 +519,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 +588,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 +637,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 +648,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 +678,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 +699,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 +709,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 +772,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 +812,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 +823,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 +851,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 +864,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 +901,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 +910,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 +986,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 +1016,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 +1072,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 +1094,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 +1123,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 +1186,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 +1218,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 +1307,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 +1390,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 +1416,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 +1429,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 +1455,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 +1469,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 +1486,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 +1495,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 +1533,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 +1584,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 +1603,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 +1611,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 +1635,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 +1662,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 +1753,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 +1804,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 +1815,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 +1824,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 +1841,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 +1901,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 3/5] net: introduce XDP driver features interface
From: Daniel Borkmann @ 2017-05-21 0:58 UTC (permalink / raw)
To: Jesper Dangaard Brouer
Cc: Daniel Borkmann, Alexei Starovoitov, John Fastabend, netdev
In-Reply-To: <20170520095331.18c6be36@redhat.com>
On 05/20/2017 09:53 AM, Jesper Dangaard Brouer wrote:
> 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...
But if we agree on implementing a certain feature that requires to
add a new member, then basic requirement should be that it needs to
be implementable by all XDP enabled drivers, so that users eventually
don't need to worry which driver they run to access a XDP feature.
In that case, zeroing that member until it gets properly implemented
is just temporary (and could be an incentive perhaps).
> [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?
That would potentially require us to go down that path and expose
feature bits for everything, even something as silly as new flags
for a specific helper that requires some sort of additional support.
We probably rather want to keep such thing in the kernel for now
and potentially reject loads instead.
>>> 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).
But the issue I pointed out with this approach is that XDP programs
using tail calls will suddenly break and get rejected from one
version to another.
That's basically breaking the contract we have today where it must
be guaranteed that older programs keep working on newer kernels,
exactly the same with uapi. Breaking user programs is a no-go,
not a good thing at all (it will hurt users and they move on with
something else). So it's not something we can 'fix' at some later
point in time; such feature detection would need to consider this
from day 1.
> 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.
^ permalink raw reply
* [PATCH net-next v6] net: ipv6: fix code style error and warning of ndisc.c
From: yuan linyu @ 2017-05-21 1:11 UTC (permalink / raw)
To: netdev; +Cc: David S . Miller, Joe Perches, yuan linyu
From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
CC: Joe Perches <joe@perches.com>
Signed-off-by: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
---
net/ipv6/ndisc.c | 324 +++++++++++++++++++++++++++++--------------------------
1 file changed, 173 insertions(+), 151 deletions(-)
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index d310dc4..5cf25bc 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;
@@ -234,20 +234,28 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
case ND_OPT_TARGET_LL_ADDR:
case ND_OPT_MTU:
case ND_OPT_NONCE:
- case ND_OPT_REDIRECT_HDR:
- if (ndopts->nd_opt_array[nd_opt->nd_opt_type]) {
+ case ND_OPT_REDIRECT_HDR: {
+ struct nd_opt_hdr **hdr;
+
+ hdr = &ndopts->nd_opt_array[nd_opt->nd_opt_type];
+ if (*hdr) {
ND_PRINTK(2, warn,
"%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;
+ *hdr = nd_opt;
}
break;
- case ND_OPT_PREFIX_INFO:
+ }
+ case ND_OPT_PREFIX_INFO: {
+ struct nd_opt_hdr **hdr;
+
+ hdr = &ndopts->nd_opt_array[nd_opt->nd_opt_type];
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;
+ if (!*hdr)
+ *hdr = nd_opt;
break;
+ }
#ifdef CONFIG_IPV6_ROUTE_INFO
case ND_OPT_ROUTE_INFO:
ndopts->nd_opts_ri_end = nd_opt;
@@ -261,8 +269,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 +287,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 +335,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 +351,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 +364,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 +519,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 +588,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 +637,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 +648,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 +678,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 +699,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 +709,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 +772,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 +812,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 +823,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 +851,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 +864,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 +901,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 +910,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 +986,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 +1016,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 +1072,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 +1094,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 +1123,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 +1186,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 +1218,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 +1307,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 +1390,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 +1416,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 +1429,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 +1455,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 +1469,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 +1486,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 +1495,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 +1533,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 +1584,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 +1603,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 +1611,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 +1635,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 +1662,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 +1753,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 +1804,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 +1815,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 +1824,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 +1841,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 +1901,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
* Deleting a dynamic mac entry..
From: Manohar Kumar @ 2017-05-21 2:28 UTC (permalink / raw)
To: netdev
Hello,
In 3.19 the following bridge fdb command to delete a dynamically
learned entry fails..
root@net-3:~# bridge fdb show | grep 02:42:0a:ff:00:06
02:42:0a:ff:00:06 dev vxlan0 master br0
root@net-3:~# bridge fdb del 02:42:0a:ff:00:06 dev vxlan0 master
RTNETLINK answers: No such file or directory
It works in 4.4.
Can someone please point to the patch that made this change ?
In kernels without this patch is there an alternative to delete
(actually I want to do it programmatically) dynamic mac entries ?
^ permalink raw reply
* Re: BPF relocations
From: Maciej W. Rozycki @ 2017-05-21 3:22 UTC (permalink / raw)
To: David Miller; +Cc: ast, daniel, netdev
In-Reply-To: <20170511.211920.2220259143750653022.davem@davemloft.net>
On Fri, 12 May 2017, David Miller wrote:
> Internally, we have to emit some kind of relocation as GAS makes it's
> first pass over the instructions.
Not really, you can defer that until the relaxation pass, e.g. to avoid
figuring out what to do about forward local symbol references, especially
in complex expressions that may eventually resolve to assembly constants.
This is how MIPS16 assembly works for example, due to its dual regular vs
extended instruction encoding, so that no artificial relocations had to be
invented in GAS for the regular instructions, which never get relocations
recorded against in an object file. Any instruction that ends up needing
a relocation, if supported (not all encodings do), gets converted to the
extended form in the relaxation pass and only then a suitable fixup is
attached to it.
Of course that may not matter for your specific case, but I think it's
worth noting so as to avoid people getting misled about how GAS works.
FWIW,
Maciej
^ permalink raw reply
* Re: [PATCH net-next] geneve: always fill CSUM6_RX configuration
From: Pravin Shelar @ 2017-05-21 4:56 UTC (permalink / raw)
To: Eric Garver, Pravin Shelar, Linux Kernel Network Developers
In-Reply-To: <20170520133503.GM9969@rhel7>
On Sat, May 20, 2017 at 6:35 AM, Eric Garver <e@erig.me> wrote:
> 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.
>
ok.
I think ip_tunnel_info_af() check is not right. it does not work in
case of collect_metadata.
Better fix would be check for genene->sock4 and genene->sock6 and
build the netlink skb accordingly.
^ 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