* RE: [PATCH net-next] liquidio: fix rare pci_driver.probe failure of VF driver
From: Chickles, Derek @ 2017-05-25 17:52 UTC (permalink / raw)
To: Manlunas, Felix, davem@davemloft.net
Cc: netdev@vger.kernel.org, Vatsavayi, Raghu, Burla, Satananda,
Kanneganti, Prasad
In-Reply-To: <20170525174214.GA1444@felix-thinkpad.cavium.com>
Looks good to me.
Derek
> -----Original Message-----
> From: Manlunas, Felix
> Sent: Thursday, May 25, 2017 10:42 AM
> To: davem@davemloft.net
> Cc: netdev@vger.kernel.org; Vatsavayi, Raghu <Raghu.Vatsavayi@cavium.com>;
> Chickles, Derek <Derek.Chickles@cavium.com>; Burla, Satananda
> <Satananda.Burla@cavium.com>; Kanneganti, Prasad
> <Prasad.Kanneganti@cavium.com>
> Subject: [PATCH net-next] liquidio: fix rare pci_driver.probe failure of
> VF driver
>
> From: Prasad Kanneganti <prasad.kanneganti@cavium.com>
>
> There's a rare pci_driver.probe failure of the VF driver that's caused by
> PF/VF handshake going out of sync. The culprit is octeon_mbox_write() who
> ignores an ack timeout condition; it just keeps unconditionally writing
> all elements of mbox_cmd->data[] even when the other side is not ready for
> them. Fix it by making each write of mbox_cmd->data[i] conditional to
> having previously received an ack.
>
> Also fix the octeon_mbox_state enum such that each state gets a unique
> value. Also add ULL suffix to numeric literals in macro definitions.
>
> Signed-off-by: Prasad Kanneganti <prasad.kanneganti@cavium.com>
> Signed-off-by: Felix Manlunas <felix.manlunas@cavium.com>
> ---
> drivers/net/ethernet/cavium/liquidio/octeon_mailbox.c | 5 ++++-
> drivers/net/ethernet/cavium/liquidio/octeon_mailbox.h | 12 ++++++------
> 2 files changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_mailbox.c
> b/drivers/net/ethernet/cavium/liquidio/octeon_mailbox.c
> index 5cca73b..57af7df 100644
> --- a/drivers/net/ethernet/cavium/liquidio/octeon_mailbox.c
> +++ b/drivers/net/ethernet/cavium/liquidio/octeon_mailbox.c
> @@ -178,7 +178,10 @@ int octeon_mbox_write(struct octeon_device *oct,
> break;
> }
> }
> - writeq(mbox_cmd->data[i], mbox->mbox_write_reg);
> + if (ret == OCTEON_MBOX_STATUS_SUCCESS)
> + writeq(mbox_cmd->data[i], mbox->mbox_write_reg);
> + else
> + break;
> }
> }
>
> diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_mailbox.h
> b/drivers/net/ethernet/cavium/liquidio/octeon_mailbox.h
> index c9376fe..1def22a 100644
> --- a/drivers/net/ethernet/cavium/liquidio/octeon_mailbox.h
> +++ b/drivers/net/ethernet/cavium/liquidio/octeon_mailbox.h
> @@ -20,16 +20,16 @@
>
> /* Macros for Mail Box Communication */
>
> -#define OCTEON_MBOX_DATA_MAX 32
> +#define OCTEON_MBOX_DATA_MAX 32
>
> #define OCTEON_VF_ACTIVE 0x1
> #define OCTEON_VF_FLR_REQUEST 0x2
> #define OCTEON_PF_CHANGED_VF_MACADDR 0x4
>
> /*Macro for Read acknowldgement*/
> -#define OCTEON_PFVFACK 0xffffffffffffffff
> -#define OCTEON_PFVFSIG 0x1122334455667788
> -#define OCTEON_PFVFERR 0xDEADDEADDEADDEAD
> +#define OCTEON_PFVFACK 0xffffffffffffffffULL
> +#define OCTEON_PFVFSIG 0x1122334455667788ULL
> +#define OCTEON_PFVFERR 0xDEADDEADDEADDEADULL
>
> #define LIO_MBOX_WRITE_WAIT_CNT 1000
> #define LIO_MBOX_WRITE_WAIT_TIME msecs_to_jiffies(1)
> @@ -74,8 +74,8 @@ enum octeon_mbox_state {
> OCTEON_MBOX_STATE_REQUEST_RECEIVED = 4,
> OCTEON_MBOX_STATE_RESPONSE_PENDING = 8,
> OCTEON_MBOX_STATE_RESPONSE_RECEIVING = 16,
> - OCTEON_MBOX_STATE_RESPONSE_RECEIVED = 16,
> - OCTEON_MBOX_STATE_ERROR = 32
> + OCTEON_MBOX_STATE_RESPONSE_RECEIVED = 32,
> + OCTEON_MBOX_STATE_ERROR = 64
> };
>
> struct octeon_mbox {
^ permalink raw reply
* Re: [PATCH net v2 0/5] Various BPF fixes
From: David Miller @ 2017-05-25 17:45 UTC (permalink / raw)
To: daniel; +Cc: alexei.starovoitov, netdev, ecree
In-Reply-To: <cover.1495665905.git.daniel@iogearbox.net>
From: Daniel Borkmann <daniel@iogearbox.net>
Date: Thu, 25 May 2017 01:05:04 +0200
> Follow-up to fix incorrect pruning when alignment tracking is
> in use and to properly clear regs after call to not leave stale
> data behind, also a fix that adds bpf_clone_redirect to the
> bpf_helper_changes_pkt_data helper and exposes correct map_flags
> for lpm map into fdinfo. For details, please see individual
> patches.
>
> v1 -> v2:
> - Reworked first patch so that env->strict_alignment is the
> final indicator on whether we have to deal with strict
> alignment rather than having CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
> checks on various locations, so only checking env->strict_alignment
> is sufficient after that. Thanks for spotting, Dave!
> - Added patch 3 and 4.
> - Rest as is.
Series applied, thanks Daniel.
Hmmm, this is likely to conflict with Edwards's work...
^ permalink raw reply
* [PATCH net-next v2 8/8] net: ipv6: RTM_GETROUTE: return matched fib result when requested
From: Roopa Prabhu @ 2017-05-25 17:42 UTC (permalink / raw)
To: davem, dsahern, rami.rosen; +Cc: netdev, nikolay
In-Reply-To: <1495734160-47659-1-git-send-email-roopa@cumulusnetworks.com>
From: Roopa Prabhu <roopa@cumulusnetworks.com>
This patch adds support to return matched fib result when RTM_F_FIB_MATCH
flag is specified in RTM_GETROUTE request. This is useful for user-space
applications/controllers wanting to query a matching route.
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
---
net/ipv6/route.c | 34 ++++++++++++++++++++++++++--------
1 file changed, 26 insertions(+), 8 deletions(-)
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 80bda31..2fe84bd 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -3607,11 +3607,13 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
{
struct net *net = sock_net(in_skb->sk);
struct nlattr *tb[RTA_MAX+1];
+ int err, iif = 0, oif = 0;
+ struct dst_entry *dst;
struct rt6_info *rt;
struct sk_buff *skb;
struct rtmsg *rtm;
struct flowi6 fl6;
- int err, iif = 0, oif = 0;
+ bool fibmatch;
err = nlmsg_parse(nlh, sizeof(*rtm), tb, RTA_MAX, rtm_ipv6_policy,
extack);
@@ -3622,6 +3624,7 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
memset(&fl6, 0, sizeof(fl6));
rtm = nlmsg_data(nlh);
fl6.flowlabel = ip6_make_flowinfo(rtm->rtm_tos, 0);
+ fibmatch = !!(rtm->rtm_flags & RTM_F_FIB_MATCH);
if (tb[RTA_SRC]) {
if (nla_len(tb[RTA_SRC]) < sizeof(struct in6_addr))
@@ -3667,12 +3670,23 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
if (!ipv6_addr_any(&fl6.saddr))
flags |= RT6_LOOKUP_F_HAS_SADDR;
- rt = (struct rt6_info *)ip6_route_input_lookup(net, dev, &fl6,
- flags);
+ if (!fibmatch)
+ dst = ip6_route_input_lookup(net, dev, &fl6, flags);
} else {
fl6.flowi6_oif = oif;
- rt = (struct rt6_info *)ip6_route_output(net, NULL, &fl6);
+ if (!fibmatch)
+ dst = ip6_route_output(net, NULL, &fl6);
+ }
+
+ if (fibmatch)
+ dst = ip6_route_lookup(net, &fl6, 0);
+
+ rt = container_of(dst, struct rt6_info, dst);
+ if (rt->dst.error) {
+ err = rt->dst.error;
+ ip6_rt_put(rt);
+ goto errout;
}
if (rt == net->ipv6.ip6_null_entry) {
@@ -3689,10 +3703,14 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
}
skb_dst_set(skb, &rt->dst);
-
- err = rt6_fill_node(net, skb, rt, &fl6.daddr, &fl6.saddr, iif,
- RTM_NEWROUTE, NETLINK_CB(in_skb).portid,
- nlh->nlmsg_seq, 0);
+ if (fibmatch)
+ err = rt6_fill_node(net, skb, rt, NULL, NULL, iif,
+ RTM_NEWROUTE, NETLINK_CB(in_skb).portid,
+ nlh->nlmsg_seq, 0);
+ else
+ err = rt6_fill_node(net, skb, rt, &fl6.daddr, &fl6.saddr, iif,
+ RTM_NEWROUTE, NETLINK_CB(in_skb).portid,
+ nlh->nlmsg_seq, 0);
if (err < 0) {
kfree_skb(skb);
goto errout;
--
1.9.1
^ permalink raw reply related
* [PATCH net-next v2 6/8] net: ipv4: add new RTM_F_FIB_MATCH flag for use with RTM_GETROUTE
From: Roopa Prabhu @ 2017-05-25 17:42 UTC (permalink / raw)
To: davem, dsahern, rami.rosen; +Cc: netdev, nikolay
In-Reply-To: <1495734160-47659-1-git-send-email-roopa@cumulusnetworks.com>
From: Roopa Prabhu <roopa@cumulusnetworks.com>
This flag when specified will return matched fib result in
response to a RTM_GETROUTE query.
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
---
include/uapi/linux/rtnetlink.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/uapi/linux/rtnetlink.h b/include/uapi/linux/rtnetlink.h
index 6487b21..564790e 100644
--- a/include/uapi/linux/rtnetlink.h
+++ b/include/uapi/linux/rtnetlink.h
@@ -278,6 +278,7 @@ enum rt_scope_t {
#define RTM_F_EQUALIZE 0x400 /* Multipath equalizer: NI */
#define RTM_F_PREFIX 0x800 /* Prefix addresses */
#define RTM_F_LOOKUP_TABLE 0x1000 /* set rtm_table to FIB lookup result */
+#define RTM_F_FIB_MATCH 0x2000 /* return full fib lookup match */
/* Reserved table identifiers */
--
1.9.1
^ permalink raw reply related
* [PATCH net-next v2 7/8] net: ipv4: RTM_GETROUTE: return matched fib result when requested
From: Roopa Prabhu @ 2017-05-25 17:42 UTC (permalink / raw)
To: davem, dsahern, rami.rosen; +Cc: netdev, nikolay
In-Reply-To: <1495734160-47659-1-git-send-email-roopa@cumulusnetworks.com>
From: Roopa Prabhu <roopa@cumulusnetworks.com>
This patch adds support to return matched fib result when RTM_F_FIB_MATCH
flag is specified in RTM_GETROUTE request. This is useful for user-space
applications/controllers wanting to query a matching route.
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
---
net/ipv4/route.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 1fa9127..3a74256 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -114,6 +114,8 @@
#include <net/ip_tunnels.h>
#include <net/l3mdev.h>
+#include "fib_lookup.h"
+
#define RT_FL_TOS(oldflp4) \
((oldflp4)->flowi4_tos & (IPTOS_RT_MASK | RTO_ONLINK))
@@ -2746,8 +2748,15 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
if (rtm->rtm_flags & RTM_F_LOOKUP_TABLE)
table_id = rt->rt_table_id;
- err = rt_fill_info(net, dst, src, table_id, &fl4, skb,
- NETLINK_CB(in_skb).portid, nlh->nlmsg_seq, rt);
+ if (rtm->rtm_flags & RTM_F_FIB_MATCH)
+ err = fib_dump_info(skb, NETLINK_CB(in_skb).portid,
+ nlh->nlmsg_seq, RTM_NEWROUTE, table_id,
+ rt->rt_type, res.prefix, res.prefixlen,
+ fl4.flowi4_tos, res.fi, 0);
+ else
+ err = rt_fill_info(net, dst, src, table_id, &fl4, skb,
+ NETLINK_CB(in_skb).portid, nlh->nlmsg_seq,
+ rt);
if (err < 0)
goto errout_free;
--
1.9.1
^ permalink raw reply related
* [PATCH net-next v2 5/8] net: ipv4: Save trie prefix to fib lookup result
From: Roopa Prabhu @ 2017-05-25 17:42 UTC (permalink / raw)
To: davem, dsahern, rami.rosen; +Cc: netdev, nikolay
In-Reply-To: <1495734160-47659-1-git-send-email-roopa@cumulusnetworks.com>
From: David Ahern <dsahern@gmail.com>
Prefix is needed for returning matching route spec on get route request.
Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
---
include/net/ip_fib.h | 1 +
net/ipv4/fib_trie.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
index 42e8b8f..25f5c51 100644
--- a/include/net/ip_fib.h
+++ b/include/net/ip_fib.h
@@ -136,6 +136,7 @@ struct fib_info {
struct fib_table;
struct fib_result {
+ __be32 prefix;
unsigned char prefixlen;
unsigned char nh_sel;
unsigned char type;
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 6d0f6c79..6e9df7d 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -1452,6 +1452,7 @@ int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp,
if (!(fib_flags & FIB_LOOKUP_NOREF))
atomic_inc(&fi->fib_clntref);
+ res->prefix = htonl(n->key);
res->prefixlen = KEYLENGTH - fa->fa_slen;
res->nh_sel = nhsel;
res->type = fa->fa_type;
--
1.9.1
^ permalink raw reply related
* [PATCH net-next v2 4/8] net: ipv4: Convert inet_rtm_getroute to rcu versions of route lookup
From: Roopa Prabhu @ 2017-05-25 17:42 UTC (permalink / raw)
To: davem, dsahern, rami.rosen; +Cc: netdev, nikolay
In-Reply-To: <1495734160-47659-1-git-send-email-roopa@cumulusnetworks.com>
From: David Ahern <dsahern@gmail.com>
Convert inet_rtm_getroute to use ip_route_input_rcu and
ip_route_output_key_hash_rcu passing the fib_result arg to both.
The rcu lock is held through the creation of the response, so the
rtable/dst does not need to be attached to the skb and is passed
to rt_fill_info directly.
In converting from ip_route_output_key to ip_route_output_key_hash_rcu
the xfrm_lookup_route in ip_route_output_flow is dropped since
flowi4_proto is not set for a route get request.
Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
---
net/ipv4/route.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index d8fcecc..1fa9127 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2534,11 +2534,11 @@ struct rtable *ip_route_output_flow(struct net *net, struct flowi4 *flp4,
}
EXPORT_SYMBOL_GPL(ip_route_output_flow);
+/* called with rcu_read_lock held */
static int rt_fill_info(struct net *net, __be32 dst, __be32 src, u32 table_id,
struct flowi4 *fl4, struct sk_buff *skb, u32 portid,
- u32 seq)
+ u32 seq, struct rtable *rt)
{
- struct rtable *rt = skb_rtable(skb);
struct rtmsg *r;
struct nlmsghdr *nlh;
unsigned long expires = 0;
@@ -2653,6 +2653,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
struct net *net = sock_net(in_skb->sk);
struct rtmsg *rtm;
struct nlattr *tb[RTA_MAX+1];
+ struct fib_result res = {};
struct rtable *rt = NULL;
struct flowi4 fl4;
__be32 dst = 0;
@@ -2709,10 +2710,12 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
fl4.flowi4_mark = mark;
fl4.flowi4_uid = uid;
+ rcu_read_lock();
+
if (iif) {
struct net_device *dev;
- dev = __dev_get_by_index(net, iif);
+ dev = dev_get_by_index_rcu(net, iif);
if (!dev) {
err = -ENODEV;
goto errout_free;
@@ -2721,14 +2724,14 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
skb->protocol = htons(ETH_P_IP);
skb->dev = dev;
skb->mark = mark;
- err = ip_route_input(skb, dst, src, rtm->rtm_tos, dev);
+ err = ip_route_input_rcu(skb, dst, src, rtm->rtm_tos,
+ dev, &res);
rt = skb_rtable(skb);
if (err == 0 && rt->dst.error)
err = -rt->dst.error;
} else {
- rt = ip_route_output_key(net, &fl4);
-
+ rt = ip_route_output_key_hash_rcu(net, &fl4, &res, skb);
err = 0;
if (IS_ERR(rt))
err = PTR_ERR(rt);
@@ -2737,7 +2740,6 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
if (err)
goto errout_free;
- skb_dst_set(skb, &rt->dst);
if (rtm->rtm_flags & RTM_F_NOTIFY)
rt->rt_flags |= RTCF_NOTIFY;
@@ -2745,15 +2747,18 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
table_id = rt->rt_table_id;
err = rt_fill_info(net, dst, src, table_id, &fl4, skb,
- NETLINK_CB(in_skb).portid, nlh->nlmsg_seq);
+ NETLINK_CB(in_skb).portid, nlh->nlmsg_seq, rt);
if (err < 0)
goto errout_free;
+ rcu_read_unlock();
+
err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid);
errout:
return err;
errout_free:
+ rcu_read_unlock();
kfree_skb(skb);
goto errout;
}
--
1.9.1
^ permalink raw reply related
* [PATCH net-next v2 3/8] net: ipv4: Remove event arg to rt_fill_info
From: Roopa Prabhu @ 2017-05-25 17:42 UTC (permalink / raw)
To: davem, dsahern, rami.rosen; +Cc: netdev, nikolay
In-Reply-To: <1495734160-47659-1-git-send-email-roopa@cumulusnetworks.com>
From: David Ahern <dsahern@gmail.com>
rt_fill_info has 1 caller with the event set to RTM_NEWROUTE. Given that
remove the arg and use RTM_NEWROUTE directly in rt_fill_info.
Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
---
net/ipv4/route.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 1dc8fd1..d8fcecc 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2536,7 +2536,7 @@ struct rtable *ip_route_output_flow(struct net *net, struct flowi4 *flp4,
static int rt_fill_info(struct net *net, __be32 dst, __be32 src, u32 table_id,
struct flowi4 *fl4, struct sk_buff *skb, u32 portid,
- u32 seq, int event)
+ u32 seq)
{
struct rtable *rt = skb_rtable(skb);
struct rtmsg *r;
@@ -2545,7 +2545,7 @@ static int rt_fill_info(struct net *net, __be32 dst, __be32 src, u32 table_id,
u32 error;
u32 metrics[RTAX_MAX];
- nlh = nlmsg_put(skb, portid, seq, event, sizeof(*r), 0);
+ nlh = nlmsg_put(skb, portid, seq, RTM_NEWROUTE, sizeof(*r), 0);
if (!nlh)
return -EMSGSIZE;
@@ -2745,8 +2745,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
table_id = rt->rt_table_id;
err = rt_fill_info(net, dst, src, table_id, &fl4, skb,
- NETLINK_CB(in_skb).portid, nlh->nlmsg_seq,
- RTM_NEWROUTE);
+ NETLINK_CB(in_skb).portid, nlh->nlmsg_seq);
if (err < 0)
goto errout_free;
--
1.9.1
^ permalink raw reply related
* [PATCH net-next v2 2/8] net: ipv4: refactor ip_route_input_noref
From: Roopa Prabhu @ 2017-05-25 17:42 UTC (permalink / raw)
To: davem, dsahern, rami.rosen; +Cc: netdev, nikolay
In-Reply-To: <1495734160-47659-1-git-send-email-roopa@cumulusnetworks.com>
From: David Ahern <dsahern@gmail.com>
A later patch wants access to the fib result on an input route lookup
with the rcu lock held. Refactor ip_route_input_noref pushing the logic
between rcu_read_lock ... rcu_read_unlock into a new helper that takes
the fib_result as an input arg.
Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
---
include/net/route.h | 3 +++
net/ipv4/route.c | 66 ++++++++++++++++++++++++++++++-----------------------
2 files changed, 40 insertions(+), 29 deletions(-)
diff --git a/include/net/route.h b/include/net/route.h
index 89e4028..08e689f 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -178,6 +178,9 @@ static inline struct rtable *ip_route_output_gre(struct net *net, struct flowi4
int ip_route_input_noref(struct sk_buff *skb, __be32 dst, __be32 src,
u8 tos, struct net_device *devin);
+int ip_route_input_rcu(struct sk_buff *skb, __be32 dst, __be32 src,
+ u8 tos, struct net_device *devin,
+ struct fib_result *res);
static inline int ip_route_input(struct sk_buff *skb, __be32 dst, __be32 src,
u8 tos, struct net_device *devin)
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index c9b55cb..1dc8fd1 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1852,9 +1852,9 @@ static int ip_mkroute_input(struct sk_buff *skb,
*/
static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
- u8 tos, struct net_device *dev)
+ u8 tos, struct net_device *dev,
+ struct fib_result *res)
{
- struct fib_result res;
struct in_device *in_dev = __in_dev_get_rcu(dev);
struct ip_tunnel_info *tun_info;
struct flowi4 fl4;
@@ -1884,8 +1884,8 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
if (ipv4_is_multicast(saddr) || ipv4_is_lbcast(saddr))
goto martian_source;
- res.fi = NULL;
- res.table = NULL;
+ res->fi = NULL;
+ res->table = NULL;
if (ipv4_is_lbcast(daddr) || (saddr == 0 && daddr == 0))
goto brd_input;
@@ -1921,17 +1921,17 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
fl4.daddr = daddr;
fl4.saddr = saddr;
fl4.flowi4_uid = sock_net_uid(net, NULL);
- err = fib_lookup(net, &fl4, &res, 0);
+ err = fib_lookup(net, &fl4, res, 0);
if (err != 0) {
if (!IN_DEV_FORWARD(in_dev))
err = -EHOSTUNREACH;
goto no_route;
}
- if (res.type == RTN_BROADCAST)
+ if (res->type == RTN_BROADCAST)
goto brd_input;
- if (res.type == RTN_LOCAL) {
+ if (res->type == RTN_LOCAL) {
err = fib_validate_source(skb, saddr, daddr, tos,
0, dev, in_dev, &itag);
if (err < 0)
@@ -1943,10 +1943,10 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
err = -EHOSTUNREACH;
goto no_route;
}
- if (res.type != RTN_UNICAST)
+ if (res->type != RTN_UNICAST)
goto martian_destination;
- err = ip_mkroute_input(skb, &res, in_dev, daddr, saddr, tos);
+ err = ip_mkroute_input(skb, res, in_dev, daddr, saddr, tos);
out: return err;
brd_input:
@@ -1960,14 +1960,14 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
goto martian_source;
}
flags |= RTCF_BROADCAST;
- res.type = RTN_BROADCAST;
+ res->type = RTN_BROADCAST;
RT_CACHE_STAT_INC(in_brd);
local_input:
do_cache = false;
- if (res.fi) {
+ if (res->fi) {
if (!itag) {
- rth = rcu_dereference(FIB_RES_NH(res).nh_rth_input);
+ rth = rcu_dereference(FIB_RES_NH(*res).nh_rth_input);
if (rt_cache_valid(rth)) {
skb_dst_set_noref(skb, &rth->dst);
err = 0;
@@ -1978,7 +1978,7 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
}
rth = rt_dst_alloc(l3mdev_master_dev_rcu(dev) ? : net->loopback_dev,
- flags | RTCF_LOCAL, res.type,
+ flags | RTCF_LOCAL, res->type,
IN_DEV_CONF_GET(in_dev, NOPOLICY), false, do_cache);
if (!rth)
goto e_nobufs;
@@ -1988,18 +1988,18 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
rth->dst.tclassid = itag;
#endif
rth->rt_is_input = 1;
- if (res.table)
- rth->rt_table_id = res.table->tb_id;
+ if (res->table)
+ rth->rt_table_id = res->table->tb_id;
RT_CACHE_STAT_INC(in_slow_tot);
- if (res.type == RTN_UNREACHABLE) {
+ if (res->type == RTN_UNREACHABLE) {
rth->dst.input= ip_error;
rth->dst.error= -err;
rth->rt_flags &= ~RTCF_LOCAL;
}
if (do_cache) {
- struct fib_nh *nh = &FIB_RES_NH(res);
+ struct fib_nh *nh = &FIB_RES_NH(*res);
rth->dst.lwtstate = lwtstate_get(nh->nh_lwtstate);
if (lwtunnel_input_redirect(rth->dst.lwtstate)) {
@@ -2019,9 +2019,9 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
no_route:
RT_CACHE_STAT_INC(in_no_route);
- res.type = RTN_UNREACHABLE;
- res.fi = NULL;
- res.table = NULL;
+ res->type = RTN_UNREACHABLE;
+ res->fi = NULL;
+ res->table = NULL;
goto local_input;
/*
@@ -2051,11 +2051,22 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
int ip_route_input_noref(struct sk_buff *skb, __be32 daddr, __be32 saddr,
u8 tos, struct net_device *dev)
{
- int res;
+ struct fib_result res;
+ int err;
tos &= IPTOS_RT_MASK;
rcu_read_lock();
+ err = ip_route_input_rcu(skb, daddr, saddr, tos, dev, &res);
+ rcu_read_unlock();
+ return err;
+}
+EXPORT_SYMBOL(ip_route_input_noref);
+
+/* called with rcu_read_lock held */
+int ip_route_input_rcu(struct sk_buff *skb, __be32 daddr, __be32 saddr,
+ u8 tos, struct net_device *dev, struct fib_result *res)
+{
/* Multicast recognition logic is moved from route cache to here.
The problem was that too many Ethernet cards have broken/missing
hardware multicast filters :-( As result the host on multicasting
@@ -2070,6 +2081,7 @@ int ip_route_input_noref(struct sk_buff *skb, __be32 daddr, __be32 saddr,
if (ipv4_is_multicast(daddr)) {
struct in_device *in_dev = __in_dev_get_rcu(dev);
int our = 0;
+ int err = -EINVAL;
if (in_dev)
our = ip_check_mc_rcu(in_dev, daddr, saddr,
@@ -2085,7 +2097,6 @@ int ip_route_input_noref(struct sk_buff *skb, __be32 daddr, __be32 saddr,
ip_hdr(skb)->protocol);
}
- res = -EINVAL;
if (our
#ifdef CONFIG_IP_MROUTE
||
@@ -2093,17 +2104,14 @@ int ip_route_input_noref(struct sk_buff *skb, __be32 daddr, __be32 saddr,
IN_DEV_MFORWARD(in_dev))
#endif
) {
- res = ip_route_input_mc(skb, daddr, saddr,
+ err = ip_route_input_mc(skb, daddr, saddr,
tos, dev, our);
}
- rcu_read_unlock();
- return res;
+ return err;
}
- res = ip_route_input_slow(skb, daddr, saddr, tos, dev);
- rcu_read_unlock();
- return res;
+
+ return ip_route_input_slow(skb, daddr, saddr, tos, dev, res);
}
-EXPORT_SYMBOL(ip_route_input_noref);
/* called with rcu_read_lock() */
static struct rtable *__mkroute_output(const struct fib_result *res,
--
1.9.1
^ permalink raw reply related
* [PATCH net-next v2 1/8] net: ipv4: refactor __ip_route_output_key_hash
From: Roopa Prabhu @ 2017-05-25 17:42 UTC (permalink / raw)
To: davem, dsahern, rami.rosen; +Cc: netdev, nikolay
In-Reply-To: <1495734160-47659-1-git-send-email-roopa@cumulusnetworks.com>
From: David Ahern <dsahern@gmail.com>
A later patch wants access to the fib result on an output route lookup
with the rcu lock held. Refactor __ip_route_output_key_hash, pushing
the logic between rcu_read_lock ... rcu_read_unlock into a new helper
with the fib_result as an input arg.
To keep the name length under control remove the leading underscores
from the name and add _rcu to the name of the new helper indicating it
is called with the rcu read lock held.
Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
---
include/net/route.h | 9 ++++++---
net/ipv4/icmp.c | 2 +-
net/ipv4/route.c | 53 +++++++++++++++++++++++++++++++----------------------
3 files changed, 38 insertions(+), 26 deletions(-)
diff --git a/include/net/route.h b/include/net/route.h
index 2cc0e14..89e4028 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -113,13 +113,16 @@ struct rt_cache_stat {
int ip_rt_init(void);
void rt_cache_flush(struct net *net);
void rt_flush_dev(struct net_device *dev);
-struct rtable *__ip_route_output_key_hash(struct net *net, struct flowi4 *flp,
- const struct sk_buff *skb);
+struct rtable *ip_route_output_key_hash(struct net *net, struct flowi4 *flp,
+ const struct sk_buff *skb);
+struct rtable *ip_route_output_key_hash_rcu(struct net *net, struct flowi4 *flp,
+ struct fib_result *res,
+ const struct sk_buff *skb);
static inline struct rtable *__ip_route_output_key(struct net *net,
struct flowi4 *flp)
{
- return __ip_route_output_key_hash(net, flp, NULL);
+ return ip_route_output_key_hash(net, flp, NULL);
}
struct rtable *ip_route_output_flow(struct net *, struct flowi4 *flp,
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 43318b5..5610971 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -489,7 +489,7 @@ static struct rtable *icmp_route_lookup(struct net *net,
fl4->flowi4_oif = l3mdev_master_ifindex(skb_dst(skb_in)->dev);
security_skb_classify_flow(skb_in, flowi4_to_flowi(fl4));
- rt = __ip_route_output_key_hash(net, fl4, skb_in);
+ rt = ip_route_output_key_hash(net, fl4, skb_in);
if (IS_ERR(rt))
return rt;
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 655d9ee..c9b55cb 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2246,29 +2246,40 @@ static struct rtable *__mkroute_output(const struct fib_result *res,
* Major route resolver routine.
*/
-struct rtable *__ip_route_output_key_hash(struct net *net, struct flowi4 *fl4,
- const struct sk_buff *skb)
+struct rtable *ip_route_output_key_hash(struct net *net, struct flowi4 *fl4,
+ const struct sk_buff *skb)
{
- struct net_device *dev_out = NULL;
__u8 tos = RT_FL_TOS(fl4);
- unsigned int flags = 0;
struct fib_result res;
struct rtable *rth;
- int orig_oif;
- int err = -ENETUNREACH;
res.tclassid = 0;
res.fi = NULL;
res.table = NULL;
- orig_oif = fl4->flowi4_oif;
-
fl4->flowi4_iif = LOOPBACK_IFINDEX;
fl4->flowi4_tos = tos & IPTOS_RT_MASK;
fl4->flowi4_scope = ((tos & RTO_ONLINK) ?
RT_SCOPE_LINK : RT_SCOPE_UNIVERSE);
rcu_read_lock();
+ rth = ip_route_output_key_hash_rcu(net, fl4, &res, skb);
+ rcu_read_unlock();
+
+ return rth;
+}
+EXPORT_SYMBOL_GPL(ip_route_output_key_hash);
+
+struct rtable *ip_route_output_key_hash_rcu(struct net *net, struct flowi4 *fl4,
+ struct fib_result *res,
+ const struct sk_buff *skb)
+{
+ struct net_device *dev_out = NULL;
+ int orig_oif = fl4->flowi4_oif;
+ unsigned int flags = 0;
+ struct rtable *rth;
+ int err = -ENETUNREACH;
+
if (fl4->saddr) {
rth = ERR_PTR(-EINVAL);
if (ipv4_is_multicast(fl4->saddr) ||
@@ -2354,15 +2365,15 @@ struct rtable *__ip_route_output_key_hash(struct net *net, struct flowi4 *fl4,
fl4->daddr = fl4->saddr = htonl(INADDR_LOOPBACK);
dev_out = net->loopback_dev;
fl4->flowi4_oif = LOOPBACK_IFINDEX;
- res.type = RTN_LOCAL;
+ res->type = RTN_LOCAL;
flags |= RTCF_LOCAL;
goto make_route;
}
- err = fib_lookup(net, fl4, &res, 0);
+ err = fib_lookup(net, fl4, res, 0);
if (err) {
- res.fi = NULL;
- res.table = NULL;
+ res->fi = NULL;
+ res->table = NULL;
if (fl4->flowi4_oif &&
(ipv4_is_multicast(fl4->daddr) ||
!netif_index_is_l3_master(net, fl4->flowi4_oif))) {
@@ -2387,43 +2398,41 @@ struct rtable *__ip_route_output_key_hash(struct net *net, struct flowi4 *fl4,
if (fl4->saddr == 0)
fl4->saddr = inet_select_addr(dev_out, 0,
RT_SCOPE_LINK);
- res.type = RTN_UNICAST;
+ res->type = RTN_UNICAST;
goto make_route;
}
rth = ERR_PTR(err);
goto out;
}
- if (res.type == RTN_LOCAL) {
+ if (res->type == RTN_LOCAL) {
if (!fl4->saddr) {
- if (res.fi->fib_prefsrc)
- fl4->saddr = res.fi->fib_prefsrc;
+ if (res->fi->fib_prefsrc)
+ fl4->saddr = res->fi->fib_prefsrc;
else
fl4->saddr = fl4->daddr;
}
/* L3 master device is the loopback for that domain */
- dev_out = l3mdev_master_dev_rcu(FIB_RES_DEV(res)) ? :
+ dev_out = l3mdev_master_dev_rcu(FIB_RES_DEV(*res)) ? :
net->loopback_dev;
fl4->flowi4_oif = dev_out->ifindex;
flags |= RTCF_LOCAL;
goto make_route;
}
- fib_select_path(net, &res, fl4, skb);
+ fib_select_path(net, res, fl4, skb);
- dev_out = FIB_RES_DEV(res);
+ dev_out = FIB_RES_DEV(*res);
fl4->flowi4_oif = dev_out->ifindex;
make_route:
- rth = __mkroute_output(&res, fl4, orig_oif, dev_out, flags);
+ rth = __mkroute_output(res, fl4, orig_oif, dev_out, flags);
out:
- rcu_read_unlock();
return rth;
}
-EXPORT_SYMBOL_GPL(__ip_route_output_key_hash);
static struct dst_entry *ipv4_blackhole_dst_check(struct dst_entry *dst, u32 cookie)
{
--
1.9.1
^ permalink raw reply related
* [PATCH net-next v2 0/8] net: extend RTM_GETROUTE to return fib result
From: Roopa Prabhu @ 2017-05-25 17:42 UTC (permalink / raw)
To: davem, dsahern, rami.rosen; +Cc: netdev, nikolay
From: Roopa Prabhu <roopa@cumulusnetworks.com>
This series adds a new RTM_F_FIB_MATCH flag to return matched fib result
with RTM_GETROUTE. This is useful for applications and protocols in
userspace wanting to query the selected route.
examples (with patched iproute2):
ipv4:
----
$ip route show
default via 192.168.0.2 dev eth0
10.0.14.0/24
nexthop via 172.16.0.3 dev dummy0 weight 1
nexthop via 172.16.1.3 dev dummy1 weight 1
$ip route get 10.0.14.2
10.0.14.2 via 172.16.1.3 dev dummy1 src 172.16.1.1
cache
$ip route get fibmatch 10.0.14.2
10.0.14.0/24
nexthop via 172.16.0.3 dev dummy0 weight 1
nexthop via 172.16.1.3 dev dummy1 weight 1
ipv6:
----
$ip -6 route show
2001:db9:100::/120 metric 1024
nexthop via 2001:db8:2::2 dev dummy0 weight 1
nexthop via 2001:db8:12::2 dev dummy1 weight 1
$ip -6 route get 2001:db9:100::1
2001:db9:100::1 from :: via 2001:db8:12::2 dev dummy1 src 2001:db8:12::1 metric 1024 pref medium
$ip -6 route get fibmatch 2001:db9:100::1
2001:db9:100::/120 metric 1024
nexthop via 2001:db8:12::2 dev dummy1 weight 1
nexthop via 2001:db8:2::2 dev dummy0 weight 1
v2:
- pick up new forward port of patch-01 from david
- inet6_rtm_getroute: use container_of for rt6_info to
dst conversion
David Ahern (5):
net: ipv4: refactor __ip_route_output_key_hash
net: ipv4: refactor ip_route_input_noref
net: ipv4: Remove event arg to rt_fill_info
net: ipv4: Convert inet_rtm_getroute to rcu versions of route lookup
net: ipv4: Save trie prefix to fib lookup result
Roopa Prabhu (3):
net: ipv4: add new RTM_F_FIB_MATCH flag for use with RTM_GETROUTE
net: ipv4: RTM_GETROUTE: return matched fib result when
RTM_F_FIB_MATCH flag present
net: ipv6: RTM_GETROUTE: return matched fib result when
RTM_F_FIB_MATCH flag present
include/net/ip_fib.h | 1 +
include/net/route.h | 10 ++-
include/uapi/linux/rtnetlink.h | 1 +
net/ipv4/fib_trie.c | 1 +
net/ipv4/icmp.c | 2 +-
net/ipv4/route.c | 160 ++++++++++++++++++++++++-----------------
net/ipv6/route.c | 11 ++-
7 files changed, 116 insertions(+), 70 deletions(-)
--
1.9.1
^ permalink raw reply
* [PATCH net-next] liquidio: fix rare pci_driver.probe failure of VF driver
From: Felix Manlunas @ 2017-05-25 17:42 UTC (permalink / raw)
To: davem
Cc: netdev, raghu.vatsavayi, derek.chickles, satananda.burla,
prasad.kanneganti
From: Prasad Kanneganti <prasad.kanneganti@cavium.com>
There's a rare pci_driver.probe failure of the VF driver that's caused by
PF/VF handshake going out of sync. The culprit is octeon_mbox_write() who
ignores an ack timeout condition; it just keeps unconditionally writing all
elements of mbox_cmd->data[] even when the other side is not ready for
them. Fix it by making each write of mbox_cmd->data[i] conditional to
having previously received an ack.
Also fix the octeon_mbox_state enum such that each state gets a unique
value. Also add ULL suffix to numeric literals in macro definitions.
Signed-off-by: Prasad Kanneganti <prasad.kanneganti@cavium.com>
Signed-off-by: Felix Manlunas <felix.manlunas@cavium.com>
---
drivers/net/ethernet/cavium/liquidio/octeon_mailbox.c | 5 ++++-
drivers/net/ethernet/cavium/liquidio/octeon_mailbox.h | 12 ++++++------
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_mailbox.c b/drivers/net/ethernet/cavium/liquidio/octeon_mailbox.c
index 5cca73b..57af7df 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_mailbox.c
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_mailbox.c
@@ -178,7 +178,10 @@ int octeon_mbox_write(struct octeon_device *oct,
break;
}
}
- writeq(mbox_cmd->data[i], mbox->mbox_write_reg);
+ if (ret == OCTEON_MBOX_STATUS_SUCCESS)
+ writeq(mbox_cmd->data[i], mbox->mbox_write_reg);
+ else
+ break;
}
}
diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_mailbox.h b/drivers/net/ethernet/cavium/liquidio/octeon_mailbox.h
index c9376fe..1def22a 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_mailbox.h
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_mailbox.h
@@ -20,16 +20,16 @@
/* Macros for Mail Box Communication */
-#define OCTEON_MBOX_DATA_MAX 32
+#define OCTEON_MBOX_DATA_MAX 32
#define OCTEON_VF_ACTIVE 0x1
#define OCTEON_VF_FLR_REQUEST 0x2
#define OCTEON_PF_CHANGED_VF_MACADDR 0x4
/*Macro for Read acknowldgement*/
-#define OCTEON_PFVFACK 0xffffffffffffffff
-#define OCTEON_PFVFSIG 0x1122334455667788
-#define OCTEON_PFVFERR 0xDEADDEADDEADDEAD
+#define OCTEON_PFVFACK 0xffffffffffffffffULL
+#define OCTEON_PFVFSIG 0x1122334455667788ULL
+#define OCTEON_PFVFERR 0xDEADDEADDEADDEADULL
#define LIO_MBOX_WRITE_WAIT_CNT 1000
#define LIO_MBOX_WRITE_WAIT_TIME msecs_to_jiffies(1)
@@ -74,8 +74,8 @@ enum octeon_mbox_state {
OCTEON_MBOX_STATE_REQUEST_RECEIVED = 4,
OCTEON_MBOX_STATE_RESPONSE_PENDING = 8,
OCTEON_MBOX_STATE_RESPONSE_RECEIVING = 16,
- OCTEON_MBOX_STATE_RESPONSE_RECEIVED = 16,
- OCTEON_MBOX_STATE_ERROR = 32
+ OCTEON_MBOX_STATE_RESPONSE_RECEIVED = 32,
+ OCTEON_MBOX_STATE_ERROR = 64
};
struct octeon_mbox {
^ permalink raw reply related
* Re: [PATCH net] sky2: Do not deadlock on sky2_hw_down
From: David Miller @ 2017-05-25 17:42 UTC (permalink / raw)
To: jemele; +Cc: netdev, jemele, mlindner, stephen, linux-kernel
In-Reply-To: <20170524224353.124692-1-jemele@gmail.com>
From: Joshua Emele <jemele@gmail.com>
Date: Wed, 24 May 2017 15:43:18 -0700
> From: Joshua Emele <jemele@google.com>
>
> The sky2_hw_down uses sky2_tx_complete to free pending frames stuck in
> the HW queue. Because sky2_hw_down can be called from a process context,
> the call to u64_stats_update_begin can result in deadlock.
>
> Because the statistics do not require update as part of the sky2_hw_down
> sequence, prevent the update to avoid the deadlock.
I disagree. Taking the interface down should cause events in the
statistics to be lost.
You're going to have to find a way to fix this without eliding
the stats increments.
Thanks.
^ permalink raw reply
* Re: [PATCH] arp: fixed -Wuninitialized compiler warning
From: David Miller @ 2017-05-25 17:38 UTC (permalink / raw)
To: ihrachys; +Cc: ja, netdev
In-Reply-To: <20170524221935.11167-1-ihrachys@redhat.com>
From: Ihar Hrachyshka <ihrachys@redhat.com>
Date: Wed, 24 May 2017 15:19:35 -0700
> Commit 7d472a59c0e5ec117220a05de6b370447fb6cb66 ("arp: always override
> existing neigh entries with gratuitous ARP") introduced a compiler
> warning:
>
> net/ipv4/arp.c:880:35: warning: 'addr_type' may be used uninitialized in
> this function [-Wmaybe-uninitialized]
>
> While the code logic seems to be correct and doesn't allow the variable
> to be used uninitialized, and the warning is not consistently
> reproducible, it's still worth fixing it for other people not to waste
> time looking at the warning in case it pops up in the build environment.
> Yes, compiler is probably at fault, but we will need to accommodate.
>
> Fixes: 7d472a59c0e5ec117220a05de6b370447fb6cb66
> Signed-off-by: Ihar Hrachyshka <ihrachys@redhat.com>
Applied, but please in the future format your Fixes: tag properly
which should have been:
Fixes: 7d472a59c0e5 ("arp: always override existing neigh entries with gratuitous ARP")
Thanks.
^ permalink raw reply
* Re: [PATCH net] tcp: avoid fastopen API to be used on AF_UNSPEC
From: David Miller @ 2017-05-25 17:30 UTC (permalink / raw)
To: weiwan; +Cc: netdev, ycheng, vegard.nossum, edumazet
In-Reply-To: <20170524165931.22502-1-tracywwnj@gmail.com>
From: Wei Wang <weiwan@google.com>
Date: Wed, 24 May 2017 09:59:31 -0700
> Fastopen API should be used to perform fastopen operations on the TCP
> socket. It does not make sense to use fastopen API to perform disconnect
> by calling it with AF_UNSPEC. The fastopen data path is also prone to
> race conditions and bugs when using with AF_UNSPEC.
>
> One issue reported and analyzed by Vegard Nossum is as follows:
...
> If the connection is reopened then we will send a brand new SYN packet
> after thread A has already queued a buffer. At this point I think the
> socket internal state (sequence numbers etc.) becomes messed up.
>
> When the new connection is closed, the FIN-ACK is rejected because the
> sequence number is outside the window. The other side tries to
> retransmit,
> but __tcp_retransmit_skb() calls tcp_trim_head() on an empty skb which
> corrupts the skb data length and hits a BUG() in copy_and_csum_bits().
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Hence, this patch adds a check for AF_UNSPEC in the fastopen data path
> and return EOPNOTSUPP to user if such case happens.
>
> Fixes: cf60af03ca4e7 ("tcp: Fast Open client - sendmsg(MSG_FASTOPEN)")
> Reported-by: Vegard Nossum <vegard.nossum@oracle.com>
> Signed-off-by: Wei Wang <weiwan@google.com>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Applied and queue up for -stable, thanks.
^ permalink raw reply
* Re: [PATCH net v2] sctp: fix ICMP processing if skb is non-linear
From: Marcelo Ricardo Leitner @ 2017-05-25 17:29 UTC (permalink / raw)
To: Davide Caratti; +Cc: netdev, linux-sctp, Xin Long, David S . Miller
In-Reply-To: <d0cd7c2e4b9329ec23e48aed94bf2fbf94554f44.1495730857.git.dcaratti@redhat.com>
On Thu, May 25, 2017 at 07:14:56PM +0200, Davide Caratti wrote:
> sometimes ICMP replies to INIT chunks are ignored by the client, even if
> the encapsulated SCTP headers match an open socket. This happens when the
> ICMP packet is carried by a paged skb: use skb_header_pointer() to read
> packet contents beyond the SCTP header, so that chunk header and initiate
> tag are validated correctly.
>
> v2:
> - don't use skb_header_pointer() to read the transport header, since
> icmp_socket_deliver() already puts these 8 bytes in the linear area.
> - change commit message to make specific reference to INIT chunks.
>
> Signed-off-by: Davide Caratti <dcaratti@redhat.com>
LGTM
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
> ---
> net/sctp/input.c | 16 +++++++++-------
> 1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/net/sctp/input.c b/net/sctp/input.c
> index 0e06a27..ba9ad32 100644
> --- a/net/sctp/input.c
> +++ b/net/sctp/input.c
> @@ -473,15 +473,14 @@ struct sock *sctp_err_lookup(struct net *net, int family, struct sk_buff *skb,
> struct sctp_association **app,
> struct sctp_transport **tpp)
> {
> + struct sctp_init_chunk *chunkhdr, _chunkhdr;
> union sctp_addr saddr;
> union sctp_addr daddr;
> struct sctp_af *af;
> struct sock *sk = NULL;
> struct sctp_association *asoc;
> struct sctp_transport *transport = NULL;
> - struct sctp_init_chunk *chunkhdr;
> __u32 vtag = ntohl(sctphdr->vtag);
> - int len = skb->len - ((void *)sctphdr - (void *)skb->data);
>
> *app = NULL; *tpp = NULL;
>
> @@ -516,13 +515,16 @@ struct sock *sctp_err_lookup(struct net *net, int family, struct sk_buff *skb,
> * discard the packet.
> */
> if (vtag == 0) {
> - chunkhdr = (void *)sctphdr + sizeof(struct sctphdr);
> - if (len < sizeof(struct sctphdr) + sizeof(sctp_chunkhdr_t)
> - + sizeof(__be32) ||
> + /* chunk header + first 4 octects of init header */
> + chunkhdr = skb_header_pointer(skb, skb_transport_offset(skb) +
> + sizeof(struct sctphdr),
> + sizeof(struct sctp_chunkhdr) +
> + sizeof(__be32), &_chunkhdr);
> + if (!chunkhdr ||
> chunkhdr->chunk_hdr.type != SCTP_CID_INIT ||
> - ntohl(chunkhdr->init_hdr.init_tag) != asoc->c.my_vtag) {
> + ntohl(chunkhdr->init_hdr.init_tag) != asoc->c.my_vtag)
> goto out;
> - }
> +
> } else if (vtag != asoc->c.peer_vtag) {
> goto out;
> }
> --
> 2.9.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply
* Re: [PATCH net-next 0/4] kernel TLS
From: David Miller @ 2017-05-25 17:29 UTC (permalink / raw)
To: davejwatson
Cc: ilyal, aviadye, borisp, liranl, matanb, netdev, tom, herbert,
linux-crypto, hannes, alexei.starovoitov, nmav, fridolin.pokorny
In-Reply-To: <20170524162633.GA24030@davejwatson-mba.local>
From: Dave Watson <davejwatson@fb.com>
Date: Wed, 24 May 2017 09:26:33 -0700
> This series adds support for kernel TLS encryption over TCP sockets.
> A standard TCP socket is converted to a TLS socket using a setsockopt.
> Only symmetric crypto is done in the kernel, as well as TLS record
> framing. The handshake remains in userspace, and the negotiated
> cipher keys/iv are provided to the TCP socket.
>
> We implemented support for this API in OpenSSL 1.1.0, the code is
> available at https://github.com/Mellanox/tls-openssl/tree/master
>
> It should work with any TLS library with similar modifications,
> a test tool using gnutls is here: https://github.com/Mellanox/tls-af_ktls_tool
>
> Changes from RFC V2:
>
> * Generic ULP (upper layer protocol) framework instead of TLS specific
> setsockopts
> * Dropped Mellanox hardware patches, will come as separate series.
> Framework will work for both.
The value in this is seeing how it can work transparently behind
an existing userspace library providing TLS services.
So the reference to the gnutls and openssl implementations probably
belongs in the Documentation patch #4 too.
Thanks.
^ permalink raw reply
* Re: [PATCH net-next 2/4] tcp: export do_tcp_sendpages and tcp_rate_check_app_limited functions
From: David Miller @ 2017-05-25 17:26 UTC (permalink / raw)
To: davejwatson
Cc: ilyal, aviadye, borisp, liranl, matanb, netdev, tom, herbert,
linux-crypto, hannes, alexei.starovoitov, nmav, fridolin.pokorny
In-Reply-To: <20170524162657.GA24165@davejwatson-mba.local>
From: Dave Watson <davejwatson@fb.com>
Date: Wed, 24 May 2017 09:26:57 -0700
> Export do_tcp_sendpages and tcp_rate_check_app_limited, since tls will need to
> sendpages while the socket is already locked.
>
> tcp_sendpage is exported, but requires the socket lock to not be held already.
>
> Signed-off-by: Aviad Yehezkel <aviadye@mellanox.com>
> Signed-off-by: Ilya Lesokhin <ilyal@mellanox.com>
> Signed-off-by: Boris Pismenny <borisp@mellanox.com>
> Signed-off-by: Dave Watson <davejwatson@fb.com>
...
> +EXPORT_SYMBOL(do_tcp_sendpages);
...
> +EXPORT_SYMBOL(tcp_rate_check_app_limited);
These need to both be EXPORT_SYMBOL_GPL().
^ permalink raw reply
* Re: [PATCH net-next] tcp: better validation of received ack sequences
From: David Miller @ 2017-05-25 17:22 UTC (permalink / raw)
To: eric.dumazet
Cc: p.fiterau-brostean, netdev, F.Vaandrager, ncardwell, ycheng,
soheil
In-Reply-To: <1495731051.6465.100.camel@edumazet-glaptop3.roam.corp.google.com>
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 25 May 2017 09:50:51 -0700
> On Thu, 2017-05-25 at 12:48 -0400, David Miller wrote:
>> From: Eric Dumazet <eric.dumazet@gmail.com>
>> Date: Tue, 23 May 2017 15:24:46 -0700
>>
>> > Add a FLAG_NO_CHALLENGE_ACK so that tcp_rcv_state_process()
>> > can choose to send a challenge ACK and discard the packet instead
>> > of wrongly change socket state.
>>
>> Applied, but the tests end up being double-negatives so it might
>> have been easier to understand if the flag was a positive rather
>> than a negative value.
>
> I thought of this (and was in fact one of the patch I sent for internal
> review at Google), but this was changing all tcp_ack() calls instead of
> a single one ?
>
> Or maybe I am missing some easier way ?
Indeed, it is a bit of churn to adjust all callers in order to make
one test easier to read.
I'm not so sure it's better or worth it...
^ permalink raw reply
* Re: [PATCH net-next] rxrpc: Support network namespacing
From: David Miller @ 2017-05-25 17:20 UTC (permalink / raw)
To: dhowells; +Cc: netdev, linux-afs, linux-kernel
In-Reply-To: <149564175249.12289.12304563996697291080.stgit@warthog.procyon.org.uk>
From: David Howells <dhowells@redhat.com>
Date: Wed, 24 May 2017 17:02:32 +0100
> Support network namespacing in AF_RXRPC with the following changes:
>
> (1) All the local endpoint, peer and call lists, locks, counters, etc. are
> moved into the per-namespace record.
>
> (2) All the connection tracking is moved into the per-namespace record
> with the exception of the client connection ID tree, which is kept
> global so that connection IDs are kept unique per-machine.
>
> (3) Each namespace gets its own epoch. This allows each network namespace
> to pretend to be a separate client machine.
>
> (4) The /proc/net/rxrpc_xxx files are now called /proc/net/rxrpc/xxx and
> the contents reflect the namespace.
>
> fs/afs/ should be okay with this patch as it explicitly requires the current
> net namespace to be init_net to permit a mount to proceed at the moment. It
> will, however, need updating so that cells, IP addresses and DNS records are
> per-namespace also.
>
> Signed-off-by: David Howells <dhowells@redhat.com>
Applied.
^ permalink raw reply
* Re: [PATCH net-next] net/packet: remove unused parameter in prb_curr_blk_in_use().
From: David Miller @ 2017-05-25 17:19 UTC (permalink / raw)
To: rami.rosen; +Cc: netdev
In-Reply-To: <1495640051-39181-1-git-send-email-rami.rosen@intel.com>
From: Rami Rosen <rami.rosen@intel.com>
Date: Wed, 24 May 2017 18:34:11 +0300
> This patch removes unused parameter from prb_curr_blk_in_use() method
> in net/packet/af_packet.c.
>
> Signed-off-by: Rami Rosen <rami.rosen@intel.com>
Applied.
^ permalink raw reply
* [PATCH net v2] sctp: fix ICMP processing if skb is non-linear
From: Davide Caratti @ 2017-05-25 17:14 UTC (permalink / raw)
To: netdev, linux-sctp; +Cc: Xin Long, Marcelo Ricardo Leitner, David S . Miller
sometimes ICMP replies to INIT chunks are ignored by the client, even if
the encapsulated SCTP headers match an open socket. This happens when the
ICMP packet is carried by a paged skb: use skb_header_pointer() to read
packet contents beyond the SCTP header, so that chunk header and initiate
tag are validated correctly.
v2:
- don't use skb_header_pointer() to read the transport header, since
icmp_socket_deliver() already puts these 8 bytes in the linear area.
- change commit message to make specific reference to INIT chunks.
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
---
net/sctp/input.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/net/sctp/input.c b/net/sctp/input.c
index 0e06a27..ba9ad32 100644
--- a/net/sctp/input.c
+++ b/net/sctp/input.c
@@ -473,15 +473,14 @@ struct sock *sctp_err_lookup(struct net *net, int family, struct sk_buff *skb,
struct sctp_association **app,
struct sctp_transport **tpp)
{
+ struct sctp_init_chunk *chunkhdr, _chunkhdr;
union sctp_addr saddr;
union sctp_addr daddr;
struct sctp_af *af;
struct sock *sk = NULL;
struct sctp_association *asoc;
struct sctp_transport *transport = NULL;
- struct sctp_init_chunk *chunkhdr;
__u32 vtag = ntohl(sctphdr->vtag);
- int len = skb->len - ((void *)sctphdr - (void *)skb->data);
*app = NULL; *tpp = NULL;
@@ -516,13 +515,16 @@ struct sock *sctp_err_lookup(struct net *net, int family, struct sk_buff *skb,
* discard the packet.
*/
if (vtag == 0) {
- chunkhdr = (void *)sctphdr + sizeof(struct sctphdr);
- if (len < sizeof(struct sctphdr) + sizeof(sctp_chunkhdr_t)
- + sizeof(__be32) ||
+ /* chunk header + first 4 octects of init header */
+ chunkhdr = skb_header_pointer(skb, skb_transport_offset(skb) +
+ sizeof(struct sctphdr),
+ sizeof(struct sctp_chunkhdr) +
+ sizeof(__be32), &_chunkhdr);
+ if (!chunkhdr ||
chunkhdr->chunk_hdr.type != SCTP_CID_INIT ||
- ntohl(chunkhdr->init_hdr.init_tag) != asoc->c.my_vtag) {
+ ntohl(chunkhdr->init_hdr.init_tag) != asoc->c.my_vtag)
goto out;
- }
+
} else if (vtag != asoc->c.peer_vtag) {
goto out;
}
--
2.9.4
^ permalink raw reply related
* Re: [PATCH v7 net-next 17/17] net: qualcomm: add QCA7000 UART driver
From: David Miller @ 2017-05-25 17:13 UTC (permalink / raw)
To: stefan.wahren
Cc: robh+dt, mark.rutland, gregkh, jslaby, LinoSanfilippo, kubakici,
devicetree, netdev, linux-serial, linux-kernel
In-Reply-To: <1495618181-1204-1-git-send-email-stefan.wahren@i2se.com>
When you submit a new version of a patch within a patch series, you must
always resubmit the entire series not just the patches which change.
Thank you.
^ permalink raw reply
* Re: [PATCH v2] net: move somaxconn init from sysctl code
From: David Miller @ 2017-05-25 17:12 UTC (permalink / raw)
To: roman.kapl; +Cc: netdev
In-Reply-To: <20170524082222.14208-1-roman.kapl@sysgo.com>
From: Roman Kapl <roman.kapl@sysgo.com>
Date: Wed, 24 May 2017 10:22:22 +0200
> The default value for somaxconn is set in sysctl_core_net_init(), but this
> function is not called when kernel is configured without CONFIG_SYSCTL.
>
> This results in the kernel not being able to accept TCP connections,
> because the backlog has zero size. Usually, the user ends up with:
> "TCP: request_sock_TCP: Possible SYN flooding on port 7. Dropping request. Check SNMP counters."
> If SYN cookies are not enabled the connection is rejected.
>
> Before ef547f2ac16 (tcp: remove max_qlen_log), the effects were less
> severe, because the backlog was always at least eight slots long.
>
> Signed-off-by: Roman Kapl <roman.kapl@sysgo.com>
This looks better, applied, thanks.
^ permalink raw reply
* Re: [PATCH net-next] net: rps: Add the rfs_needed check when record flow hash
From: David Miller @ 2017-05-25 17:11 UTC (permalink / raw)
To: gfree.wind; +Cc: netdev
In-Reply-To: <1495611359-118199-1-git-send-email-gfree.wind@vip.163.com>
From: gfree.wind@vip.163.com
Date: Wed, 24 May 2017 15:35:59 +0800
>
> +static inline void sock_rps_record_flow_hash(__u32 hash)
> +{
> +#ifdef CONFIG_RPS
> + if (static_key_false(&rfs_needed))
> + _sock_rps_record_flow_hash(hash);
> +#endif
> +}
> +
This is no longer used.
If you have some plans to use it in another context, you absolutely _MUST_
post this change inside of a patch series that adds the new user as well.
Otherwise it is impossible to determine the correctness and
appropriateness of your changes.
Thanks.
^ 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