[PATCH v2 7/9] net: rtmsg_to_fib6_config() - use new style struct initializer instead of memset

2018-09-29 Thread Maciej Żenczykowski
From: Maciej Żenczykowski 

(allows for better compiler optimization)

Signed-off-by: Maciej Żenczykowski 
---
 net/ipv6/route.c | 32 
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index dd19cf8dbcc1..c312ad4046d1 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -3604,23 +3604,23 @@ static void rtmsg_to_fib6_config(struct net *net,
 struct in6_rtmsg *rtmsg,
 struct fib6_config *cfg)
 {
-   memset(cfg, 0, sizeof(*cfg));
+   *cfg = (struct fib6_config){
+   .fc_table = l3mdev_fib_table_by_index(net, 
rtmsg->rtmsg_ifindex) ?
+: RT6_TABLE_MAIN,
+   .fc_ifindex = rtmsg->rtmsg_ifindex,
+   .fc_metric = rtmsg->rtmsg_metric,
+   .fc_expires = rtmsg->rtmsg_info,
+   .fc_dst_len = rtmsg->rtmsg_dst_len,
+   .fc_src_len = rtmsg->rtmsg_src_len,
+   .fc_flags = rtmsg->rtmsg_flags,
+   .fc_type = rtmsg->rtmsg_type,
+
+   .fc_nlinfo.nl_net = net,
 
-   cfg->fc_table = l3mdev_fib_table_by_index(net, rtmsg->rtmsg_ifindex) ?
-: RT6_TABLE_MAIN;
-   cfg->fc_ifindex = rtmsg->rtmsg_ifindex;
-   cfg->fc_metric = rtmsg->rtmsg_metric;
-   cfg->fc_expires = rtmsg->rtmsg_info;
-   cfg->fc_dst_len = rtmsg->rtmsg_dst_len;
-   cfg->fc_src_len = rtmsg->rtmsg_src_len;
-   cfg->fc_flags = rtmsg->rtmsg_flags;
-   cfg->fc_type = rtmsg->rtmsg_type;
-
-   cfg->fc_nlinfo.nl_net = net;
-
-   cfg->fc_dst = rtmsg->rtmsg_dst;
-   cfg->fc_src = rtmsg->rtmsg_src;
-   cfg->fc_gateway = rtmsg->rtmsg_gateway;
+   .fc_dst = rtmsg->rtmsg_dst,
+   .fc_src = rtmsg->rtmsg_src,
+   .fc_gateway = rtmsg->rtmsg_gateway,
+   };
 }
 
 int ipv6_route_ioctl(struct net *net, unsigned int cmd, void __user *arg)
-- 
2.19.0.605.g01d371f741-goog



[PATCH v2 5/9] net: remove 1 always zero parameter from ip6_redirect_no_header()

2018-09-29 Thread Maciej Żenczykowski
From: Maciej Żenczykowski 

(the parameter in question is mark)

Signed-off-by: Maciej Żenczykowski 
---
 include/net/ip6_route.h | 3 +--
 net/ipv6/ndisc.c| 2 +-
 net/ipv6/route.c| 4 +---
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index 7b9c82de11cc..cef186dbd2ce 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -165,8 +165,7 @@ void ip6_update_pmtu(struct sk_buff *skb, struct net *net, 
__be32 mtu, int oif,
 void ip6_sk_update_pmtu(struct sk_buff *skb, struct sock *sk, __be32 mtu);
 void ip6_redirect(struct sk_buff *skb, struct net *net, int oif, u32 mark,
  kuid_t uid);
-void ip6_redirect_no_header(struct sk_buff *skb, struct net *net, int oif,
-   u32 mark);
+void ip6_redirect_no_header(struct sk_buff *skb, struct net *net, int oif);
 void ip6_sk_redirect(struct sk_buff *skb, struct sock *sk);
 
 struct netlink_callback;
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 0ec273997d1d..51863ada15a4 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1533,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);
return;
}
 
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index dff80697c033..e50525a95a09 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2524,8 +2524,7 @@ void ip6_redirect(struct sk_buff *skb, struct net *net, 
int oif, u32 mark,
 }
 EXPORT_SYMBOL_GPL(ip6_redirect);
 
-void ip6_redirect_no_header(struct sk_buff *skb, struct net *net, int oif,
-   u32 mark)
+void ip6_redirect_no_header(struct sk_buff *skb, struct net *net, int oif)
 {
const struct ipv6hdr *iph = ipv6_hdr(skb);
const struct rd_msg *msg = (struct rd_msg *)icmp6_hdr(skb);
@@ -2533,7 +2532,6 @@ void ip6_redirect_no_header(struct sk_buff *skb, struct 
net *net, int oif,
struct flowi6 fl6 = {
.flowi6_iif = LOOPBACK_IFINDEX,
.flowi6_oif = oif,
-   .flowi6_mark = mark,
.daddr = msg->dest,
.saddr = iph->daddr,
.flowi6_uid = sock_net_uid(net, NULL),
-- 
2.19.0.605.g01d371f741-goog



[PATCH v2 6/9] net: ip6_update_pmtu() - use new style struct initializer instead of memset

2018-09-29 Thread Maciej Żenczykowski
From: Maciej Żenczykowski 

(allows for better compiler optimization)

Signed-off-by: Maciej Żenczykowski 
---
 net/ipv6/route.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index e50525a95a09..dd19cf8dbcc1 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2349,15 +2349,14 @@ void ip6_update_pmtu(struct sk_buff *skb, struct net 
*net, __be32 mtu,
 {
const struct ipv6hdr *iph = (struct ipv6hdr *) skb->data;
struct dst_entry *dst;
-   struct flowi6 fl6;
-
-   memset(&fl6, 0, sizeof(fl6));
-   fl6.flowi6_oif = oif;
-   fl6.flowi6_mark = mark ? mark : IP6_REPLY_MARK(net, skb->mark);
-   fl6.daddr = iph->daddr;
-   fl6.saddr = iph->saddr;
-   fl6.flowlabel = ip6_flowinfo(iph);
-   fl6.flowi6_uid = uid;
+   struct flowi6 fl6 = {
+   .flowi6_oif = oif,
+   .flowi6_mark = mark ? mark : IP6_REPLY_MARK(net, skb->mark),
+   .daddr = iph->daddr,
+   .saddr = iph->saddr,
+   .flowlabel = ip6_flowinfo(iph),
+   .flowi6_uid = uid,
+   };
 
dst = ip6_route_output(net, NULL, &fl6);
if (!dst->error)
-- 
2.19.0.605.g01d371f741-goog



[PATCH v2 8/9] net: rtm_to_fib6_config() - use new style struct initializer instead of memset

2018-09-29 Thread Maciej Żenczykowski
From: Maciej Żenczykowski 

(allows for better compiler optimization)

Signed-off-by: Maciej Żenczykowski 
---
 net/ipv6/route.c | 23 ---
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index c312ad4046d1..be5f7a15bc38 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -4143,14 +4143,19 @@ static int rtm_to_fib6_config(struct sk_buff *skb, 
struct nlmsghdr *nlh,
 
err = -EINVAL;
rtm = nlmsg_data(nlh);
-   memset(cfg, 0, sizeof(*cfg));
 
-   cfg->fc_table = rtm->rtm_table;
-   cfg->fc_dst_len = rtm->rtm_dst_len;
-   cfg->fc_src_len = rtm->rtm_src_len;
-   cfg->fc_flags = RTF_UP;
-   cfg->fc_protocol = rtm->rtm_protocol;
-   cfg->fc_type = rtm->rtm_type;
+   *cfg = (struct fib6_config){
+   .fc_table = rtm->rtm_table,
+   .fc_dst_len = rtm->rtm_dst_len,
+   .fc_src_len = rtm->rtm_src_len,
+   .fc_flags = RTF_UP,
+   .fc_protocol = rtm->rtm_protocol,
+   .fc_type = rtm->rtm_type,
+
+   .fc_nlinfo.portid = NETLINK_CB(skb).portid,
+   .fc_nlinfo.nlh = nlh,
+   .fc_nlinfo.nl_net = sock_net(skb->sk),
+   };
 
if (rtm->rtm_type == RTN_UNREACHABLE ||
rtm->rtm_type == RTN_BLACKHOLE ||
@@ -4166,10 +4171,6 @@ static int rtm_to_fib6_config(struct sk_buff *skb, 
struct nlmsghdr *nlh,
 
cfg->fc_flags |= (rtm->rtm_flags & RTNH_F_ONLINK);
 
-   cfg->fc_nlinfo.portid = NETLINK_CB(skb).portid;
-   cfg->fc_nlinfo.nlh = nlh;
-   cfg->fc_nlinfo.nl_net = sock_net(skb->sk);
-
if (tb[RTA_GATEWAY]) {
cfg->fc_gateway = nla_get_in6_addr(tb[RTA_GATEWAY]);
cfg->fc_flags |= RTF_GATEWAY;
-- 
2.19.0.605.g01d371f741-goog



[PATCH v2 9/9] net: inet6_rtm_getroute() - use new style struct initializer instead of memset

2018-09-29 Thread Maciej Żenczykowski
From: Maciej Żenczykowski 

Signed-off-by: Maciej Żenczykowski 
---
 net/ipv6/route.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index be5f7a15bc38..6311a7fc5f63 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -4823,7 +4823,7 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, 
struct nlmsghdr *nlh,
struct rt6_info *rt;
struct sk_buff *skb;
struct rtmsg *rtm;
-   struct flowi6 fl6;
+   struct flowi6 fl6 = {};
bool fibmatch;
 
err = nlmsg_parse(nlh, sizeof(*rtm), tb, RTA_MAX, rtm_ipv6_policy,
@@ -4832,7 +4832,6 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, 
struct nlmsghdr *nlh,
goto errout;
 
err = -EINVAL;
-   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);
-- 
2.19.0.605.g01d371f741-goog



[PATCH v2 3/9] net: ip6_redirect() - use new style struct initializer instead of memset

2018-09-29 Thread Maciej Żenczykowski
From: Maciej Żenczykowski 

(allows for better compiler optimization)

Signed-off-by: Maciej Żenczykowski 
---
 net/ipv6/route.c | 19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index d28f83e01593..6f252fa914c2 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2508,16 +2508,15 @@ void ip6_redirect(struct sk_buff *skb, struct net *net, 
int oif, u32 mark,
 {
const struct ipv6hdr *iph = (struct ipv6hdr *) skb->data;
struct dst_entry *dst;
-   struct flowi6 fl6;
-
-   memset(&fl6, 0, sizeof(fl6));
-   fl6.flowi6_iif = LOOPBACK_IFINDEX;
-   fl6.flowi6_oif = oif;
-   fl6.flowi6_mark = mark;
-   fl6.daddr = iph->daddr;
-   fl6.saddr = iph->saddr;
-   fl6.flowlabel = ip6_flowinfo(iph);
-   fl6.flowi6_uid = uid;
+   struct flowi6 fl6 = {
+   .flowi6_iif = LOOPBACK_IFINDEX,
+   .flowi6_oif = oif,
+   .flowi6_mark = mark,
+   .daddr = iph->daddr,
+   .saddr = iph->saddr,
+   .flowlabel = ip6_flowinfo(iph),
+   .flowi6_uid = uid,
+   };
 
dst = ip6_route_redirect(net, &fl6, skb, &ipv6_hdr(skb)->saddr);
rt6_do_redirect(dst, NULL, skb);
-- 
2.19.0.605.g01d371f741-goog



[PATCH v2 2/9] net: inet_rtm_getroute() - use new style struct initializer instead of memset

2018-09-29 Thread Maciej Żenczykowski
From: Maciej Żenczykowski 

Signed-off-by: Maciej Żenczykowski 
---
 net/ipv4/route.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 02482b71498b..048919713f4e 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2780,7 +2780,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, 
struct nlmsghdr *nlh,
struct rtable *rt = NULL;
struct sk_buff *skb;
struct rtmsg *rtm;
-   struct flowi4 fl4;
+   struct flowi4 fl4 = {};
__be32 dst = 0;
__be32 src = 0;
kuid_t uid;
@@ -2820,7 +2820,6 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, 
struct nlmsghdr *nlh,
if (!skb)
return -ENOBUFS;
 
-   memset(&fl4, 0, sizeof(fl4));
fl4.daddr = dst;
fl4.saddr = src;
fl4.flowi4_tos = rtm->rtm_tos;
-- 
2.19.0.605.g01d371f741-goog



[PATCH v2 1/9] net: ip_rt_get_source() - use new style struct initializer instead of memset

2018-09-29 Thread Maciej Żenczykowski
From: Maciej Żenczykowski 

(allows for better compiler optimization)

Signed-off-by: Maciej Żenczykowski 
---
 net/ipv4/route.c | 21 +
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index dce2ed66ebe1..02482b71498b 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1217,18 +1217,15 @@ void ip_rt_get_source(u8 *addr, struct sk_buff *skb, 
struct rtable *rt)
src = ip_hdr(skb)->saddr;
else {
struct fib_result res;
-   struct flowi4 fl4;
-   struct iphdr *iph;
-
-   iph = ip_hdr(skb);
-
-   memset(&fl4, 0, sizeof(fl4));
-   fl4.daddr = iph->daddr;
-   fl4.saddr = iph->saddr;
-   fl4.flowi4_tos = RT_TOS(iph->tos);
-   fl4.flowi4_oif = rt->dst.dev->ifindex;
-   fl4.flowi4_iif = skb->dev->ifindex;
-   fl4.flowi4_mark = skb->mark;
+   struct iphdr *iph = ip_hdr(skb);
+   struct flowi4 fl4 = {
+   .daddr = iph->daddr,
+   .saddr = iph->saddr,
+   .flowi4_tos = RT_TOS(iph->tos),
+   .flowi4_oif = rt->dst.dev->ifindex,
+   .flowi4_iif = skb->dev->ifindex,
+   .flowi4_mark = skb->mark,
+   };
 
rcu_read_lock();
if (fib_lookup(dev_net(rt->dst.dev), &fl4, &res, 0) == 0)
-- 
2.19.0.605.g01d371f741-goog



[PATCH v2 4/9] net: ip6_redirect_no_header() - use new style struct initializer instead of memset

2018-09-29 Thread Maciej Żenczykowski
From: Maciej Żenczykowski 

(allows for better compiler optimization)

Signed-off-by: Maciej Żenczykowski 
---
 net/ipv6/route.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 6f252fa914c2..dff80697c033 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2530,15 +2530,14 @@ void ip6_redirect_no_header(struct sk_buff *skb, struct 
net *net, int oif,
const struct ipv6hdr *iph = ipv6_hdr(skb);
const struct rd_msg *msg = (struct rd_msg *)icmp6_hdr(skb);
struct dst_entry *dst;
-   struct flowi6 fl6;
-
-   memset(&fl6, 0, sizeof(fl6));
-   fl6.flowi6_iif = LOOPBACK_IFINDEX;
-   fl6.flowi6_oif = oif;
-   fl6.flowi6_mark = mark;
-   fl6.daddr = msg->dest;
-   fl6.saddr = iph->daddr;
-   fl6.flowi6_uid = sock_net_uid(net, NULL);
+   struct flowi6 fl6 = {
+   .flowi6_iif = LOOPBACK_IFINDEX,
+   .flowi6_oif = oif,
+   .flowi6_mark = mark,
+   .daddr = msg->dest,
+   .saddr = iph->daddr,
+   .flowi6_uid = sock_net_uid(net, NULL),
+   };
 
dst = ip6_route_redirect(net, &fl6, skb, &iph->saddr);
rt6_do_redirect(dst, NULL, skb);
-- 
2.19.0.605.g01d371f741-goog



[PATCH][net-next] ipv6: drop container_of when convert dst to rt6_info

2018-09-29 Thread Li RongQing
we can save container_of computation and return dst directly,
since dst is always first member of struct rt6_info

Add a BUILD_BUG_ON() to catch any change that could break this
assertion.

Signed-off-by: Li RongQing 
---
 include/net/ip6_route.h | 4 +++-
 net/ipv6/route.c| 6 +++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index 7b9c82de11cc..1f09298634cb 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -194,8 +194,10 @@ static inline const struct rt6_info *skb_rt6_info(const 
struct sk_buff *skb)
const struct dst_entry *dst = skb_dst(skb);
const struct rt6_info *rt6 = NULL;
 
+   BUILD_BUG_ON(offsetof(struct rt6_info, dst) != 0);
+
if (dst)
-   rt6 = container_of(dst, struct rt6_info, dst);
+   rt6 = (struct rt6_info *)dst;
 
return rt6;
 }
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index d28f83e01593..3fb8034fc2d0 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -217,7 +217,7 @@ static struct neighbour *ip6_dst_neigh_lookup(const struct 
dst_entry *dst,
  struct sk_buff *skb,
  const void *daddr)
 {
-   const struct rt6_info *rt = container_of(dst, struct rt6_info, dst);
+   const struct rt6_info *rt = (struct rt6_info *)dst;
 
return ip6_neigh_lookup(&rt->rt6i_gateway, dst->dev, skb, daddr);
 }
@@ -2187,7 +2187,7 @@ static struct dst_entry *ip6_dst_check(struct dst_entry 
*dst, u32 cookie)
struct fib6_info *from;
struct rt6_info *rt;
 
-   rt = container_of(dst, struct rt6_info, dst);
+   rt = (struct rt6_info *)dst;
 
rcu_read_lock();
 
@@ -4911,7 +4911,7 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, 
struct nlmsghdr *nlh,
}
 
 
-   rt = container_of(dst, struct rt6_info, dst);
+   rt = (struct rt6_info *)dst;
if (rt->dst.error) {
err = rt->dst.error;
ip6_rt_put(rt);
-- 
2.16.2



[PATCH][net-next] net: drop container_of in dst_cache_get_ip4

2018-09-29 Thread Li RongQing
we can save container_of computation and return dst directly,
since dst is always first member of struct rtable, and any
breaking will be caught by BUILD_BUG_ON in route.h

include/net/route.h:BUILD_BUG_ON(offsetof(struct rtable, dst) != 0);

Signed-off-by: Li RongQing 
---
 net/core/dst_cache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/dst_cache.c b/net/core/dst_cache.c
index 64cef977484a..0753838480fd 100644
--- a/net/core/dst_cache.c
+++ b/net/core/dst_cache.c
@@ -87,7 +87,7 @@ struct rtable *dst_cache_get_ip4(struct dst_cache *dst_cache, 
__be32 *saddr)
return NULL;
 
*saddr = idst->in_saddr.s_addr;
-   return container_of(dst, struct rtable, dst);
+   return (struct rtable *)dst;
 }
 EXPORT_SYMBOL_GPL(dst_cache_get_ip4);
 
-- 
2.16.2



[PATCH iproute2 net-next] ipneigh: update man page and help for router

2018-09-29 Thread Roopa Prabhu
From: Roopa Prabhu 

While at it also add missing text for proxy in the man page.

Signed-off-by: Roopa Prabhu 
---
 ip/ipneigh.c|  1 +
 man/man8/ip-neighbour.8 | 11 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/ip/ipneigh.c b/ip/ipneigh.c
index 5747152..165546e 100644
--- a/ip/ipneigh.c
+++ b/ip/ipneigh.c
@@ -48,6 +48,7 @@ static void usage(void)
 {
fprintf(stderr, "Usage: ip neigh { add | del | change | replace }\n"
"{ ADDR [ lladdr LLADDR ] [ nud STATE ] 
| proxy ADDR } [ dev DEV ]\n");
+   fprintf(stderr, " [ router ]\n\n");
fprintf(stderr, "   ip neigh { show | flush } [ proxy ] [ to PREFIX 
] [ dev DEV ] [ nud STATE ]\n");
fprintf(stderr, " [ vrf NAME ]\n\n");
fprintf(stderr, "STATE := { permanent | noarp | stale | reachable | 
none |\n"
diff --git a/man/man8/ip-neighbour.8 b/man/man8/ip-neighbour.8
index bbfe8e7..db286d1 100644
--- a/man/man8/ip-neighbour.8
+++ b/man/man8/ip-neighbour.8
@@ -23,7 +23,8 @@ ip-neighbour \- neighbour/arp tables management.
 .B proxy
 .IR ADDR " } [ "
 .B  dev
-.IR DEV " ]"
+.IR DEV " ] [ "
+.BR router " ] "
 
 .ti -8
 .BR "ip neigh" " { " show " | " flush " } [ " proxy " ] [ " to
@@ -76,6 +77,14 @@ the protocol address of the neighbour. It is either an IPv4 
or IPv6 address.
 the interface to which this neighbour is attached.
 
 .TP
+.BI proxy
+indicates whether we are proxying for this neigbour entry
+
+.TP
+.BI router
+indicates whether neigbour is a router
+
+.TP
 .BI lladdr " LLADDRESS"
 the link layer address of the neighbour.
 .I LLADDRESS
-- 
2.1.4



[PATCH net-next] tls: Add support for inplace records encryption

2018-09-29 Thread Vakul Garg
Presently, for non-zero copy case, separate pages are allocated for
storing plaintext and encrypted text of records. These pages are stored
in sg_plaintext_data and sg_encrypted_data scatterlists inside record
structure. Further, sg_plaintext_data & sg_encrypted_data are passed
to cryptoapis for record encryption. Allocating separate pages for
plaintext and encrypted text is inefficient from both required memory
and performance point of view.

This patch adds support of inplace encryption of records. For non-zero
copy case, we reuse the pages from sg_encrypted_data scatterlist to
copy the application's plaintext data. For the movement of pages from
sg_encrypted_data to sg_plaintext_data scatterlists, we introduce a new
function move_to_plaintext_sg(). This function add pages into
sg_plaintext_data from sg_encrypted_data scatterlists.

tls_do_encryption() is modified to pass the same scatterlist as both
source and destination into aead_request_set_crypt() if inplace crypto
has been enabled. A new ariable 'inplace_crypto' has been introduced in
record structure to signify whether the same scatterlist can be used.
By default, the inplace_crypto is enabled in get_rec(). If zero-copy is
used (i.e. plaintext data is not copied), inplace_crypto is set to '0'.

Signed-off-by: Vakul Garg 
---
 include/net/tls.h |  1 +
 net/tls/tls_sw.c  | 91 ---
 2 files changed, 74 insertions(+), 18 deletions(-)

diff --git a/include/net/tls.h b/include/net/tls.h
index 262420cdad10..5e853835597e 100644
--- a/include/net/tls.h
+++ b/include/net/tls.h
@@ -101,6 +101,7 @@ struct tls_rec {
struct list_head list;
int tx_ready;
int tx_flags;
+   int inplace_crypto;
 
/* AAD | sg_plaintext_data | sg_tag */
struct scatterlist sg_plaintext_data[MAX_SKB_FRAGS + 1];
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index 1d4c354d5516..aa9fdce272b6 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -281,24 +281,72 @@ static int alloc_encrypted_sg(struct sock *sk, int len)
return rc;
 }
 
-static int alloc_plaintext_sg(struct sock *sk, int len)
+static int move_to_plaintext_sg(struct sock *sk, int required_size)
 {
struct tls_context *tls_ctx = tls_get_ctx(sk);
struct tls_sw_context_tx *ctx = tls_sw_ctx_tx(tls_ctx);
struct tls_rec *rec = ctx->open_rec;
-   int rc = 0;
+   struct scatterlist *plain_sg = &rec->sg_plaintext_data[1];
+   struct scatterlist *enc_sg = &rec->sg_encrypted_data[1];
+   int enc_sg_idx = 0;
+   int skip, len;
 
-   rc = sk_alloc_sg(sk, len,
-&rec->sg_plaintext_data[1], 0,
-&rec->sg_plaintext_num_elem,
-&rec->sg_plaintext_size,
-tls_ctx->pending_open_record_frags);
+   if (rec->sg_plaintext_num_elem == MAX_SKB_FRAGS)
+   return -ENOSPC;
 
-   if (rc == -ENOSPC)
-   rec->sg_plaintext_num_elem =
-   ARRAY_SIZE(rec->sg_plaintext_data) - 1;
+   /* We add page references worth len bytes from enc_sg at the
+* end of plain_sg. It is guaranteed that sg_encrypted_data
+* has enough required room (ensured by caller).
+*/
+   len = required_size - rec->sg_plaintext_size;
 
-   return rc;
+   /* Skip initial bytes in sg_encrypted_data to be able
+* to use same offset of both plain and encrypted data.
+*/
+   skip = tls_ctx->tx.prepend_size + rec->sg_plaintext_size;
+
+   while (enc_sg_idx < rec->sg_encrypted_num_elem) {
+   if (enc_sg[enc_sg_idx].length > skip)
+   break;
+
+   skip -= enc_sg[enc_sg_idx].length;
+   enc_sg_idx++;
+   }
+
+   /* unmark the end of plain_sg*/
+   sg_unmark_end(plain_sg + rec->sg_plaintext_num_elem - 1);
+
+   while (len) {
+   struct page *page = sg_page(&enc_sg[enc_sg_idx]);
+   int bytes = enc_sg[enc_sg_idx].length - skip;
+   int offset = enc_sg[enc_sg_idx].offset + skip;
+
+   if (bytes > len)
+   bytes = len;
+   else
+   enc_sg_idx++;
+
+   /* Skipping is required only one time */
+   skip = 0;
+
+   /* Increment page reference */
+   get_page(page);
+
+   sg_set_page(&plain_sg[rec->sg_plaintext_num_elem], page,
+   bytes, offset);
+
+   sk_mem_charge(sk, bytes);
+
+   len -= bytes;
+   rec->sg_plaintext_size += bytes;
+
+   rec->sg_plaintext_num_elem++;
+
+   if (rec->sg_plaintext_num_elem == MAX_SKB_FRAGS)
+   return -ENOSPC;
+   }
+
+   return 0;
 }
 
 static void free_sg(struct sock *sk, struct scatterlist *sg,
@@ -459,16 +507,21 @@ static int tls_do_encryption(struct sock *sk,
 

Re: [PATCH] Documentation: Add HOWTO Korean translation into BPF and XDP Reference Guide.

2018-09-29 Thread Chang-an Song
Hello Daniel, Jon
Thank you very much for review.

>That is a bit of a problem, since Apache v2 is not compatible with GPLv2.
>If the license of the document cannot be changed, I don't think we can
>accept it into the kernel tree.

Thank you for sharing information, Jon.  I will check the rst file format
and the license of the document when I submit document at next time.
If I miss something, Please let me know and I will check the checklist, first.

>Alternative option could also be to integrate it into Cilium's doc given the
>original document is present there as well, so it could link to the Korean
>version from there.

Thank you for sharing about other ways, Daniel.
I will check the information you have provided, and then I am investigating
how to put the Korean version page, and I will proceed as soon as it
is completed.

BR/Leo
2018년 9월 27일 (목) 오전 6:19, Daniel Borkmann 님이 작성:
>
> On 09/26/2018 09:44 PM, Jonathan Corbet wrote:
> > On Wed, 26 Sep 2018 18:11:42 +0900
> > Chang-an Song  wrote:
> >
> >>>  - The original document has a copyright assertion but no associated
> >>>license.  Do we know what the license is?  I assume it's something
> >>>that is free and GPL-compatible, but that would be good to know for
> >>>sure.
> >>
> >> 3. I asked to main author Daniel that apache 2.0 license for this document.
> >
> > That is a bit of a problem, since Apache v2 is not compatible with GPLv2.
> > If the license of the document cannot be changed, I don't think we can
> > accept it into the kernel tree.
>
> Alternative option could also be to integrate it into Cilium's doc given the
> original document is present there as well, so it could link to the Korean
> version from there.


Re: [PATCH v3 net-next 4/9] bnxt_en: Use ignore_ari devlink parameter

2018-09-29 Thread Or Gerlitz
On Fri, Sep 28, 2018 at 9:30 AM Vasundhara Volam
 wrote:
> This patch adds support for ignore_ari generic permanent mode
> devlink parameter. This parameter is disabled by default. It can be
> enabled using devlink param commands.
>
> ignore_ari - If enabled, device ignores ARI(Alternate Routing ID)
> capability, even when platforms has the support and creates same number
> of partitions when platform does not support ARI capability.

why you want to ignore that?


>
> Cc: Michael Chan 
> Signed-off-by: Vasundhara Volam 
> ---
>  drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c | 6 ++
>  drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h | 2 ++
>  2 files changed, 8 insertions(+)
>
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c 
> b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
> index 790c684..5173881 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
> @@ -24,6 +24,8 @@
>  static const struct bnxt_dl_nvm_param nvm_params[] = {
> {DEVLINK_PARAM_GENERIC_ID_ENABLE_SRIOV, NVM_OFF_ENABLE_SRIOV,
>  BNXT_NVM_SHARED_CFG, 1},
> +   {DEVLINK_PARAM_GENERIC_ID_IGNORE_ARI, NVM_OFF_IGNORE_ARI,
> +BNXT_NVM_SHARED_CFG, 1},
>  };
>
>  static int bnxt_hwrm_nvm_req(struct bnxt *bp, u32 param_id, void *msg,
> @@ -108,6 +110,10 @@ static int bnxt_dl_nvm_param_set(struct devlink *dl, u32 
> id,
>   BIT(DEVLINK_PARAM_CMODE_PERMANENT),
>   bnxt_dl_nvm_param_get, bnxt_dl_nvm_param_set,
>   NULL),
> +   DEVLINK_PARAM_GENERIC(IGNORE_ARI,
> + BIT(DEVLINK_PARAM_CMODE_PERMANENT),
> + bnxt_dl_nvm_param_get, bnxt_dl_nvm_param_set,
> + NULL),
>  };
>
>  int bnxt_dl_register(struct bnxt *bp)
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h 
> b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h
> index 2f68dc0..da146492 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h
> @@ -33,6 +33,8 @@ static inline void bnxt_link_bp_to_dl(struct bnxt *bp, 
> struct devlink *dl)
> }
>  }
>
> +#define NVM_OFF_IGNORE_ARI 164

> +#define NVM_OFF_HW_TC_OFFLOAD  170

what is this (on/off for TC offloads?) and how it's related to ARI?

>  #define NVM_OFF_ENABLE_SRIOV   401


[PATCH v2 net-next 4/8] net: phy: Add helper to convert MII ADV register to a linkmode

2018-09-29 Thread Andrew Lunn
The phy_mii_ioctl can be used to write a value into the MII_ADVERTISE
register in the PHY. Since this changes the state of the PHY, we need
to make the same change to phydev->advertising. Add a helper which can
convert the register value to a linkmode.

Signed-off-by: Andrew Lunn 
Reviewed-by: Florian Fainelli 
Reviewed-by: Maxime Chevallier 
---
 include/linux/mii.h | 31 +++
 1 file changed, 31 insertions(+)

diff --git a/include/linux/mii.h b/include/linux/mii.h
index 567047ef0309..8c7da9473ad9 100644
--- a/include/linux/mii.h
+++ b/include/linux/mii.h
@@ -303,6 +303,37 @@ static inline u32 mii_lpa_to_ethtool_lpa_x(u32 lpa)
return result | mii_adv_to_ethtool_adv_x(lpa);
 }
 
+/**
+ * mii_adv_to_linkmode_adv_t
+ * @advertising:pointer to destination link mode.
+ * @adv: value of the MII_ADVERTISE register
+ *
+ * A small helper function that translates MII_ADVERTISE bits
+ * to linkmode advertisement settings.
+ */
+static inline void mii_adv_to_linkmode_adv_t(unsigned long *advertising,
+u32 adv)
+{
+   linkmode_zero(advertising);
+
+   if (adv & ADVERTISE_10HALF)
+   linkmode_set_bit(ETHTOOL_LINK_MODE_10baseT_Half_BIT,
+advertising);
+   if (adv & ADVERTISE_10FULL)
+   linkmode_set_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT,
+advertising);
+   if (adv & ADVERTISE_100HALF)
+   linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT,
+advertising);
+   if (adv & ADVERTISE_100FULL)
+   linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT,
+advertising);
+   if (adv & ADVERTISE_PAUSE_CAP)
+   linkmode_set_bit(ETHTOOL_LINK_MODE_Pause_BIT, advertising);
+   if (adv & ADVERTISE_PAUSE_ASYM)
+   linkmode_set_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, advertising);
+}
+
 /**
  * mii_advertise_flowctrl - get flow control advertisement flags
  * @cap: Flow control capabilities (FLOW_CTRL_RX, FLOW_CTRL_TX or both)
-- 
2.19.0.rc1



[PATCH v2 net-next 5/8] net: phy: Add helper for advertise to lcl value

2018-09-29 Thread Andrew Lunn
Add a helper to convert the local advertising to an LCL capabilities,
which is then used to resolve pause flow control settings.

Signed-off-by: Andrew Lunn 
Reviewed-by: Florian Fainelli 
Reviewed-by: Maxime Chevallier 
---
 drivers/net/dsa/mt7530.c  |  6 +-
 drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c   |  5 +
 drivers/net/ethernet/freescale/fman/mac.c |  6 +-
 drivers/net/ethernet/freescale/gianfar.c  |  7 +--
 .../hisilicon/hns3/hns3pf/hclge_main.c|  6 +-
 drivers/net/ethernet/mediatek/mtk_eth_soc.c   |  6 +-
 drivers/net/ethernet/socionext/sni_ave.c  |  5 +
 include/linux/mii.h   | 19 +++
 8 files changed, 26 insertions(+), 34 deletions(-)

diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index 62e486652e62..a5de9bffe5be 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -658,11 +658,7 @@ static void mt7530_adjust_link(struct dsa_switch *ds, int 
port,
if (phydev->asym_pause)
rmt_adv |= LPA_PAUSE_ASYM;
 
-   if (phydev->advertising & ADVERTISED_Pause)
-   lcl_adv |= ADVERTISE_PAUSE_CAP;
-   if (phydev->advertising & ADVERTISED_Asym_Pause)
-   lcl_adv |= ADVERTISE_PAUSE_ASYM;
-
+   lcl_adv = ethtool_adv_to_lcl_adv_t(phydev->advertising);
flowctrl = mii_resolve_flowctrl_fdx(lcl_adv, rmt_adv);
 
if (flowctrl & FLOW_CTRL_TX)
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c 
b/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
index 289129011b9f..a7e03e3ecc93 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
@@ -1495,10 +1495,7 @@ static void xgbe_phy_phydev_flowctrl(struct 
xgbe_prv_data *pdata)
if (!phy_data->phydev)
return;
 
-   if (phy_data->phydev->advertising & ADVERTISED_Pause)
-   lcl_adv |= ADVERTISE_PAUSE_CAP;
-   if (phy_data->phydev->advertising & ADVERTISED_Asym_Pause)
-   lcl_adv |= ADVERTISE_PAUSE_ASYM;
+   lcl_adv = ethtool_adv_to_lcl_adv_t(phy_data->phydev->advertising);
 
if (phy_data->phydev->pause) {
XGBE_SET_LP_ADV(lks, Pause);
diff --git a/drivers/net/ethernet/freescale/fman/mac.c 
b/drivers/net/ethernet/freescale/fman/mac.c
index a847b9c3b31a..d79e4e009d63 100644
--- a/drivers/net/ethernet/freescale/fman/mac.c
+++ b/drivers/net/ethernet/freescale/fman/mac.c
@@ -393,11 +393,7 @@ void fman_get_pause_cfg(struct mac_device *mac_dev, bool 
*rx_pause,
 */
 
/* get local capabilities */
-   lcl_adv = 0;
-   if (phy_dev->advertising & ADVERTISED_Pause)
-   lcl_adv |= ADVERTISE_PAUSE_CAP;
-   if (phy_dev->advertising & ADVERTISED_Asym_Pause)
-   lcl_adv |= ADVERTISE_PAUSE_ASYM;
+   lcl_adv = ethtool_adv_to_lcl_adv_t(phy_dev->advertising);
 
/* get link partner capabilities */
rmt_adv = 0;
diff --git a/drivers/net/ethernet/freescale/gianfar.c 
b/drivers/net/ethernet/freescale/gianfar.c
index 0bd21a493016..3c8da1a18ba0 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -3656,12 +3656,7 @@ static u32 gfar_get_flowctrl_cfg(struct gfar_private 
*priv)
if (phydev->asym_pause)
rmt_adv |= LPA_PAUSE_ASYM;
 
-   lcl_adv = 0;
-   if (phydev->advertising & ADVERTISED_Pause)
-   lcl_adv |= ADVERTISE_PAUSE_CAP;
-   if (phydev->advertising & ADVERTISED_Asym_Pause)
-   lcl_adv |= ADVERTISE_PAUSE_ASYM;
-
+   lcl_adv = ethtool_adv_to_lcl_adv_t(phydev->advertising);
flowctrl = mii_resolve_flowctrl_fdx(lcl_adv, rmt_adv);
if (flowctrl & FLOW_CTRL_TX)
val |= MACCFG1_TX_FLOW;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 7c8b686b1ce1..c17ceeefa453 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -5006,11 +5006,7 @@ int hclge_cfg_flowctrl(struct hclge_dev *hdev)
if (!phydev->link || !phydev->autoneg)
return 0;
 
-   if (phydev->advertising & ADVERTISED_Pause)
-   local_advertising = ADVERTISE_PAUSE_CAP;
-
-   if (phydev->advertising & ADVERTISED_Asym_Pause)
-   local_advertising |= ADVERTISE_PAUSE_ASYM;
+   local_advertising = ethtool_adv_to_lcl_adv_t(phydev->advertising);
 
if (phydev->pause)
remote_advertising = LPA_PAUSE_CAP;
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c 
b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index cc1e9a96a43b..7dbfdac4067a

[PATCH v2 net-next 6/8] net: phy: Add limkmode equivalents to some of the MII ethtool helpers

2018-09-29 Thread Andrew Lunn
Add helpers which take a linkmode rather than a u32 ethtool for
advertising settings.

Signed-off-by: Andrew Lunn 
Reviewed-by: Florian Fainelli 
Reviewed-by: Maxime Chevallier 
---
 include/linux/mii.h | 50 +
 1 file changed, 50 insertions(+)

diff --git a/include/linux/mii.h b/include/linux/mii.h
index 9ed49c8261d0..2da85b02e1c0 100644
--- a/include/linux/mii.h
+++ b/include/linux/mii.h
@@ -132,6 +132,34 @@ static inline u32 ethtool_adv_to_mii_adv_t(u32 ethadv)
return result;
 }
 
+/**
+ * linkmode_adv_to_mii_adv_t
+ * @advertising: the linkmode advertisement settings
+ *
+ * A small helper function that translates linkmode advertisement
+ * settings to phy autonegotiation advertisements for the
+ * MII_ADVERTISE register.
+ */
+static inline u32 linkmode_adv_to_mii_adv_t(unsigned long *advertising)
+{
+   u32 result = 0;
+
+   if (linkmode_test_bit(ETHTOOL_LINK_MODE_10baseT_Half_BIT, advertising))
+   result |= ADVERTISE_10HALF;
+   if (linkmode_test_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT, advertising))
+   result |= ADVERTISE_10FULL;
+   if (linkmode_test_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT, advertising))
+   result |= ADVERTISE_100HALF;
+   if (linkmode_test_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, advertising))
+   result |= ADVERTISE_100FULL;
+   if (linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT, advertising))
+   result |= ADVERTISE_PAUSE_CAP;
+   if (linkmode_test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, advertising))
+   result |= ADVERTISE_PAUSE_ASYM;
+
+   return result;
+}
+
 /**
  * mii_adv_to_ethtool_adv_t
  * @adv: value of the MII_ADVERTISE register
@@ -179,6 +207,28 @@ static inline u32 ethtool_adv_to_mii_ctrl1000_t(u32 ethadv)
return result;
 }
 
+/**
+ * linkmode_adv_to_mii_ctrl1000_t
+ * advertising: the linkmode advertisement settings
+ *
+ * A small helper function that translates linkmode advertisement
+ * settings to phy autonegotiation advertisements for the
+ * MII_CTRL1000 register when in 1000T mode.
+ */
+static inline u32 linkmode_adv_to_mii_ctrl1000_t(unsigned long *advertising)
+{
+   u32 result = 0;
+
+   if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT,
+ advertising))
+   result |= ADVERTISE_1000HALF;
+   if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
+ advertising))
+   result |= ADVERTISE_1000FULL;
+
+   return result;
+}
+
 /**
  * mii_ctrl1000_to_ethtool_adv_t
  * @adv: value of the MII_CTRL1000 register
-- 
2.19.0.rc1



[PATCH v2 net-next 3/8] net: phy: Add phydev_info()

2018-09-29 Thread Andrew Lunn
Add phydev_info() and make use of it within the phy drivers and core
code.

Signed-off-by: Andrew Lunn 
---
 drivers/net/phy/dp83640.c| 11 ++-
 drivers/net/phy/phy_device.c |  4 ++--
 include/linux/phy.h  |  3 +++
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
index 74cf356d8171..edd4d44a386d 100644
--- a/drivers/net/phy/dp83640.c
+++ b/drivers/net/phy/dp83640.c
@@ -687,9 +687,9 @@ static void recalibrate(struct dp83640_clock *clock)
 * read out and correct offsets
 */
val = ext_read(master, PAGE4, PTP_STS);
-   pr_info("master PTP_STS  0x%04hx\n", val);
+   phydev_info(master, "master PTP_STS  0x%04hx\n", val);
val = ext_read(master, PAGE4, PTP_ESTS);
-   pr_info("master PTP_ESTS 0x%04hx\n", val);
+   phydev_info(master, "master PTP_ESTS 0x%04hx\n", val);
event_ts.ns_lo  = ext_read(master, PAGE4, PTP_EDATA);
event_ts.ns_hi  = ext_read(master, PAGE4, PTP_EDATA);
event_ts.sec_lo = ext_read(master, PAGE4, PTP_EDATA);
@@ -699,15 +699,16 @@ static void recalibrate(struct dp83640_clock *clock)
list_for_each(this, &clock->phylist) {
tmp = list_entry(this, struct dp83640_private, list);
val = ext_read(tmp->phydev, PAGE4, PTP_STS);
-   pr_info("slave  PTP_STS  0x%04hx\n", val);
+   phydev_info(tmp->phydev, "slave  PTP_STS  0x%04hx\n", val);
val = ext_read(tmp->phydev, PAGE4, PTP_ESTS);
-   pr_info("slave  PTP_ESTS 0x%04hx\n", val);
+   phydev_info(tmp->phydev, "slave  PTP_ESTS 0x%04hx\n", val);
event_ts.ns_lo  = ext_read(tmp->phydev, PAGE4, PTP_EDATA);
event_ts.ns_hi  = ext_read(tmp->phydev, PAGE4, PTP_EDATA);
event_ts.sec_lo = ext_read(tmp->phydev, PAGE4, PTP_EDATA);
event_ts.sec_hi = ext_read(tmp->phydev, PAGE4, PTP_EDATA);
diff = now - (s64) phy2txts(&event_ts);
-   pr_info("slave offset %lld nanoseconds\n", diff);
+   phydev_info(tmp->phydev, "slave offset %lld nanoseconds\n",
+   diff);
diff += ADJTIME_FIX;
ts = ns_to_timespec64(diff);
tdr_write(0, tmp->phydev, &ts, PTP_STEP_CLK);
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index ee676d75fe02..35102e17bbeb 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -920,13 +920,13 @@ void phy_attached_print(struct phy_device *phydev, const 
char *fmt, ...)
 
 
if (!fmt) {
-   dev_info(&phydev->mdio.dev, ATTACHED_FMT "\n",
+   phydev_info(phydev, ATTACHED_FMT "\n",
 drv_name, phydev_name(phydev),
 irq_str);
} else {
va_list ap;
 
-   dev_info(&phydev->mdio.dev, ATTACHED_FMT,
+   phydev_info(phydev, ATTACHED_FMT,
 drv_name, phydev_name(phydev),
 irq_str);
 
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 0ab9f89773fd..0f6e7bf5e9c5 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -968,6 +968,9 @@ static inline void phy_device_reset(struct phy_device 
*phydev, int value)
 #define phydev_err(_phydev, format, args...)   \
dev_err(&_phydev->mdio.dev, format, ##args)
 
+#define phydev_info(_phydev, format, args...)  \
+   dev_info(&_phydev->mdio.dev, format, ##args)
+
 #define phydev_warn(_phydev, format, args...)  \
dev_warn(&_phydev->mdio.dev, format, ##args)
 
-- 
2.19.0.rc1



[PATCH v2 net-next 8/8] net: phy: Replace phy driver features u32 with link_mode bitmap

2018-09-29 Thread Andrew Lunn
This is one step in allowing phylib to make use of link_mode bitmaps,
instead of u32 for supported and advertised features. Convert the phy
drivers to use bitmaps to indicates the features they support.

Build bitmap equivalents of the u32 values at runtime, and have the
drivers point to the appropriate bitmap. These bitmaps are shared, and
we don't want a driver to modify them. So mark them __ro_after_init.

Within phylib, the features bitmap is currently turned back into a
u32. This will be removed once the whole of phylib, and the drivers
are converted to use bitmaps.

Signed-off-by: Andrew Lunn 
---
 drivers/net/ethernet/marvell/pxa168_eth.c |   4 +-
 drivers/net/phy/aquantia.c|  12 +-
 drivers/net/phy/bcm63xx.c |   9 +-
 drivers/net/phy/marvell.c |   2 +-
 drivers/net/phy/marvell10g.c  |  11 +-
 drivers/net/phy/microchip_t1.c|   2 +-
 drivers/net/phy/phy_device.c  | 164 +-
 include/linux/linkmode.h  |   9 ++
 include/linux/phy.h   |  24 ++--
 9 files changed, 198 insertions(+), 39 deletions(-)

diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c 
b/drivers/net/ethernet/marvell/pxa168_eth.c
index ff2fea0f8b75..0bd4351b2a49 100644
--- a/drivers/net/ethernet/marvell/pxa168_eth.c
+++ b/drivers/net/ethernet/marvell/pxa168_eth.c
@@ -988,8 +988,8 @@ static int pxa168_init_phy(struct net_device *dev)
cmd.base.phy_address = pep->phy_addr;
cmd.base.speed = pep->phy_speed;
cmd.base.duplex = pep->phy_duplex;
-   ethtool_convert_legacy_u32_to_link_mode(cmd.link_modes.advertising,
-   PHY_BASIC_FEATURES);
+   bitmap_copy(cmd.link_modes.advertising, PHY_BASIC_FEATURES,
+   __ETHTOOL_LINK_MODE_MASK_NBITS);
cmd.base.autoneg = AUTONEG_ENABLE;
 
if (cmd.base.speed != 0)
diff --git a/drivers/net/phy/aquantia.c b/drivers/net/phy/aquantia.c
index 319edc9c8ec7..632472cab3bb 100644
--- a/drivers/net/phy/aquantia.c
+++ b/drivers/net/phy/aquantia.c
@@ -115,7 +115,7 @@ static struct phy_driver aquantia_driver[] = {
.phy_id = PHY_ID_AQ1202,
.phy_id_mask= 0xfff0,
.name   = "Aquantia AQ1202",
-   .features   = PHY_AQUANTIA_FEATURES,
+   .features   = PHY_10GBIT_FULL_FEATURES,
.flags  = PHY_HAS_INTERRUPT,
.aneg_done  = genphy_c45_aneg_done,
.config_aneg= aquantia_config_aneg,
@@ -127,7 +127,7 @@ static struct phy_driver aquantia_driver[] = {
.phy_id = PHY_ID_AQ2104,
.phy_id_mask= 0xfff0,
.name   = "Aquantia AQ2104",
-   .features   = PHY_AQUANTIA_FEATURES,
+   .features   = PHY_10GBIT_FULL_FEATURES,
.flags  = PHY_HAS_INTERRUPT,
.aneg_done  = genphy_c45_aneg_done,
.config_aneg= aquantia_config_aneg,
@@ -139,7 +139,7 @@ static struct phy_driver aquantia_driver[] = {
.phy_id = PHY_ID_AQR105,
.phy_id_mask= 0xfff0,
.name   = "Aquantia AQR105",
-   .features   = PHY_AQUANTIA_FEATURES,
+   .features   = PHY_10GBIT_FULL_FEATURES,
.flags  = PHY_HAS_INTERRUPT,
.aneg_done  = genphy_c45_aneg_done,
.config_aneg= aquantia_config_aneg,
@@ -151,7 +151,7 @@ static struct phy_driver aquantia_driver[] = {
.phy_id = PHY_ID_AQR106,
.phy_id_mask= 0xfff0,
.name   = "Aquantia AQR106",
-   .features   = PHY_AQUANTIA_FEATURES,
+   .features   = PHY_10GBIT_FULL_FEATURES,
.flags  = PHY_HAS_INTERRUPT,
.aneg_done  = genphy_c45_aneg_done,
.config_aneg= aquantia_config_aneg,
@@ -163,7 +163,7 @@ static struct phy_driver aquantia_driver[] = {
.phy_id = PHY_ID_AQR107,
.phy_id_mask= 0xfff0,
.name   = "Aquantia AQR107",
-   .features   = PHY_AQUANTIA_FEATURES,
+   .features   = PHY_10GBIT_FULL_FEATURES,
.flags  = PHY_HAS_INTERRUPT,
.aneg_done  = genphy_c45_aneg_done,
.config_aneg= aquantia_config_aneg,
@@ -175,7 +175,7 @@ static struct phy_driver aquantia_driver[] = {
.phy_id = PHY_ID_AQR405,
.phy_id_mask= 0xfff0,
.name   = "Aquantia AQR405",
-   .features   = PHY_AQUANTIA_FEATURES,
+   .features   = PHY_10GBIT_FULL_FEATURES,
.flags  = PHY_HAS_INTERRUPT,
.aneg_done  = genphy_c45_aneg_done,
.config_aneg= aquantia_config_aneg,
diff --git a/drivers/net/phy/bcm63xx.c b/drivers/net/phy/bcm63xx.c
index cf14613745c9..d95bffdec4c1 100644
--- a/drivers/net/phy/bcm63xx.c
+++ b/drivers/net/phy/bcm63xx.c
@@ -42,6 +42,9 @@ static int bcm63xx_config_init(struct phy_device *phydev)
 {
int reg, err;
 
+   /* ASYM_

[PATCH v2 net-next 7/8] net: ethernet: xgbe: expand PHY_GBIT_FEAUTRES

2018-09-29 Thread Andrew Lunn
The macro PHY_GBIT_FEAUTRES needs to change into a bitmap in order to
support link_modes. Remove its use from xgde by replacing it with its
definition.

Probably, the current behavior is wrong. It probably should be
ANDing not assigning.

Signed-off-by: Andrew Lunn 
---
v2
Remove unneeded ()
---
 drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c 
b/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
index a7e03e3ecc93..151bdb629e8a 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
@@ -878,8 +878,9 @@ static bool xgbe_phy_finisar_phy_quirks(struct 
xgbe_prv_data *pdata)
phy_write(phy_data->phydev, 0x04, 0x0d01);
phy_write(phy_data->phydev, 0x00, 0x9140);
 
-   phy_data->phydev->supported = PHY_GBIT_FEATURES;
-   phy_data->phydev->advertising = phy_data->phydev->supported;
+   phy_data->phydev->supported = PHY_10BT_FEATURES |
+ PHY_100BT_FEATURES |
+ PHY_1000BT_FEATURES;
phy_support_asym_pause(phy_data->phydev);
 
netif_dbg(pdata, drv, pdata->netdev,
@@ -950,8 +951,9 @@ static bool xgbe_phy_belfuse_phy_quirks(struct 
xgbe_prv_data *pdata)
reg = phy_read(phy_data->phydev, 0x00);
phy_write(phy_data->phydev, 0x00, reg & ~0x00800);
 
-   phy_data->phydev->supported = PHY_GBIT_FEATURES;
-   phy_data->phydev->advertising = phy_data->phydev->supported;
+   phy_data->phydev->supported = (PHY_10BT_FEATURES |
+  PHY_100BT_FEATURES |
+  PHY_1000BT_FEATURES);
phy_support_asym_pause(phy_data->phydev);
 
netif_dbg(pdata, drv, pdata->netdev,
-- 
2.19.0.rc1



[PATCH v2 net-next 2/8] net: phy: Add phydev_warn()

2018-09-29 Thread Andrew Lunn
Not all new style LINK_MODE bits can be converted into old style
SUPPORTED bits. We need to warn when such a conversion is attempted.
Add a helper for this.

Convert all pr_warn() calls to phydev_warn() where possible.

Signed-off-by: Andrew Lunn 
Reviewed-by: Maxime Chevallier 
---
v2:
Make use of the new call.
---
 drivers/net/phy/at803x.c |  2 +-
 drivers/net/phy/dp83640.c|  7 ---
 drivers/net/phy/marvell.c|  2 +-
 drivers/net/phy/marvell10g.c |  6 +++---
 drivers/net/phy/microchip.c  | 33 +
 include/linux/phy.h  |  3 +++
 6 files changed, 29 insertions(+), 24 deletions(-)

diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index 411cf1072bae..e74a047a846e 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -357,7 +357,7 @@ static int at803x_aneg_done(struct phy_device *phydev)
 
/* check if the SGMII link is OK. */
if (!(phy_read(phydev, AT803X_PSSR) & AT803X_PSSR_MR_AN_COMPLETE)) {
-   pr_warn("803x_aneg_done: SGMII link is not ok\n");
+   phydev_warn(phydev, "803x_aneg_done: SGMII link is not ok\n");
aneg_done = 0;
}
/* switch back to copper page */
diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
index 29aa8d772b0c..74cf356d8171 100644
--- a/drivers/net/phy/dp83640.c
+++ b/drivers/net/phy/dp83640.c
@@ -553,16 +553,17 @@ static void enable_status_frames(struct phy_device 
*phydev, bool on)
mutex_unlock(&clock->extreg_lock);
 
if (!phydev->attached_dev) {
-   pr_warn("expected to find an attached netdevice\n");
+   phydev_warn(phydev,
+   "expected to find an attached netdevice\n");
return;
}
 
if (on) {
if (dev_mc_add(phydev->attached_dev, status_frame_dst))
-   pr_warn("failed to add mc address\n");
+   phydev_warn(phydev, "failed to add mc address\n");
} else {
if (dev_mc_del(phydev->attached_dev, status_frame_dst))
-   pr_warn("failed to delete mc address\n");
+   phydev_warn(phydev, "failed to delete mc address\n");
}
 }
 
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index 24fc4a73c300..8872a430d74a 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -638,7 +638,7 @@ static void marvell_config_led(struct phy_device *phydev)
err = phy_write_paged(phydev, MII_MARVELL_LED_PAGE, MII_PHY_LED_CTRL,
  def_config);
if (err < 0)
-   pr_warn("Fail to config marvell phy LED.\n");
+   phydev_warn(phydev, "Fail to config marvell phy LED.\n");
 }
 
 static int marvell_config_init(struct phy_device *phydev)
diff --git a/drivers/net/phy/marvell10g.c b/drivers/net/phy/marvell10g.c
index f77a2d9e7f9d..f214834819dd 100644
--- a/drivers/net/phy/marvell10g.c
+++ b/drivers/net/phy/marvell10g.c
@@ -337,9 +337,9 @@ static int mv3310_config_init(struct phy_device *phydev)
}
 
if (!ethtool_convert_link_mode_to_legacy_u32(&mask, supported))
-   dev_warn(&phydev->mdio.dev,
-"PHY supports (%*pb) more modes than phylib supports, 
some modes not supported.\n",
-__ETHTOOL_LINK_MODE_MASK_NBITS, supported);
+   phydev_warn(phydev,
+   "PHY supports (%*pb) more modes than phylib 
supports, some modes not supported.\n",
+   __ETHTOOL_LINK_MODE_MASK_NBITS, supported);
 
phydev->supported &= mask;
phydev->advertising &= phydev->supported;
diff --git a/drivers/net/phy/microchip.c b/drivers/net/phy/microchip.c
index 2d67937866a3..04b12e34da58 100644
--- a/drivers/net/phy/microchip.c
+++ b/drivers/net/phy/microchip.c
@@ -88,7 +88,7 @@ static int lan88xx_TR_reg_set(struct phy_device *phydev, u16 
regaddr,
/* Save current page */
save_page = phy_save_page(phydev);
if (save_page < 0) {
-   pr_warn("Failed to get current page\n");
+   phydev_warn(phydev, "Failed to get current page\n");
goto err;
}
 
@@ -98,14 +98,14 @@ static int lan88xx_TR_reg_set(struct phy_device *phydev, 
u16 regaddr,
ret = __phy_write(phydev, LAN88XX_EXT_PAGE_TR_LOW_DATA,
  (data & 0x));
if (ret < 0) {
-   pr_warn("Failed to write TR low data\n");
+   phydev_warn(phydev, "Failed to write TR low data\n");
goto err;
}
 
ret = __phy_write(phydev, LAN88XX_EXT_PAGE_TR_HIGH_DATA,
  (data & 0x00FF) >> 16);
if (ret < 0) {
-   pr_warn("Failed to write TR high data\n");
+   phydev_warn(phydev, "Failed to write TR high data\n");
goto err;
}
 
@@ -115,14 +115,15 @@ static i

[PATCH v2 net-next 1/8] net: phy: Move linkmode helpers to somewhere public

2018-09-29 Thread Andrew Lunn
phylink has some useful helpers to working with linkmode bitmaps.
Move them to there own header so other code can use them.

Signed-off-by: Andrew Lunn 
Acked-by: Florian Fainelli 
Reviewed-by: Maxime Chevallier 
---
v2: It was suggested to make include/linux/ethernet-phy and move
some of the header files into it. I decided to leave this until
later.
---
 drivers/net/phy/phylink.c | 27 
 include/linux/linkmode.h  | 67 +++
 include/linux/mii.h   |  1 +
 include/linux/phy.h   |  1 +
 4 files changed, 69 insertions(+), 27 deletions(-)
 create mode 100644 include/linux/linkmode.h

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 1d01e0c625a5..b6993af5c9e4 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -68,33 +68,6 @@ struct phylink {
struct sfp_bus *sfp_bus;
 };
 
-static inline void linkmode_zero(unsigned long *dst)
-{
-   bitmap_zero(dst, __ETHTOOL_LINK_MODE_MASK_NBITS);
-}
-
-static inline void linkmode_copy(unsigned long *dst, const unsigned long *src)
-{
-   bitmap_copy(dst, src, __ETHTOOL_LINK_MODE_MASK_NBITS);
-}
-
-static inline void linkmode_and(unsigned long *dst, const unsigned long *a,
-   const unsigned long *b)
-{
-   bitmap_and(dst, a, b, __ETHTOOL_LINK_MODE_MASK_NBITS);
-}
-
-static inline void linkmode_or(unsigned long *dst, const unsigned long *a,
-   const unsigned long *b)
-{
-   bitmap_or(dst, a, b, __ETHTOOL_LINK_MODE_MASK_NBITS);
-}
-
-static inline bool linkmode_empty(const unsigned long *src)
-{
-   return bitmap_empty(src, __ETHTOOL_LINK_MODE_MASK_NBITS);
-}
-
 /**
  * phylink_set_port_modes() - set the port type modes in the ethtool mask
  * @mask: ethtool link mode mask
diff --git a/include/linux/linkmode.h b/include/linux/linkmode.h
new file mode 100644
index ..014fb86c7114
--- /dev/null
+++ b/include/linux/linkmode.h
@@ -0,0 +1,67 @@
+#ifndef __LINKMODE_H
+#define __LINKMODE_H
+
+#include 
+#include 
+#include 
+
+static inline void linkmode_zero(unsigned long *dst)
+{
+   bitmap_zero(dst, __ETHTOOL_LINK_MODE_MASK_NBITS);
+}
+
+static inline void linkmode_copy(unsigned long *dst, const unsigned long *src)
+{
+   bitmap_copy(dst, src, __ETHTOOL_LINK_MODE_MASK_NBITS);
+}
+
+static inline void linkmode_and(unsigned long *dst, const unsigned long *a,
+   const unsigned long *b)
+{
+   bitmap_and(dst, a, b, __ETHTOOL_LINK_MODE_MASK_NBITS);
+}
+
+static inline void linkmode_or(unsigned long *dst, const unsigned long *a,
+   const unsigned long *b)
+{
+   bitmap_or(dst, a, b, __ETHTOOL_LINK_MODE_MASK_NBITS);
+}
+
+static inline bool linkmode_empty(const unsigned long *src)
+{
+   return bitmap_empty(src, __ETHTOOL_LINK_MODE_MASK_NBITS);
+}
+
+static inline int linkmode_andnot(unsigned long *dst, const unsigned long 
*src1,
+ const unsigned long *src2)
+{
+   return bitmap_andnot(dst, src1, src2,  __ETHTOOL_LINK_MODE_MASK_NBITS);
+}
+
+static inline void linkmode_set_bit(int nr, volatile unsigned long *addr)
+{
+   __set_bit(nr, addr);
+}
+
+static inline void linkmode_clear_bit(int nr, volatile unsigned long *addr)
+{
+   __clear_bit(nr, addr);
+}
+
+static inline void linkmode_change_bit(int nr, volatile unsigned long *addr)
+{
+   __change_bit(nr, addr);
+}
+
+static inline int linkmode_test_bit(int nr, volatile unsigned long *addr)
+{
+   return test_bit(nr, addr);
+}
+
+static inline int linkmode_equal(const unsigned long *src1,
+const unsigned long *src2)
+{
+   return bitmap_equal(src1, src2, __ETHTOOL_LINK_MODE_MASK_NBITS);
+}
+
+#endif /* __LINKMODE_H */
diff --git a/include/linux/mii.h b/include/linux/mii.h
index 55000ee5c6ad..567047ef0309 100644
--- a/include/linux/mii.h
+++ b/include/linux/mii.h
@@ -10,6 +10,7 @@
 
 
 #include 
+#include 
 #include 
 
 struct ethtool_cmd;
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 192a1fa0c73b..d24cc46748e2 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
-- 
2.19.0.rc1



[PATCH v2 net-next 0/8] Continue towards using linkmode in phylib

2018-09-29 Thread Andrew Lunn
These patches contain some further cleanup and helpers, and the first
real patch towards using linkmode bitmaps in phylink.

The macro magic in the RFC version has been replaced with run time
initialisation.

Andrew Lunn (8):
  net: phy: Move linkmode helpers to somewhere public
  net: phy: Add phydev_warn()
  net: phy: Add phydev_info()
  net: phy: Add helper to convert MII ADV register to a linkmode
  net: phy: Add helper for advertise to lcl value
  net: phy: Add limkmode equivalents to some of the MII ethtool helpers
  net: ethernet: xgbe: expand PHY_GBIT_FEAUTRES
  net: phy: Replace phy driver features u32 with link_mode bitmap

 drivers/net/dsa/mt7530.c  |   6 +-
 drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c   |  15 +-
 drivers/net/ethernet/freescale/fman/mac.c |   6 +-
 drivers/net/ethernet/freescale/gianfar.c  |   7 +-
 .../hisilicon/hns3/hns3pf/hclge_main.c|   6 +-
 drivers/net/ethernet/marvell/pxa168_eth.c |   4 +-
 drivers/net/ethernet/mediatek/mtk_eth_soc.c   |   6 +-
 drivers/net/ethernet/socionext/sni_ave.c  |   5 +-
 drivers/net/phy/aquantia.c|  12 +-
 drivers/net/phy/at803x.c  |   2 +-
 drivers/net/phy/bcm63xx.c |   9 +-
 drivers/net/phy/dp83640.c |  18 +-
 drivers/net/phy/marvell.c |   4 +-
 drivers/net/phy/marvell10g.c  |  17 +-
 drivers/net/phy/microchip.c   |  33 ++--
 drivers/net/phy/microchip_t1.c|   2 +-
 drivers/net/phy/phy_device.c  | 168 +-
 drivers/net/phy/phylink.c |  27 ---
 include/linux/linkmode.h  |  76 
 include/linux/mii.h   | 101 +++
 include/linux/phy.h   |  31 +++-
 21 files changed, 420 insertions(+), 135 deletions(-)
 create mode 100644 include/linux/linkmode.h

-- 
2.19.0.rc1



[PATCH net-next] MAINTAINERS: Fix wrong include file path

2018-09-29 Thread Andrew Lunn
Fix the patch for the mv88e6xxx.h header file in MAINTAINERS

Reported-by: Joe Perches 
Signed-off-by: Andrew Lunn 
---
 MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 15565de091af..12d1da4a9653 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8753,7 +8753,7 @@ M:Vivien Didelot 

 L: netdev@vger.kernel.org
 S: Maintained
 F: drivers/net/dsa/mv88e6xxx/
-F: linux/platform_data/mv88e6xxx.h
+F: include/linux/platform_data/mv88e6xxx.h
 F: Documentation/devicetree/bindings/net/dsa/marvell.txt
 
 MARVELL ARMADA DRM SUPPORT
-- 
2.19.0.rc1



Re: [PATCH] r8169: Disable clk during suspend / resume

2018-09-29 Thread David Miller
From: Hans de Goede 
Date: Wed, 26 Sep 2018 22:12:39 +0200

> Disable the clk during suspend to save power. Note that tp->clk may be
> NULL, the clk core functions handle this without problems.
> 
> Reviewed-by: Andy Shevchenko 
> Tested-by: Carlo Caione 
> Signed-off-by: Hans de Goede 

Applied.


Re: [PATCH] netlink: fix typo in nla_parse_nested() comment

2018-09-29 Thread David Miller
From: Johannes Berg 
Date: Wed, 26 Sep 2018 22:19:42 +0200

> From: Johannes Berg 
> 
> Fix a simple typo: attribuets -> attributes
> 
> Signed-off-by: Johannes Berg 

Applied.


Re: [PATCH net 1/1] qlcnic: fix Tx descriptor corruption on 82xx devices

2018-09-29 Thread David Miller
From: Shahed Shaikh 
Date: Wed, 26 Sep 2018 12:41:10 -0700

> In regular NIC transmission flow, driver always configures MAC using
> Tx queue zero descriptor as a part of MAC learning flow.
> But with multi Tx queue supported NIC, regular transmission can occur on
> any non-zero Tx queue and from that context it uses
> Tx queue zero descriptor to configure MAC, at the same time TX queue
> zero could be used by another CPU for regular transmission
> which could lead to Tx queue zero descriptor corruption and cause FW
> abort.
> 
> This patch fixes this in such a way that driver always configures
> learned MAC address from the same Tx queue which is used for
> regular transmission.
> 
> Fixes: 7e2cf4feba05 ("qlcnic: change driver hardware interface mechanism")
> Signed-off-by: Shahed Shaikh 

Applied and queued up for -stable.


Re: [PATCH] [PATCH net-next] openvswitch: Use correct reply values in datapath and vport ops

2018-09-29 Thread David Miller
From: Yifeng Sun 
Date: Wed, 26 Sep 2018 11:40:14 -0700

> This patch fixes the bug that all datapath and vport ops are returning
> wrong values (OVS_FLOW_CMD_NEW or OVS_DP_CMD_NEW) in their replies.
> 
> Signed-off-by: Yifeng Sun 

Applied.


Re: [PATCH net-next] tls: Remove redundant vars from tls record structure

2018-09-29 Thread David Miller
From: Vakul Garg 
Date: Wed, 26 Sep 2018 16:22:08 +0530

> Structure 'tls_rec' contains sg_aead_in and sg_aead_out which point
> to a aad_space and then chain scatterlists sg_plaintext_data,
> sg_encrypted_data respectively. Rather than using chained scatterlists
> for plaintext and encrypted data in aead_req, it is efficient to store
> aad_space in sg_encrypted_data and sg_plaintext_data itself in the
> first index and get rid of sg_aead_in, sg_aead_in and further chaining.
> 
> This requires increasing size of sg_encrypted_data & sg_plaintext_data
> arrarys by 1 to accommodate entry for aad_space. The code which uses
> sg_encrypted_data and sg_plaintext_data has been modified to skip first
> index as it points to aad_space.
> 
> Signed-off-by: Vakul Garg 

Applied, thanks.


Re: pull-request: ieee802154 for net 2018-09-28

2018-09-29 Thread David Miller
From: Stefan Schmidt 
Date: Fri, 28 Sep 2018 12:20:42 +0200

> An update from ieee802154 for your *net* tree.
> 
> Some cleanup patches throughout the drivers from the Huawei tag team
> Yue Haibing and Zhong Jiang.
> Xue is replacing some magic numbers with defines in his mcr20a driver.

Applied, thanks.


Re: [PATCH net-next v2] tcp: up initial rmem to 128KB and SYN rwin to around 64KB

2018-09-29 Thread David Miller
From: Yuchung Cheng 
Date: Fri, 28 Sep 2018 13:09:02 -0700

> Previously TCP initial receive buffer is ~87KB by default and
> the initial receive window is ~29KB (20 MSS). This patch changes
> the two numbers to 128KB and ~64KB (rounding down to the multiples
> of MSS) respectively. The patch also simplifies the calculations s.t.
> the two numbers are directly controlled by sysctl tcp_rmem[1]:
> 
>   1) Initial receiver buffer budget (sk_rcvbuf): while this should
>  be configured via sysctl tcp_rmem[1], previously tcp_fixup_rcvbuf()
>  always override and set a larger size when a new connection
>  establishes.
> 
>   2) Initial receive window in SYN: previously it is set to 20
>  packets if MSS <= 1460. The number 20 was based on the initial
>  congestion window of 10: the receiver needs twice amount to
>  avoid being limited by the receive window upon out-of-order
>  delivery in the first window burst. But since this only
>  applies if the receiving MSS <= 1460, connection using large MTU
>  (e.g. to utilize receiver zero-copy) may be limited by the
>  receive window.
> 
> This patch also lowers the initial bytes expected to receive in
> the receiver buffer autotuning algorithm - otherwise the receiver
> may take two to three rounds to increase the buffer to the
> appropriate level (2x sender congestion window).
> 
> With this patch TCP memory configuration is more straight-forward and
> more properly sized to modern high-speed networks by default. Several
> popular stacks have been announcing 64KB rwin in SYNs as well.
> 
> Signed-off-by: Yuchung Cheng 
> Signed-off-by: Wei Wang 
> Signed-off-by: Neal Cardwell 
> Signed-off-by: Eric Dumazet 
> Reviewed-by: Soheil Hassas Yeganeh 

Applied, thanks.


[PATCH iproute2-next 03/11] libnetlink: Convert GETADDRLABEL dumps to use rtnl_addrlbldump_req

2018-09-29 Thread David Ahern
From: David Ahern 

Add rtnl_addrlbldump_req for address label dumps using the proper
ifaddrlblmsg as the header. Convert existing RTM_GETADDRALBEL dumps
to use it.

Signed-off-by: David Ahern 
---
 include/libnetlink.h |  2 ++
 ip/ipaddrlabel.c |  4 ++--
 lib/libnetlink.c | 17 +
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/include/libnetlink.h b/include/libnetlink.h
index a60af316b505..bacaec8216f7 100644
--- a/include/libnetlink.h
+++ b/include/libnetlink.h
@@ -49,6 +49,8 @@ void rtnl_close(struct rtnl_handle *rth);
 
 int rtnl_addrdump_req(struct rtnl_handle *rth, int family)
__attribute__((warn_unused_result));
+int rtnl_addrlbldump_req(struct rtnl_handle *rth, int family)
+   __attribute__((warn_unused_result));
 int rtnl_routedump_req(struct rtnl_handle *rth, int family)
__attribute__((warn_unused_result));
 
diff --git a/ip/ipaddrlabel.c b/ip/ipaddrlabel.c
index 2f79c56dcead..845fe4c5db27 100644
--- a/ip/ipaddrlabel.c
+++ b/ip/ipaddrlabel.c
@@ -118,7 +118,7 @@ static int ipaddrlabel_list(int argc, char **argv)
return -1;
}
 
-   if (rtnl_wilddump_request(&rth, af, RTM_GETADDRLABEL) < 0) {
+   if (rtnl_addrlbldump_req(&rth, af) < 0) {
perror("Cannot send dump request");
return 1;
}
@@ -237,7 +237,7 @@ static int ipaddrlabel_flush(int argc, char **argv)
return -1;
}
 
-   if (rtnl_wilddump_request(&rth, af, RTM_GETADDRLABEL) < 0) {
+   if (rtnl_addrlbldump_req(&rth, af) < 0) {
perror("Cannot send dump request");
return -1;
}
diff --git a/lib/libnetlink.c b/lib/libnetlink.c
index fda5309ce44d..fb5f1714c2d8 100644
--- a/lib/libnetlink.c
+++ b/lib/libnetlink.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "libnetlink.h"
 
@@ -215,6 +216,22 @@ int rtnl_addrdump_req(struct rtnl_handle *rth, int family)
return send(rth->fd, &req, sizeof(req), 0);
 }
 
+int rtnl_addrlbldump_req(struct rtnl_handle *rth, int family)
+{
+   struct {
+   struct nlmsghdr nlh;
+   struct ifaddrlblmsg ifal;
+   } req = {
+   .nlh.nlmsg_len = sizeof(req),
+   .nlh.nlmsg_type = RTM_GETADDRLABEL,
+   .nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
+   .nlh.nlmsg_seq = rth->dump = ++rth->seq,
+   .ifal.ifal_family = family,
+   };
+
+   return send(rth->fd, &req, sizeof(req), 0);
+}
+
 int rtnl_routedump_req(struct rtnl_handle *rth, int family)
 {
struct {
-- 
2.11.0



[PATCH iproute2-next 02/11] libnetlink: Convert GETROUTE dumps to use rtnl_routedump_req

2018-09-29 Thread David Ahern
From: David Ahern 

Add rtnl_routedump_req for route dumps using the proper rtmsg
as the header. Convert existing RTM_GETROUTE dumps to use it.

Signed-off-by: David Ahern 
---
 include/libnetlink.h |  2 ++
 ip/ipmroute.c|  2 +-
 ip/iproute.c |  4 ++--
 lib/libnetlink.c | 16 
 4 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/include/libnetlink.h b/include/libnetlink.h
index 2d9f6190230c..a60af316b505 100644
--- a/include/libnetlink.h
+++ b/include/libnetlink.h
@@ -49,6 +49,8 @@ void rtnl_close(struct rtnl_handle *rth);
 
 int rtnl_addrdump_req(struct rtnl_handle *rth, int family)
__attribute__((warn_unused_result));
+int rtnl_routedump_req(struct rtnl_handle *rth, int family)
+   __attribute__((warn_unused_result));
 
 int rtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type)
__attribute__((warn_unused_result));
diff --git a/ip/ipmroute.c b/ip/ipmroute.c
index bc23cfea7e8b..c5dfa9cb1538 100644
--- a/ip/ipmroute.c
+++ b/ip/ipmroute.c
@@ -283,7 +283,7 @@ static int mroute_list(int argc, char **argv)
filter.iif = idx;
}
 
-   if (rtnl_wilddump_request(&rth, filter.af, RTM_GETROUTE) < 0) {
+   if (rtnl_routedump_req(&rth, filter.af) < 0) {
perror("Cannot send dump request");
return 1;
}
diff --git a/ip/iproute.c b/ip/iproute.c
index 398322fd1f4f..699635923764 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -1645,7 +1645,7 @@ static int iproute_flush(int do_ipv6, rtnl_filter_t 
filter_fn)
filter.flushe = sizeof(flushb);
 
for (;;) {
-   if (rtnl_wilddump_request(&rth, do_ipv6, RTM_GETROUTE) < 0) {
+   if (rtnl_routedump_req(&rth, do_ipv6) < 0) {
perror("Cannot send dump request");
return -2;
}
@@ -1891,7 +1891,7 @@ static int iproute_list_flush_or_save(int argc, char 
**argv, int action)
return iproute_flush(do_ipv6, filter_fn);
 
if (!filter.cloned) {
-   if (rtnl_wilddump_request(&rth, do_ipv6, RTM_GETROUTE) < 0) {
+   if (rtnl_routedump_req(&rth, do_ipv6) < 0) {
perror("Cannot send dump request");
return -2;
}
diff --git a/lib/libnetlink.c b/lib/libnetlink.c
index 749cf4fbb88e..fda5309ce44d 100644
--- a/lib/libnetlink.c
+++ b/lib/libnetlink.c
@@ -215,6 +215,22 @@ int rtnl_addrdump_req(struct rtnl_handle *rth, int family)
return send(rth->fd, &req, sizeof(req), 0);
 }
 
+int rtnl_routedump_req(struct rtnl_handle *rth, int family)
+{
+   struct {
+   struct nlmsghdr nlh;
+   struct rtmsg rtm;
+   } req = {
+   .nlh.nlmsg_len = sizeof(req),
+   .nlh.nlmsg_type = RTM_GETROUTE,
+   .nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
+   .nlh.nlmsg_seq = rth->dump = ++rth->seq,
+   .rtm.rtm_family = family,
+   };
+
+   return send(rth->fd, &req, sizeof(req), 0);
+}
+
 int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type)
 {
return rtnl_wilddump_req_filter(rth, family, type, RTEXT_FILTER_VF);
-- 
2.11.0



[PATCH iproute2-next 05/11] libnetlink: Convert GETNETCONF dumps to use rtnl_netconfdump_req

2018-09-29 Thread David Ahern
From: David Ahern 

Add rtnl_netconfdump_req for netconf dumps using the proper netconfmsg
as the header. Convert existing RTM_GETNETCONF dumps to use it.

Signed-off-by: David Ahern 
---
 include/libnetlink.h |  2 ++
 ip/ipnetconf.c   |  3 +--
 lib/libnetlink.c | 16 
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/include/libnetlink.h b/include/libnetlink.h
index 8f2b2935074a..7e9ef640c704 100644
--- a/include/libnetlink.h
+++ b/include/libnetlink.h
@@ -55,6 +55,8 @@ int rtnl_routedump_req(struct rtnl_handle *rth, int family)
__attribute__((warn_unused_result));
 int rtnl_mdbdump_req(struct rtnl_handle *rth, int family)
__attribute__((warn_unused_result));
+int rtnl_netconfdump_req(struct rtnl_handle *rth, int family)
+   __attribute__((warn_unused_result));
 
 int rtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type)
__attribute__((warn_unused_result));
diff --git a/ip/ipnetconf.c b/ip/ipnetconf.c
index 04c4d60807b1..21822e367e11 100644
--- a/ip/ipnetconf.c
+++ b/ip/ipnetconf.c
@@ -210,8 +210,7 @@ static int do_show(int argc, char **argv)
} else {
rth.flags = RTNL_HANDLE_F_SUPPRESS_NLERR;
 dump:
-   if (rtnl_wilddump_request(&rth, filter.family,
- RTM_GETNETCONF) < 0) {
+   if (rtnl_netconfdump_req(&rth, filter.family) < 0) {
perror("Cannot send dump request");
exit(1);
}
diff --git a/lib/libnetlink.c b/lib/libnetlink.c
index 51ea457cd31a..e5cb275faf09 100644
--- a/lib/libnetlink.c
+++ b/lib/libnetlink.c
@@ -265,6 +265,22 @@ int rtnl_mdbdump_req(struct rtnl_handle *rth, int family)
return send(rth->fd, &req, sizeof(req), 0);
 }
 
+int rtnl_netconfdump_req(struct rtnl_handle *rth, int family)
+{
+   struct {
+   struct nlmsghdr nlh;
+   struct netconfmsg ncm;
+   } req = {
+   .nlh.nlmsg_len = sizeof(req),
+   .nlh.nlmsg_type = RTM_GETNETCONF,
+   .nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
+   .nlh.nlmsg_seq = rth->dump = ++rth->seq,
+   .ncm.ncm_family = family,
+   };
+
+   return send(rth->fd, &req, sizeof(req), 0);
+}
+
 int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type)
 {
return rtnl_wilddump_req_filter(rth, family, type, RTEXT_FILTER_VF);
-- 
2.11.0



[PATCH iproute2-next 04/11] libnetlink: Convert GETMDB dumps to use rtnl_mdbdump_req

2018-09-29 Thread David Ahern
From: David Ahern 

Add rtnl_mdbdump_req for mdb dumps using the proper br_port_msg as
the header. Convert existing RTM_GETMDB dumps to use it.

Signed-off-by: David Ahern 
---
 bridge/mdb.c |  2 +-
 include/libnetlink.h |  2 ++
 lib/libnetlink.c | 17 +
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/bridge/mdb.c b/bridge/mdb.c
index 841a36123050..03fcc91f0219 100644
--- a/bridge/mdb.c
+++ b/bridge/mdb.c
@@ -293,7 +293,7 @@ static int mdb_show(int argc, char **argv)
new_json_obj(json);
 
/* get mdb entries*/
-   if (rtnl_wilddump_request(&rth, PF_BRIDGE, RTM_GETMDB) < 0) {
+   if (rtnl_mdbdump_req(&rth, PF_BRIDGE) < 0) {
perror("Cannot send dump request");
return -1;
}
diff --git a/include/libnetlink.h b/include/libnetlink.h
index bacaec8216f7..8f2b2935074a 100644
--- a/include/libnetlink.h
+++ b/include/libnetlink.h
@@ -53,6 +53,8 @@ int rtnl_addrlbldump_req(struct rtnl_handle *rth, int family)
__attribute__((warn_unused_result));
 int rtnl_routedump_req(struct rtnl_handle *rth, int family)
__attribute__((warn_unused_result));
+int rtnl_mdbdump_req(struct rtnl_handle *rth, int family)
+   __attribute__((warn_unused_result));
 
 int rtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type)
__attribute__((warn_unused_result));
diff --git a/lib/libnetlink.c b/lib/libnetlink.c
index fb5f1714c2d8..51ea457cd31a 100644
--- a/lib/libnetlink.c
+++ b/lib/libnetlink.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "libnetlink.h"
 
@@ -248,6 +249,22 @@ int rtnl_routedump_req(struct rtnl_handle *rth, int family)
return send(rth->fd, &req, sizeof(req), 0);
 }
 
+int rtnl_mdbdump_req(struct rtnl_handle *rth, int family)
+{
+   struct {
+   struct nlmsghdr nlh;
+   struct br_port_msg bpm;
+   } req = {
+   .nlh.nlmsg_len = sizeof(req),
+   .nlh.nlmsg_type = RTM_GETMDB,
+   .nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
+   .nlh.nlmsg_seq = rth->dump = ++rth->seq,
+   .bpm.family = family,
+   };
+
+   return send(rth->fd, &req, sizeof(req), 0);
+}
+
 int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type)
 {
return rtnl_wilddump_req_filter(rth, family, type, RTEXT_FILTER_VF);
-- 
2.11.0



[PATCH iproute2-next 08/11] libnetlink: Convert GETNEIGHTBL dumps to use rtnl_neightbldump_req

2018-09-29 Thread David Ahern
From: David Ahern 

Add rtnl_neightbldump_req for neighbor table dumps using the proper ndtmsg
as the header. Convert existing RTM_GETNEIGHTBL dumps to use it.

Signed-off-by: David Ahern 
---
 include/libnetlink.h |  2 ++
 ip/ipntable.c|  2 +-
 lib/libnetlink.c | 16 
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/include/libnetlink.h b/include/libnetlink.h
index e22ccbb82ce2..5ccc421b4b0e 100644
--- a/include/libnetlink.h
+++ b/include/libnetlink.h
@@ -57,6 +57,8 @@ int rtnl_ruledump_req(struct rtnl_handle *rth, int family)
__attribute__((warn_unused_result));
 int rtnl_neighdump_req(struct rtnl_handle *rth, int family)
__attribute__((warn_unused_result));
+int rtnl_neightbldump_req(struct rtnl_handle *rth, int family)
+   __attribute__((warn_unused_result));
 int rtnl_mdbdump_req(struct rtnl_handle *rth, int family)
__attribute__((warn_unused_result));
 int rtnl_netconfdump_req(struct rtnl_handle *rth, int family)
diff --git a/ip/ipntable.c b/ip/ipntable.c
index dd4f7c2ee6d9..ce3f4614e32b 100644
--- a/ip/ipntable.c
+++ b/ip/ipntable.c
@@ -658,7 +658,7 @@ static int ipntable_show(int argc, char **argv)
argc--; argv++;
}
 
-   if (rtnl_wilddump_request(&rth, preferred_family, RTM_GETNEIGHTBL) < 0) 
{
+   if (rtnl_neightbldump_req(&rth, preferred_family) < 0) {
perror("Cannot send dump request");
exit(1);
}
diff --git a/lib/libnetlink.c b/lib/libnetlink.c
index fd0f95a24194..c28047e4b055 100644
--- a/lib/libnetlink.c
+++ b/lib/libnetlink.c
@@ -282,6 +282,22 @@ int rtnl_neighdump_req(struct rtnl_handle *rth, int family)
return send(rth->fd, &req, sizeof(req), 0);
 }
 
+int rtnl_neightbldump_req(struct rtnl_handle *rth, int family)
+{
+   struct {
+   struct nlmsghdr nlh;
+   struct ndtmsg ndtmsg;
+   } req = {
+   .nlh.nlmsg_len = sizeof(req),
+   .nlh.nlmsg_type = RTM_GETNEIGHTBL,
+   .nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
+   .nlh.nlmsg_seq = rth->dump = ++rth->seq,
+   .ndtmsg.ndtm_family = family,
+   };
+
+   return send(rth->fd, &req, sizeof(req), 0);
+}
+
 int rtnl_mdbdump_req(struct rtnl_handle *rth, int family)
 {
struct {
-- 
2.11.0



[PATCH iproute2-next 07/11] libnetlink: Convert GETNEIGH dumps to use rtnl_neighdump_req

2018-09-29 Thread David Ahern
From: David Ahern 

Add rtnl_neighdump_req for neighbor dumps using the proper ndmsg
as the header. Convert existing rtnl_wilddump_request for RTM_GETNEIGH
to use it.

Signed-off-by: David Ahern 
---
 include/libnetlink.h |  2 ++
 lib/libnetlink.c | 16 
 misc/arpd.c  |  2 +-
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/include/libnetlink.h b/include/libnetlink.h
index 5f6bbe55fe4a..e22ccbb82ce2 100644
--- a/include/libnetlink.h
+++ b/include/libnetlink.h
@@ -55,6 +55,8 @@ int rtnl_routedump_req(struct rtnl_handle *rth, int family)
__attribute__((warn_unused_result));
 int rtnl_ruledump_req(struct rtnl_handle *rth, int family)
__attribute__((warn_unused_result));
+int rtnl_neighdump_req(struct rtnl_handle *rth, int family)
+   __attribute__((warn_unused_result));
 int rtnl_mdbdump_req(struct rtnl_handle *rth, int family)
__attribute__((warn_unused_result));
 int rtnl_netconfdump_req(struct rtnl_handle *rth, int family)
diff --git a/lib/libnetlink.c b/lib/libnetlink.c
index 89e4d6a2a662..fd0f95a24194 100644
--- a/lib/libnetlink.c
+++ b/lib/libnetlink.c
@@ -266,6 +266,22 @@ int rtnl_ruledump_req(struct rtnl_handle *rth, int family)
return send(rth->fd, &req, sizeof(req), 0);
 }
 
+int rtnl_neighdump_req(struct rtnl_handle *rth, int family)
+{
+   struct {
+   struct nlmsghdr nlh;
+   struct ndmsg ndm;
+   } req = {
+   .nlh.nlmsg_len = sizeof(req),
+   .nlh.nlmsg_type = RTM_GETNEIGH,
+   .nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
+   .nlh.nlmsg_seq = rth->dump = ++rth->seq,
+   .ndm.ndm_family = family,
+   };
+
+   return send(rth->fd, &req, sizeof(req), 0);
+}
+
 int rtnl_mdbdump_req(struct rtnl_handle *rth, int family)
 {
struct {
diff --git a/misc/arpd.c b/misc/arpd.c
index 67d86b67957b..ce7c09978c2b 100644
--- a/misc/arpd.c
+++ b/misc/arpd.c
@@ -424,7 +424,7 @@ static int do_one_request(struct nlmsghdr *n)
 
 static void load_initial_table(void)
 {
-   if (rtnl_wilddump_request(&rth, AF_INET, RTM_GETNEIGH) < 0) {
+   if (rtnl_neighdump_req(&rth, AF_INET) < 0) {
perror("dump request failed");
exit(1);
}
-- 
2.11.0



[PATCH iproute2-next 06/11] libnetlink: Convert GETRULE dumps to use rtnl_ruledump_req

2018-09-29 Thread David Ahern
From: David Ahern 

Add rtnl_ruledump_req for fib fule dumps using the proper fib_rule_hdr
as the header. Convert existing RTM_GETRULE dumps to use it.

Signed-off-by: David Ahern 
---
 include/libnetlink.h |  2 ++
 ip/iprule.c  |  2 +-
 lib/libnetlink.c | 17 +
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/include/libnetlink.h b/include/libnetlink.h
index 7e9ef640c704..5f6bbe55fe4a 100644
--- a/include/libnetlink.h
+++ b/include/libnetlink.h
@@ -53,6 +53,8 @@ int rtnl_addrlbldump_req(struct rtnl_handle *rth, int family)
__attribute__((warn_unused_result));
 int rtnl_routedump_req(struct rtnl_handle *rth, int family)
__attribute__((warn_unused_result));
+int rtnl_ruledump_req(struct rtnl_handle *rth, int family)
+   __attribute__((warn_unused_result));
 int rtnl_mdbdump_req(struct rtnl_handle *rth, int family)
__attribute__((warn_unused_result));
 int rtnl_netconfdump_req(struct rtnl_handle *rth, int family)
diff --git a/ip/iprule.c b/ip/iprule.c
index 744d6d88e343..60fd4c7e9f93 100644
--- a/ip/iprule.c
+++ b/ip/iprule.c
@@ -615,7 +615,7 @@ static int iprule_list_flush_or_save(int argc, char **argv, 
int action)
argc--; argv++;
}
 
-   if (rtnl_wilddump_request(&rth, af, RTM_GETRULE) < 0) {
+   if (rtnl_ruledump_req(&rth, af) < 0) {
perror("Cannot send dump request");
return 1;
}
diff --git a/lib/libnetlink.c b/lib/libnetlink.c
index e5cb275faf09..89e4d6a2a662 100644
--- a/lib/libnetlink.c
+++ b/lib/libnetlink.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -249,6 +250,22 @@ int rtnl_routedump_req(struct rtnl_handle *rth, int family)
return send(rth->fd, &req, sizeof(req), 0);
 }
 
+int rtnl_ruledump_req(struct rtnl_handle *rth, int family)
+{
+   struct {
+   struct nlmsghdr nlh;
+   struct fib_rule_hdr frh;
+   } req = {
+   .nlh.nlmsg_len = sizeof(req),
+   .nlh.nlmsg_type = RTM_GETRULE,
+   .nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
+   .nlh.nlmsg_seq = rth->dump = ++rth->seq,
+   .frh.family = family
+   };
+
+   return send(rth->fd, &req, sizeof(req), 0);
+}
+
 int rtnl_mdbdump_req(struct rtnl_handle *rth, int family)
 {
struct {
-- 
2.11.0



[PATCH iproute2-next 01/11] libnetlink: Convert GETADDR dumps to use rtnl_addrdump_req

2018-09-29 Thread David Ahern
From: David Ahern 

Add rtnl_addrdump_req for address dumps using the proper ifaddrmsg
as the header. Convert existing RTM_GETADDR dumps to use it.

Signed-off-by: David Ahern 
---
 include/libnetlink.h |  4 
 ip/ipaddress.c   |  6 +++---
 lib/libnetlink.c | 16 
 3 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/include/libnetlink.h b/include/libnetlink.h
index 9d9249e634dc..2d9f6190230c 100644
--- a/include/libnetlink.h
+++ b/include/libnetlink.h
@@ -46,6 +46,10 @@ int rtnl_open_byproto(struct rtnl_handle *rth, unsigned int 
subscriptions,
__attribute__((warn_unused_result));
 
 void rtnl_close(struct rtnl_handle *rth);
+
+int rtnl_addrdump_req(struct rtnl_handle *rth, int family)
+   __attribute__((warn_unused_result));
+
 int rtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type)
__attribute__((warn_unused_result));
 int rtnl_wilddump_req_filter(struct rtnl_handle *rth, int fam, int type,
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 8dc6c32fd6d9..f29480ce51d4 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -1698,7 +1698,7 @@ static int ipaddr_flush(void)
filter.flushe = sizeof(flushb);
 
while ((max_flush_loops == 0) || (round < max_flush_loops)) {
-   if (rtnl_wilddump_request(&rth, filter.family, RTM_GETADDR) < 
0) {
+   if (rtnl_addrdump_req(&rth, filter.family) < 0) {
perror("Cannot send dump request");
exit(1);
}
@@ -1790,7 +1790,7 @@ int ip_linkaddr_list(int family, req_filter_fn_t 
filter_fn,
}
 
if (ainfo) {
-   if (rtnl_wilddump_request(&rth, family, RTM_GETADDR) < 0) {
+   if (rtnl_addrdump_req(&rth, family) < 0) {
perror("Cannot send dump request");
return 1;
}
@@ -1915,7 +1915,7 @@ static int ipaddr_list_flush_or_save(int argc, char 
**argv, int action)
if (ipadd_save_prep())
exit(1);
 
-   if (rtnl_wilddump_request(&rth, preferred_family, RTM_GETADDR) 
< 0) {
+   if (rtnl_addrdump_req(&rth, preferred_family) < 0) {
perror("Cannot send dump request");
exit(1);
}
diff --git a/lib/libnetlink.c b/lib/libnetlink.c
index f18dceac2b5e..749cf4fbb88e 100644
--- a/lib/libnetlink.c
+++ b/lib/libnetlink.c
@@ -199,6 +199,22 @@ int rtnl_open(struct rtnl_handle *rth, unsigned int 
subscriptions)
return rtnl_open_byproto(rth, subscriptions, NETLINK_ROUTE);
 }
 
+int rtnl_addrdump_req(struct rtnl_handle *rth, int family)
+{
+   struct {
+   struct nlmsghdr nlh;
+   struct ifaddrmsg ifm;
+   } req = {
+   .nlh.nlmsg_len = sizeof(req),
+   .nlh.nlmsg_type = RTM_GETADDR,
+   .nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
+   .nlh.nlmsg_seq = rth->dump = ++rth->seq,
+   .ifm.ifa_family = family,
+   };
+
+   return send(rth->fd, &req, sizeof(req), 0);
+}
+
 int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type)
 {
return rtnl_wilddump_req_filter(rth, family, type, RTEXT_FILTER_VF);
-- 
2.11.0



[PATCH iproute2-next 10/11] libnetlink: Rename rtnl_wilddump_* to rtnl_linkdump_*

2018-09-29 Thread David Ahern
From: David Ahern 

Rename rtnl_wilddump_req_filter to rtnl_linkdump_req_filter,
rtnl_wilddump_request to rtnl_linkdump_request and
rtnl_wilddump_req_filter_fn to rtnl_linkdump_req_filter_fn.

In all cases drop the type argument which at this point is only
RTM_GETLINK and hardcode in the functions.

Signed-off-by: David Ahern 
---
 bridge/link.c|  4 ++--
 bridge/vlan.c|  2 +-
 include/libnetlink.h |  7 +++
 ip/ipaddress.c   |  4 ++--
 ip/iptoken.c |  2 +-
 ip/iptuntap.c|  2 +-
 ip/rtmon.c   |  2 +-
 ip/tunnel.c  |  2 +-
 lib/libnetlink.c | 12 ++--
 lib/ll_map.c |  2 +-
 misc/ifstat.c|  2 +-
 11 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/bridge/link.c b/bridge/link.c
index 8557026387d2..5d4f9b525cad 100644
--- a/bridge/link.c
+++ b/bridge/link.c
@@ -502,7 +502,7 @@ static int brlink_show(int argc, char **argv)
}
 
if (show_details) {
-   if (rtnl_wilddump_req_filter(&rth, PF_BRIDGE, RTM_GETLINK,
+   if (rtnl_linkdump_req_filter(&rth, PF_BRIDGE,
 (compress_vlans ?
  RTEXT_FILTER_BRVLAN_COMPRESSED :
  RTEXT_FILTER_BRVLAN)) < 0) {
@@ -510,7 +510,7 @@ static int brlink_show(int argc, char **argv)
exit(1);
}
} else {
-   if (rtnl_wilddump_request(&rth, PF_BRIDGE, RTM_GETLINK) < 0) {
+   if (rtnl_linkdump_request(&rth, PF_BRIDGE) < 0) {
perror("Cannon send dump request");
exit(1);
}
diff --git a/bridge/vlan.c b/bridge/vlan.c
index bdce55ae4e14..59ed1964bcd2 100644
--- a/bridge/vlan.c
+++ b/bridge/vlan.c
@@ -575,7 +575,7 @@ static int vlan_show(int argc, char **argv)
new_json_obj(json);
 
if (!show_stats) {
-   if (rtnl_wilddump_req_filter(&rth, PF_BRIDGE, RTM_GETLINK,
+   if (rtnl_linkdump_req_filter(&rth, PF_BRIDGE,
 (compress_vlans ?
  RTEXT_FILTER_BRVLAN_COMPRESSED :
  RTEXT_FILTER_BRVLAN)) < 0) {
diff --git a/include/libnetlink.h b/include/libnetlink.h
index f22c92ac03dc..29eb906ec9eb 100644
--- a/include/libnetlink.h
+++ b/include/libnetlink.h
@@ -66,15 +66,14 @@ int rtnl_netconfdump_req(struct rtnl_handle *rth, int 
family)
 int rtnl_nsiddump_req(struct rtnl_handle *rth, int family)
__attribute__((warn_unused_result));
 
-int rtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type)
+int rtnl_linkdump_request(struct rtnl_handle *rth, int fam)
__attribute__((warn_unused_result));
-int rtnl_wilddump_req_filter(struct rtnl_handle *rth, int fam, int type,
-   __u32 filt_mask)
+int rtnl_linkdump_req_filter(struct rtnl_handle *rth, int fam, __u32 filt_mask)
__attribute__((warn_unused_result));
 
 typedef int (*req_filter_fn_t)(struct nlmsghdr *nlh, int reqlen);
 
-int rtnl_wilddump_req_filter_fn(struct rtnl_handle *rth, int fam, int type,
+int rtnl_linkdump_req_filter_fn(struct rtnl_handle *rth, int fam,
req_filter_fn_t fn)
__attribute__((warn_unused_result));
 int rtnl_wilddump_stats_req_filter(struct rtnl_handle *rth, int fam, int type,
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index f29480ce51d4..ffe1e1617cba 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -1778,7 +1778,7 @@ static int iplink_filter_req(struct nlmsghdr *nlh, int 
reqlen)
 int ip_linkaddr_list(int family, req_filter_fn_t filter_fn,
 struct nlmsg_chain *linfo, struct nlmsg_chain *ainfo)
 {
-   if (rtnl_wilddump_req_filter_fn(&rth, preferred_family, RTM_GETLINK,
+   if (rtnl_linkdump_req_filter_fn(&rth, preferred_family,
filter_fn) < 0) {
perror("Cannot send dump request");
return 1;
@@ -2031,7 +2031,7 @@ void ipaddr_get_vf_rate(int vfnum, int *min, int *max, 
const char *dev)
exit(1);
}
 
-   if (rtnl_wilddump_request(&rth, AF_UNSPEC, RTM_GETLINK) < 0) {
+   if (rtnl_linkdump_request(&rth, AF_UNSPEC) < 0) {
perror("Cannot send dump request");
exit(1);
}
diff --git a/ip/iptoken.c b/ip/iptoken.c
index fb64da4ec262..ce0051dfdf8a 100644
--- a/ip/iptoken.c
+++ b/ip/iptoken.c
@@ -109,7 +109,7 @@ static int iptoken_list(int argc, char **argv)
argc--; argv++;
}
 
-   if (rtnl_wilddump_request(&rth, af, RTM_GETLINK) < 0) {
+   if (rtnl_linkdump_request(&rth, af) < 0) {
perror("Cannot send dump request");
return -1;
}
diff --git a/ip/iptuntap.c b/ip/iptuntap.c
index 58996e6c5733..8c84e6206fa9 100644
--- a/ip/iptuntap.c
+++ b/ip/iptunt

[PATCH iproute2-next 09/11] libnetlink: Convert GETNSID dumps to use rtnl_nsiddump_req

2018-09-29 Thread David Ahern
From: David Ahern 

Add rtnl_nsiddump_req for namespace id dumps using the proper rtgenmsg
as the header. Convert existing RTM_GETNSID dumps to use it.

Signed-off-by: David Ahern 
---
 include/libnetlink.h |  2 ++
 ip/ipnetns.c |  2 +-
 lib/libnetlink.c | 16 
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/include/libnetlink.h b/include/libnetlink.h
index 5ccc421b4b0e..f22c92ac03dc 100644
--- a/include/libnetlink.h
+++ b/include/libnetlink.h
@@ -63,6 +63,8 @@ int rtnl_mdbdump_req(struct rtnl_handle *rth, int family)
__attribute__((warn_unused_result));
 int rtnl_netconfdump_req(struct rtnl_handle *rth, int family)
__attribute__((warn_unused_result));
+int rtnl_nsiddump_req(struct rtnl_handle *rth, int family)
+   __attribute__((warn_unused_result));
 
 int rtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type)
__attribute__((warn_unused_result));
diff --git a/ip/ipnetns.c b/ip/ipnetns.c
index 368be0cbc0a4..e8500c773994 100644
--- a/ip/ipnetns.c
+++ b/ip/ipnetns.c
@@ -346,7 +346,7 @@ static int netns_list_id(int argc, char **argv)
return -ENOTSUP;
}
 
-   if (rtnl_wilddump_request(&rth, AF_UNSPEC, RTM_GETNSID) < 0) {
+   if (rtnl_nsiddump_req(&rth, AF_UNSPEC) < 0) {
perror("Cannot send dump request");
exit(1);
}
diff --git a/lib/libnetlink.c b/lib/libnetlink.c
index c28047e4b055..2dd14ac5ea58 100644
--- a/lib/libnetlink.c
+++ b/lib/libnetlink.c
@@ -330,6 +330,22 @@ int rtnl_netconfdump_req(struct rtnl_handle *rth, int 
family)
return send(rth->fd, &req, sizeof(req), 0);
 }
 
+int rtnl_nsiddump_req(struct rtnl_handle *rth, int family)
+{
+   struct {
+   struct nlmsghdr nlh;
+   struct rtgenmsg rtm;
+   } req = {
+   .nlh.nlmsg_len = sizeof(req),
+   .nlh.nlmsg_type = RTM_GETNSID,
+   .nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
+   .nlh.nlmsg_seq = rth->dump = ++rth->seq,
+   .rtm.rtgen_family = family,
+   };
+
+   return send(rth->fd, &req, sizeof(req), 0);
+}
+
 int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type)
 {
return rtnl_wilddump_req_filter(rth, family, type, RTEXT_FILTER_VF);
-- 
2.11.0



[PATCH iproute2-next 11/11] libnetlink: Rename rtnl_wilddump_stats_req_filter to rtnl_statsdump_req_filter

2018-09-29 Thread David Ahern
From: David Ahern 

rtnl_wilddump_stats_req_filter only takes RTM_GETSTATS as the type argument
so rename to rtnl_statsdump_req_filter for consistency with other request
functions and hardcode the type argument.

Signed-off-by: David Ahern 
---
 bridge/vlan.c| 8 ++--
 include/libnetlink.h | 3 +--
 ip/iplink.c  | 4 +---
 ip/iplink_xstats.c   | 4 +---
 lib/libnetlink.c | 5 ++---
 misc/ifstat.c| 4 ++--
 6 files changed, 9 insertions(+), 19 deletions(-)

diff --git a/bridge/vlan.c b/bridge/vlan.c
index 59ed1964bcd2..239907bdad89 100644
--- a/bridge/vlan.c
+++ b/bridge/vlan.c
@@ -603,9 +603,7 @@ static int vlan_show(int argc, char **argv)
__u32 filt_mask;
 
filt_mask = IFLA_STATS_FILTER_BIT(IFLA_STATS_LINK_XSTATS);
-   if (rtnl_wilddump_stats_req_filter(&rth, AF_UNSPEC,
-  RTM_GETSTATS,
-  filt_mask) < 0) {
+   if (rtnl_statsdump_req_filter(&rth, AF_UNSPEC, filt_mask) < 0) {
perror("Cannont send dump request");
exit(1);
}
@@ -619,9 +617,7 @@ static int vlan_show(int argc, char **argv)
}
 
filt_mask = IFLA_STATS_FILTER_BIT(IFLA_STATS_LINK_XSTATS_SLAVE);
-   if (rtnl_wilddump_stats_req_filter(&rth, AF_UNSPEC,
-  RTM_GETSTATS,
-  filt_mask) < 0) {
+   if (rtnl_statsdump_req_filter(&rth, AF_UNSPEC, filt_mask) < 0) {
perror("Cannont send slave dump request");
exit(1);
}
diff --git a/include/libnetlink.h b/include/libnetlink.h
index 29eb906ec9eb..8655e0b75c38 100644
--- a/include/libnetlink.h
+++ b/include/libnetlink.h
@@ -76,8 +76,7 @@ typedef int (*req_filter_fn_t)(struct nlmsghdr *nlh, int 
reqlen);
 int rtnl_linkdump_req_filter_fn(struct rtnl_handle *rth, int fam,
req_filter_fn_t fn)
__attribute__((warn_unused_result));
-int rtnl_wilddump_stats_req_filter(struct rtnl_handle *rth, int fam, int type,
-  __u32 filt_mask)
+int rtnl_statsdump_req_filter(struct rtnl_handle *rth, int fam, __u32 
filt_mask)
__attribute__((warn_unused_result));
 int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req,
 int len)
diff --git a/ip/iplink.c b/ip/iplink.c
index d99c49ed244a..50ccb49a0263 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -1601,9 +1601,7 @@ static int iplink_afstats(int argc, char **argv)
}
}
 
-   if (rtnl_wilddump_stats_req_filter(&rth, AF_UNSPEC,
-  RTM_GETSTATS,
-  filt_mask) < 0) {
+   if (rtnl_statsdump_req_filter(&rth, AF_UNSPEC, filt_mask) < 0) {
perror("Cannont send dump request");
return 1;
}
diff --git a/ip/iplink_xstats.c b/ip/iplink_xstats.c
index 10f953bc4584..908d9228369f 100644
--- a/ip/iplink_xstats.c
+++ b/ip/iplink_xstats.c
@@ -65,9 +65,7 @@ int iplink_ifla_xstats(int argc, char **argv)
else
filt_mask = IFLA_STATS_FILTER_BIT(IFLA_STATS_LINK_XSTATS);
 
-   if (rtnl_wilddump_stats_req_filter(&rth, AF_UNSPEC,
-  RTM_GETSTATS,
-  filt_mask) < 0) {
+   if (rtnl_statsdump_req_filter(&rth, AF_UNSPEC, filt_mask) < 0) {
perror("Cannont send dump request");
return -1;
}
diff --git a/lib/libnetlink.c b/lib/libnetlink.c
index bc72272be9c4..e12ce63bd05a 100644
--- a/lib/libnetlink.c
+++ b/lib/libnetlink.c
@@ -400,8 +400,7 @@ int rtnl_linkdump_req_filter_fn(struct rtnl_handle *rth, 
int family,
return send(rth->fd, &req, req.nlh.nlmsg_len, 0);
 }
 
-int rtnl_wilddump_stats_req_filter(struct rtnl_handle *rth, int fam, int type,
-  __u32 filt_mask)
+int rtnl_statsdump_req_filter(struct rtnl_handle *rth, int fam, __u32 
filt_mask)
 {
struct {
struct nlmsghdr nlh;
@@ -410,7 +409,7 @@ int rtnl_wilddump_stats_req_filter(struct rtnl_handle *rth, 
int fam, int type,
 
memset(&req, 0, sizeof(req));
req.nlh.nlmsg_len = NLMSG_LENGTH(sizeof(struct if_stats_msg));
-   req.nlh.nlmsg_type = type;
+   req.nlh.nlmsg_type = RTM_GETSTATS;
req.nlh.nlmsg_flags = NLM_F_DUMP|NLM_F_REQUEST;
req.nlh.nlmsg_pid = 0;
req.nlh.nlmsg_seq = rth->dump = ++rth->seq;
diff --git a/misc/ifstat.c b/misc/ifstat.c
index 36eba605d5ba..f12c88f295c3 100644
--- a/misc/ifstat.c
+++ b/misc/ifstat.c
@@ -203,8 +203,8 @@ static void load_info(void)
if (is_extended) {
ll_init_map(&rth);
filter_mask = IFLA_STATS_FILTER_BIT(filter_type);
- 

[PATCH iproute2-next 00/11] Fix dump requests to use proper header for type

2018-09-29 Thread David Ahern
From: David Ahern 

iproute2 currently uses ifinfomsg as the header for all dumps using the
wilddump headers. This is wrong as each message type actually has its own
header type. While the kernel has traditionally let it go as it for the
most part only uses the family entry, the use of kernel side filters is
increasing to alter what is returned on a request. The kernel side filters
really need to use the proper header type.

To that end, fix iproute2 to use the proper header struct for the GET type.

David Ahern (11):
  libnetlink: Convert GETADDR dumps to use rtnl_addrdump_req
  libnetlink: Convert GETROUTE dumps to use rtnl_routedump_req
  libnetlink: Convert GETADDRLABEL dumps to use rtnl_addrlbldump_req
  libnetlink: Convert GETMDB dumps to use rtnl_mdbdump_req
  libnetlink: Convert GETNETCONF dumps to use rtnl_netconfdump_req
  libnetlink: Convert GETRULE dumps to use rtnl_ruledump_req
  libnetlink: Convert GETNEIGH dumps to use rtnl_neighdump_req
  libnetlink: Convert GETNEIGHTBL dumps to use rtnl_neightbldump_req
  libnetlink: Convert GETNSID dumps to use rtnl_nsiddump_req
  libnetlink: Rename rtnl_wilddump_* to rtnl_linkdump_*
  libnetlink: Rename rtnl_wilddump_stats_req_filter to
rtnl_statsdump_req_filter

 bridge/link.c|   4 +-
 bridge/mdb.c |   2 +-
 bridge/vlan.c|  10 +---
 include/libnetlink.h |  30 --
 ip/ipaddress.c   |  10 ++--
 ip/ipaddrlabel.c |   4 +-
 ip/iplink.c  |   4 +-
 ip/iplink_xstats.c   |   4 +-
 ip/ipmroute.c|   2 +-
 ip/ipnetconf.c   |   3 +-
 ip/ipnetns.c |   2 +-
 ip/ipntable.c|   2 +-
 ip/iproute.c |   4 +-
 ip/iprule.c  |   2 +-
 ip/iptoken.c |   2 +-
 ip/iptuntap.c|   2 +-
 ip/rtmon.c   |   2 +-
 ip/tunnel.c  |   2 +-
 lib/libnetlink.c | 164 ---
 lib/ll_map.c |   2 +-
 misc/arpd.c  |   2 +-
 misc/ifstat.c|   6 +-
 22 files changed, 210 insertions(+), 55 deletions(-)

-- 
2.11.0



[PATCH] net/packet: fix packet drop as of virtio gso

2018-09-29 Thread Jianfeng Tan
When we use raw socket as the vhost backend, a packet from virito with
gso offloading information, cannot be sent out in later validaton at
xmit path, as we did not set correct skb->protocol which is further used
for looking up the gso function.

To fix this, we set this field according to virito hdr information.

Fixes: e858fae2b0b8f4 ("virtio_net: use common code for virtio_net_hdr and skb 
GSO conversion")

Cc: sta...@vger.kernel.org
Signed-off-by: Jianfeng Tan 
---
 include/linux/virtio_net.h | 18 ++
 net/packet/af_packet.c | 11 +++
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
index 9397628a1967..cb462f9ab7dd 100644
--- a/include/linux/virtio_net.h
+++ b/include/linux/virtio_net.h
@@ -5,6 +5,24 @@
 #include 
 #include 
 
+static inline int virtio_net_hdr_set_proto(struct sk_buff *skb,
+  const struct virtio_net_hdr *hdr)
+{
+   switch (hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
+   case VIRTIO_NET_HDR_GSO_TCPV4:
+   case VIRTIO_NET_HDR_GSO_UDP:
+   skb->protocol = cpu_to_be16(ETH_P_IP);
+   break;
+   case VIRTIO_NET_HDR_GSO_TCPV6:
+   skb->protocol = cpu_to_be16(ETH_P_IPV6);
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
 static inline int virtio_net_hdr_to_skb(struct sk_buff *skb,
const struct virtio_net_hdr *hdr,
bool little_endian)
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 75c92a87e7b2..d6e94dc7e290 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2715,10 +2715,12 @@ static int tpacket_snd(struct packet_sock *po, struct 
msghdr *msg)
}
}
 
-   if (po->has_vnet_hdr && virtio_net_hdr_to_skb(skb, vnet_hdr,
- vio_le())) {
-   tp_len = -EINVAL;
-   goto tpacket_error;
+   if (po->has_vnet_hdr) {
+   if (virtio_net_hdr_to_skb(skb, vnet_hdr, vio_le())) {
+   tp_len = -EINVAL;
+   goto tpacket_error;
+   }
+   virtio_net_hdr_set_proto(skb, vnet_hdr);
}
 
skb->destructor = tpacket_destruct_skb;
@@ -2915,6 +2917,7 @@ static int packet_snd(struct socket *sock, struct msghdr 
*msg, size_t len)
if (err)
goto out_free;
len += sizeof(vnet_hdr);
+   virtio_net_hdr_set_proto(skb, &vnet_hdr);
}
 
skb_probe_transport_header(skb, reserve);
-- 
2.17.1



[PATCHv2 net-next] geneve: allow to clear ttl inherit

2018-09-29 Thread Hangbin Liu
As Michal remaind, we should allow to clear ttl inherit. Then we will
have three states:

1. set the flag, and do ttl inherit.
2. do not set the flag, use configured ttl value, or default ttl (0) if
   not set.
3. disable ttl inherit, use previous configured ttl value, or default ttl (0).

Fixes: 52d0d404d39dd ("geneve: add ttl inherit support")
CC: Michal Kubecek 
Signed-off-by: Hangbin Liu 
---
 drivers/net/geneve.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index 6625fab..82eccc9 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -1325,11 +1325,15 @@ static int geneve_nl2info(struct nlattr *tb[], struct 
nlattr *data[],
info->key.tun_id = tunid;
}
 
-   if (data[IFLA_GENEVE_TTL])
+   if (data[IFLA_GENEVE_TTL_INHERIT]) {
+   if (nla_get_u8(data[IFLA_GENEVE_TTL_INHERIT]))
+   *ttl_inherit = true;
+   else
+   *ttl_inherit = false;
+   } else if (data[IFLA_GENEVE_TTL]) {
info->key.ttl = nla_get_u8(data[IFLA_GENEVE_TTL]);
-
-   if (data[IFLA_GENEVE_TTL_INHERIT])
-   *ttl_inherit = true;
+   *ttl_inherit = false;
+   }
 
if (data[IFLA_GENEVE_TOS])
info->key.tos = nla_get_u8(data[IFLA_GENEVE_TOS]);
-- 
2.5.5



Re: [PATCH net-next] geneve: fix ttl inherit type

2018-09-29 Thread Hangbin Liu
On Sat, Sep 29, 2018 at 01:46:19AM +0200, Michal Kubecek wrote:
> Is it desirable to switch to a flag? If I read geneve_changelink() and
> geneve_nl2info() correctly, it allows you to set the ttl_inherit flag
> for an existing device but doesn't allow you to clear it. With NLA_U8,
> you could distinguish three cases: set the flag (non-zero value), clear
> the flag (zero value) and preserve current state (attribute not
> present).
> 
> The same problem exists for vxlan but vxlan code intentionally disallows
> changing the flag value for an existing device (I'm not sure if it's
> because it's really impossible or just due to limits of the interface).
> Unfortunately it has been already released with NLA_FLAG in 4.18,
> AFAICS, so we have to live with it. But it's not too late for geneve.
> 
> Michal Kubecek

Hi michal,

I thought about the vxlan issue and agree with you. TTL inherit is a way
to define the ttl number we should use. It also should be able to be changed
as the normal ttl. How about enabling clear ttl inherit flag like:

--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -3303,13 +3303,11 @@ static int vxlan_nl2conf(struct nlattr *tb[], struct 
nlattr *data[],
if (data[IFLA_VXLAN_TOS])
conf->tos  = nla_get_u8(data[IFLA_VXLAN_TOS]);

-   if (data[IFLA_VXLAN_TTL])
-   conf->ttl = nla_get_u8(data[IFLA_VXLAN_TTL]);
-
if (data[IFLA_VXLAN_TTL_INHERIT]) {
-   if (changelink)
-   return -EOPNOTSUPP;
conf->flags |= VXLAN_F_TTL_INHERIT;
+   } else if (data[IFLA_VXLAN_TTL]) {
+   conf->flags &= ~VXLAN_F_TTL_INHERIT;
+   conf->ttl = nla_get_u8(data[IFLA_VXLAN_TTL]);
}


Before this fix, we disabled changing it after creating vxlan. And with this fix
we can set/unset it. I think this should not be a usage break. What do you 
think?

Thanks
Hangbin


Re: [PATCH iproute2 net-next] ipneigh: support setting of NTF_ROUTER on neigh entries

2018-09-29 Thread Roopa Prabhu
On Fri, Sep 28, 2018 at 9:57 AM David Ahern  wrote:
>
> On 9/25/18 3:15 PM, Roopa Prabhu wrote:
> > From: Roopa Prabhu 
> >
> > Signed-off-by: Roopa Prabhu 
> > ---
> >  ip/ipneigh.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
>
> applied to iproute2-next.
>
> And then I noticed you did not update the help or the man page. Please
> send a follow up.

Oops, looks like i missed including it in this patch before sending.
will post it today.


RE: [PATCH] hv_netvsc: remove ndo_poll_controller

2018-09-29 Thread Haiyang Zhang



> -Original Message-
> From: Stephen Hemminger 
> Sent: Saturday, September 29, 2018 8:53 AM
> To: netdev@vger.kernel.org
> Cc: Stephen Hemminger ; Haiyang Zhang
> ; Eric Dumazet 
> Subject: [PATCH] hv_netvsc: remove ndo_poll_controller
> 
> Similar to other patches from ERic.
> 
> As diagnosed by Song Liu, ndo_poll_controller() can be very dangerous on
> loaded hosts, since the cpu calling ndo_poll_controller() might steal all NAPI
> contexts (for all RX/TX queues of the NIC). This capture can last for 
> unlimited
> amount of time, since one cpu is generally not able to drain all the queues
> under load.
> 
> In netvsc driver it uses NAPI for TX completions. The default poll_napi will 
> do
> this for us now and avoid the capture.
> 
> Signed-off-by: Stephen Hemminger 
> Cc: Haiyang Zhang 
> Cc: Eric Dumazet 
> ---

Thank you.
Reviewed-by: Haiyang Zhang 



Re: [PATCH v3 net-next 9/9] devlink: Add Documentation/networking/devlink-params-bnxt.txt

2018-09-29 Thread Jiri Pirko
Fri, Sep 28, 2018 at 08:28:23AM CEST, vasundhara-v.vo...@broadcom.com wrote:
>This patch adds a new file to add information about configuration
>parameters that are supported by bnxt_en driver via devlink.
>
>Cc: "David S. Miller" 
>Cc: Jonathan Corbet 
>Cc: linux-...@vger.kernel.org
>Cc: Jiri Pirko 
>Cc: Michael Chan 
>Signed-off-by: Vasundhara Volam 
>---
> Documentation/networking/devlink-params-bnxt.txt | 22 ++
> 1 file changed, 22 insertions(+)
> create mode 100644 Documentation/networking/devlink-params-bnxt.txt
>
>diff --git a/Documentation/networking/devlink-params-bnxt.txt 
>b/Documentation/networking/devlink-params-bnxt.txt
>new file mode 100644
>index 000..c7bc9d8
>--- /dev/null
>+++ b/Documentation/networking/devlink-params-bnxt.txt
>@@ -0,0 +1,22 @@
>+enable_sriov  [DEVICE, GENERIC]
>+  Type: Boolean

No need to list "Type" here. You have it in devlink-params.txt for
generic params already.


>+  Configuration mode: Permanent
>+
>+ignore_ari[DEVICE, GENERIC]
>+  Type: Boolean
>+  Configuration mode: Permanent
>+
>+msix_vec_per_pf_max   [DEVICE, GENERIC]
>+  Type: u32
>+  Configuration mode: Permanent
>+
>+msix_vec_per_pf_min   [DEVICE, GENERIC]
>+  Type: u32
>+  Configuration mode: Permanent
>+
>+gre_ver_check [DEVICE, DRIVER-SPECIFIC]
>+  Generic Routing Encapsulation (GRE) version check will
>+  be enabled in the device. If disabled, device skips
>+  version checking for incoming packets.
>+  Type: Boolean
>+  Configuration mode: Permanent
>-- 
>1.8.3.1
>


Re: [PATCH] hv_netvsc: remove ndo_poll_controller

2018-09-29 Thread Stephen Hemminger
On Sat, 29 Sep 2018 14:52:56 +0200
Stephen Hemminger  wrote:

> Similar to other patches from ERic.
> 
> As diagnosed by Song Liu, ndo_poll_controller() can
> be very dangerous on loaded hosts, since the cpu
> calling ndo_poll_controller() might steal all NAPI
> contexts (for all RX/TX queues of the NIC). This capture
> can last for unlimited amount of time, since one
> cpu is generally not able to drain all the queues under load.
> 
> In netvsc driver it uses NAPI for TX completions. The default
> poll_napi will do this for us now and avoid the capture.
> 
> Signed-off-by: Stephen Hemminger 
> Cc: Haiyang Zhang 
> Cc: Eric Dumazet 

Forgot to label this, it is for net-next.



[PATCH] hv_netvsc: remove ndo_poll_controller

2018-09-29 Thread Stephen Hemminger
Similar to other patches from ERic.

As diagnosed by Song Liu, ndo_poll_controller() can
be very dangerous on loaded hosts, since the cpu
calling ndo_poll_controller() might steal all NAPI
contexts (for all RX/TX queues of the NIC). This capture
can last for unlimited amount of time, since one
cpu is generally not able to drain all the queues under load.

In netvsc driver it uses NAPI for TX completions. The default
poll_napi will do this for us now and avoid the capture.

Signed-off-by: Stephen Hemminger 
Cc: Haiyang Zhang 
Cc: Eric Dumazet 
---
 drivers/net/hyperv/netvsc_drv.c | 23 ---
 1 file changed, 23 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index ec699741170b..d7f843463bf2 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -1564,26 +1564,6 @@ netvsc_set_rxnfc(struct net_device *ndev, struct 
ethtool_rxnfc *info)
return -EOPNOTSUPP;
 }
 
-#ifdef CONFIG_NET_POLL_CONTROLLER
-static void netvsc_poll_controller(struct net_device *dev)
-{
-   struct net_device_context *ndc = netdev_priv(dev);
-   struct netvsc_device *ndev;
-   int i;
-
-   rcu_read_lock();
-   ndev = rcu_dereference(ndc->nvdev);
-   if (ndev) {
-   for (i = 0; i < ndev->num_chn; i++) {
-   struct netvsc_channel *nvchan = &ndev->chan_table[i];
-
-   napi_schedule(&nvchan->napi);
-   }
-   }
-   rcu_read_unlock();
-}
-#endif
-
 static u32 netvsc_get_rxfh_key_size(struct net_device *dev)
 {
return NETVSC_HASH_KEYLEN;
@@ -1811,9 +1791,6 @@ static const struct net_device_ops device_ops = {
.ndo_set_mac_address =  netvsc_set_mac_addr,
.ndo_select_queue = netvsc_select_queue,
.ndo_get_stats64 =  netvsc_get_stats64,
-#ifdef CONFIG_NET_POLL_CONTROLLER
-   .ndo_poll_controller =  netvsc_poll_controller,
-#endif
 };
 
 /*
-- 
2.17.1



[net-next, PATCH 0/2, v3] net: socionext: XDP support

2018-09-29 Thread Ilias Apalodimas
This patch series adds AF_XDP support socionext netsec driver
In addition the new dma allocation scheme offers a 10% boost on Rx
pps rate using 64b packets

- patch [1/2]: Use a different allocation scheme for Rx DMA buffers to 
  prepare the driver for AF_XDP support
- patch [2/2]: Add XDP support without zero-copy

test and performance numbers (64b packets):
---
- Normal SKBs on Rx: ~217kpps
test: pktgen -> intel i210 -> netsec -> XDP_TX/XDP_REDIRECT
- XDP_TX: 320kpps
- XDP_REDIRECT: 320kpps

qemu -> pktgen -> virtio -> ndo_xdp_xmit -> netsec
- ndo_xdp_xmit: Could not send more than 120kpps. Interface forwarded that 
with success

Changes since v2:
 - Always allocate Rx buffers with XDP_PACKET_HEADROOM
 
 Björn Töpel:
 - Added locking in the Tx queue

 Jesper Dangaard Brouer:
 - Added support for .ndo_xdp_xmit
 - XDP_TX does not flush every packet

Changes since v1:
- patch [2/2]:
 Toshiaki Makita:
 - Added XDP_PACKET_HEADROOM
 - Fixed a bug on XDP_PASS case
 - Using extact for error messaging instead of netdev_warn, when
   trying to setup XDP

Ilias Apalodimas (2):
  net: socionext: different approach on DMA
  net: socionext: add XDP support

 drivers/net/ethernet/socionext/netsec.c | 541 +---
 1 file changed, 426 insertions(+), 115 deletions(-)

-- 
2.7.4



[net-next, PATCH 2/2, v3] net: socionext: add XDP support

2018-09-29 Thread Ilias Apalodimas
Add basic XDP support. The interface only supports 1 Tx queue for now
so locking is introduced on the Tx queue if XDP is enabled to make sure
.ndo_start_xmit and .ndo_xdp_xmit won't corrupt Tx ring

Signed-off-by: Ilias Apalodimas 
---
 drivers/net/ethernet/socionext/netsec.c | 345 +---
 1 file changed, 318 insertions(+), 27 deletions(-)

diff --git a/drivers/net/ethernet/socionext/netsec.c 
b/drivers/net/ethernet/socionext/netsec.c
index 8f788a1..2b29363 100644
--- a/drivers/net/ethernet/socionext/netsec.c
+++ b/drivers/net/ethernet/socionext/netsec.c
@@ -9,6 +9,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 #include 
 #include 
@@ -238,6 +241,15 @@
 
 #define NETSEC_F_NETSEC_VER_MAJOR_NUM(x)   ((x) & 0x)
 
+#define NETSEC_XDP_PASS  0
+#define NETSEC_XDP_CONSUMED  BIT(0)
+#define NETSEC_XDP_TXBIT(1)
+#define NETSEC_XDP_REDIR BIT(2)
+#define NETSEC_XDP_RX_OK (NETSEC_XDP_PASS | NETSEC_XDP_TX | NETSEC_XDP_REDIR)
+
+#define NETSEC_RXBUF_HEADROOM (max(XDP_PACKET_HEADROOM, NET_SKB_PAD) + \
+  NET_IP_ALIGN)
+
 enum ring_id {
NETSEC_RING_TX = 0,
NETSEC_RING_RX
@@ -256,11 +268,16 @@ struct netsec_desc_ring {
void *vaddr;
u16 pkt_cnt;
u16 head, tail;
+   u16 xdp_xmit; /* netsec_xdp_xmit packets */
+   bool is_xdp;
+   struct xdp_rxq_info xdp_rxq;
+   spinlock_t lock; /* XDP tx queue locking */
 };
 
 struct netsec_priv {
struct netsec_desc_ring desc_ring[NETSEC_RING_MAX];
struct ethtool_coalesce et_coalesce;
+   struct bpf_prog *xdp_prog;
spinlock_t reglock; /* protect reg access */
struct napi_struct napi;
phy_interface_t phy_interface;
@@ -297,6 +314,8 @@ struct netsec_rx_pkt_info {
 };
 
 static void netsec_rx_fill(struct netsec_priv *priv, u16 from, u16 num);
+static u32 netsec_run_xdp(struct netsec_priv *priv, struct bpf_prog *prog,
+ struct xdp_buff *xdp);
 
 static void *netsec_alloc_rx_data(struct netsec_priv *priv,
  dma_addr_t *dma_addr, u16 *len);
@@ -590,6 +609,8 @@ static int netsec_clean_tx_dring(struct netsec_priv *priv, 
int budget)
struct netsec_desc_ring *dring = &priv->desc_ring[NETSEC_RING_TX];
unsigned int pkts, bytes;
 
+   if (dring->is_xdp)
+   spin_lock(&dring->lock);
dring->pkt_cnt += netsec_read(priv, NETSEC_REG_NRM_TX_DONE_PKTCNT);
 
if (dring->pkt_cnt < budget)
@@ -615,13 +636,23 @@ static int netsec_clean_tx_dring(struct netsec_priv 
*priv, int budget)
 
dma_unmap_single(priv->dev, desc->dma_addr, desc->len,
 DMA_TO_DEVICE);
-   if (eop) {
-   pkts++;
+
+   if (!eop) {
+   *desc = (struct netsec_desc){};
+   continue;
+   }
+
+   if (!desc->skb) {
+   skb_free_frag(desc->addr);
+   } else {
bytes += desc->skb->len;
dev_kfree_skb(desc->skb);
}
+   pkts++;
*desc = (struct netsec_desc){};
}
+   if (dring->is_xdp)
+   spin_unlock(&dring->lock);
dring->pkt_cnt -= budget;
 
priv->ndev->stats.tx_packets += budget;
@@ -656,11 +687,30 @@ static void netsec_adv_desc(u16 *idx)
*idx = 0;
 }
 
+static void netsec_xdp_ring_tx_db(struct netsec_priv *priv, u16 pkts)
+{
+   if (likely(pkts))
+   netsec_write(priv, NETSEC_REG_NRM_TX_PKTCNT, pkts);
+}
+
+static void netsec_finalize_xdp_rx(struct netsec_priv *priv, u32 xdp_res,
+  u16 pkts)
+{
+   if (xdp_res & NETSEC_XDP_REDIR)
+   xdp_do_flush_map();
+
+   if (xdp_res & NETSEC_XDP_TX)
+   netsec_xdp_ring_tx_db(priv, pkts);
+}
+
 static int netsec_process_rx(struct netsec_priv *priv, int budget)
 {
struct netsec_desc_ring *dring = &priv->desc_ring[NETSEC_RING_RX];
+   struct bpf_prog *xdp_prog = READ_ONCE(priv->xdp_prog);
struct net_device *ndev = priv->ndev;
-   struct sk_buff *skb;
+   struct sk_buff *skb = NULL;
+   u16 xdp_xmit = 0;
+   u32 xdp_act = 0;
int done = 0;
 
while (done < budget) {
@@ -668,8 +718,10 @@ static int netsec_process_rx(struct netsec_priv *priv, int 
budget)
struct netsec_de *de = dring->vaddr + (DESC_SZ * idx);
struct netsec_desc *desc = &dring->desc[idx];
struct netsec_rx_pkt_info rpi;
-   u16 pkt_len, desc_len;
+   u32 xdp_result = XDP_PASS;
dma_addr_t dma_handle;
+   u16 pkt_len, desc_len;
+   struct xdp_buff xdp;
void *buf_addr;
 
if (de->attr & (1U << NETSEC_RX_PKT_OWN_FIELD))
@@ -706,7 +758,23 @@ 

[net-next, PATCH 1/2, v3] net: socionext: different approach on DMA

2018-09-29 Thread Ilias Apalodimas
Current driver dynamically allocates an skb and maps it as DMA rx buffer.
A following patch introduces XDP functionality, so we need a
different allocation scheme. Buffers are allocated dynamically and
mapped into hardware. During the Rx operation the driver uses
build_skb() to produce the necessary buffers for the network stack

Signed-off-by: Ilias Apalodimas 
---
 drivers/net/ethernet/socionext/netsec.c | 238 +---
 1 file changed, 129 insertions(+), 109 deletions(-)

diff --git a/drivers/net/ethernet/socionext/netsec.c 
b/drivers/net/ethernet/socionext/netsec.c
index 7aa5ebb..8f788a1 100644
--- a/drivers/net/ethernet/socionext/netsec.c
+++ b/drivers/net/ethernet/socionext/netsec.c
@@ -296,6 +296,11 @@ struct netsec_rx_pkt_info {
bool err_flag;
 };
 
+static void netsec_rx_fill(struct netsec_priv *priv, u16 from, u16 num);
+
+static void *netsec_alloc_rx_data(struct netsec_priv *priv,
+ dma_addr_t *dma_addr, u16 *len);
+
 static void netsec_write(struct netsec_priv *priv, u32 reg_addr, u32 val)
 {
writel(val, priv->ioaddr + reg_addr);
@@ -556,34 +561,10 @@ static const struct ethtool_ops netsec_ethtool_ops = {
 
 /* NETDEV_OPS FOLLOW */
 
-static struct sk_buff *netsec_alloc_skb(struct netsec_priv *priv,
-   struct netsec_desc *desc)
-{
-   struct sk_buff *skb;
-
-   if (device_get_dma_attr(priv->dev) == DEV_DMA_COHERENT) {
-   skb = netdev_alloc_skb_ip_align(priv->ndev, desc->len);
-   } else {
-   desc->len = L1_CACHE_ALIGN(desc->len);
-   skb = netdev_alloc_skb(priv->ndev, desc->len);
-   }
-   if (!skb)
-   return NULL;
-
-   desc->addr = skb->data;
-   desc->dma_addr = dma_map_single(priv->dev, desc->addr, desc->len,
-   DMA_FROM_DEVICE);
-   if (dma_mapping_error(priv->dev, desc->dma_addr)) {
-   dev_kfree_skb_any(skb);
-   return NULL;
-   }
-   return skb;
-}
 
 static void netsec_set_rx_de(struct netsec_priv *priv,
 struct netsec_desc_ring *dring, u16 idx,
-const struct netsec_desc *desc,
-struct sk_buff *skb)
+const struct netsec_desc *desc)
 {
struct netsec_de *de = dring->vaddr + DESC_SZ * idx;
u32 attr = (1 << NETSEC_RX_PKT_OWN_FIELD) |
@@ -602,59 +583,6 @@ static void netsec_set_rx_de(struct netsec_priv *priv,
dring->desc[idx].dma_addr = desc->dma_addr;
dring->desc[idx].addr = desc->addr;
dring->desc[idx].len = desc->len;
-   dring->desc[idx].skb = skb;
-}
-
-static struct sk_buff *netsec_get_rx_de(struct netsec_priv *priv,
-   struct netsec_desc_ring *dring,
-   u16 idx,
-   struct netsec_rx_pkt_info *rxpi,
-   struct netsec_desc *desc, u16 *len)
-{
-   struct netsec_de de = {};
-
-   memcpy(&de, dring->vaddr + DESC_SZ * idx, DESC_SZ);
-
-   *len = de.buf_len_info >> 16;
-
-   rxpi->err_flag = (de.attr >> NETSEC_RX_PKT_ER_FIELD) & 1;
-   rxpi->rx_cksum_result = (de.attr >> NETSEC_RX_PKT_CO_FIELD) & 3;
-   rxpi->err_code = (de.attr >> NETSEC_RX_PKT_ERR_FIELD) &
-   NETSEC_RX_PKT_ERR_MASK;
-   *desc = dring->desc[idx];
-   return desc->skb;
-}
-
-static struct sk_buff *netsec_get_rx_pkt_data(struct netsec_priv *priv,
- struct netsec_rx_pkt_info *rxpi,
- struct netsec_desc *desc,
- u16 *len)
-{
-   struct netsec_desc_ring *dring = &priv->desc_ring[NETSEC_RING_RX];
-   struct sk_buff *tmp_skb, *skb = NULL;
-   struct netsec_desc td;
-   int tail;
-
-   *rxpi = (struct netsec_rx_pkt_info){};
-
-   td.len = priv->ndev->mtu + 22;
-
-   tmp_skb = netsec_alloc_skb(priv, &td);
-
-   tail = dring->tail;
-
-   if (!tmp_skb) {
-   netsec_set_rx_de(priv, dring, tail, &dring->desc[tail],
-dring->desc[tail].skb);
-   } else {
-   skb = netsec_get_rx_de(priv, dring, tail, rxpi, desc, len);
-   netsec_set_rx_de(priv, dring, tail, &td, tmp_skb);
-   }
-
-   /* move tail ahead */
-   dring->tail = (dring->tail + 1) % DESC_NUM;
-
-   return skb;
 }
 
 static int netsec_clean_tx_dring(struct netsec_priv *priv, int budget)
@@ -721,19 +649,28 @@ static int netsec_process_tx(struct netsec_priv *priv, 
int budget)
return done;
 }
 
+static void netsec_adv_desc(u16 *idx)
+{
+   *idx = *idx + 1;
+   if (unlikely(*idx >= DESC_NUM))
+   *idx = 0;
+}
+
 static int netsec_process_rx(stru

[PATCH] net: dsa: lantiq: Fix path in MAINTAINERS file

2018-09-29 Thread Hauke Mehrtens
The MAINTAINERS file contained the wrong file name of the driver.

Fixes: 14fceff4771e ("net: dsa: Add Lantiq / Intel DSA driver for vrx200")
Reported-by: Joe Perches 
Signed-off-by: Hauke Mehrtens 
---
 MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 7233a9ed0f5b..d3c24f3fcec9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8190,7 +8190,7 @@ S:Maintained
 F: net/dsa/tag_gswip.c
 F: drivers/net/ethernet/lantiq_xrx200.c
 F: drivers/net/dsa/lantiq_pce.h
-F: drivers/net/dsa/intel_gswip.c
+F: drivers/net/dsa/lantiq_gswip.c
 
 LANTIQ MIPS ARCHITECTURE
 M: John Crispin 
-- 
2.11.0



Re: [PATCH net-next] geneve: fix ttl inherit type

2018-09-29 Thread Hangbin Liu
Hi David Ahern,
On Fri, Sep 28, 2018 at 11:59:37AM -0600, David Ahern wrote:
> On 9/27/18 7:09 PM, Hangbin Liu wrote:
> > Phil pointed out that there is a mismatch between vxlan and geneve ttl
> > inherit. We should define it as a flag and use nla_put_flag to export this
> > opiton.
> > 
> > Fixes: 52d0d404d39dd ("geneve: add ttl inherit support")
> 
> same here .. getting an unknown commit id.

This one targets to kernel net-next tree.

But as Michal suggested. We can leave geneve ttl inherit as NLA_U8 to
be able set/unset it. I will re-consider this patch.

Thanks
Hangbin


Re: [PATCH net-next] geneve: fix ttl inherit type

2018-09-29 Thread Hangbin Liu
On Sat, Sep 29, 2018 at 01:46:19AM +0200, Michal Kubecek wrote:
> On Fri, Sep 28, 2018 at 09:09:58AM +0800, Hangbin Liu wrote:
> > Phil pointed out that there is a mismatch between vxlan and geneve ttl
> > inherit. We should define it as a flag and use nla_put_flag to export this
> > opiton.
> > 
> > Fixes: 52d0d404d39dd ("geneve: add ttl inherit support")
> > Reported-by: Phil Sutter 
> > Signed-off-by: Hangbin Liu 
> > ---
> >  drivers/net/geneve.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
> > index 6625fab..09ab2fd 100644
> > --- a/drivers/net/geneve.c
> > +++ b/drivers/net/geneve.c
> > @@ -1100,7 +1100,7 @@ static const struct nla_policy 
> > geneve_policy[IFLA_GENEVE_MAX + 1] = {
> > [IFLA_GENEVE_UDP_CSUM]  = { .type = NLA_U8 },
> > [IFLA_GENEVE_UDP_ZERO_CSUM6_TX] = { .type = NLA_U8 },
> > [IFLA_GENEVE_UDP_ZERO_CSUM6_RX] = { .type = NLA_U8 },
> > -   [IFLA_GENEVE_TTL_INHERIT]   = { .type = NLA_U8 },
> > +   [IFLA_GENEVE_TTL_INHERIT]   = { .type = NLA_FLAG },
> >  };
> >  
> >  static int geneve_validate(struct nlattr *tb[], struct nlattr *data[],
> > @@ -1582,7 +1582,7 @@ static size_t geneve_get_size(const struct net_device 
> > *dev)
> > nla_total_size(sizeof(__u8)) + /* IFLA_GENEVE_UDP_CSUM */
> > nla_total_size(sizeof(__u8)) + /* IFLA_GENEVE_UDP_ZERO_CSUM6_TX 
> > */
> > nla_total_size(sizeof(__u8)) + /* IFLA_GENEVE_UDP_ZERO_CSUM6_RX 
> > */
> > -   nla_total_size(sizeof(__u8)) + /* IFLA_GENEVE_TTL_INHERIT */
> > +   nla_total_size(0) + /* IFLA_GENEVE_TTL_INHERIT */
> > 0;
> >  }
> >  
> > @@ -1636,7 +1636,7 @@ static int geneve_fill_info(struct sk_buff *skb, 
> > const struct net_device *dev)
> > goto nla_put_failure;
> >  #endif
> >  
> > -   if (nla_put_u8(skb, IFLA_GENEVE_TTL_INHERIT, ttl_inherit))
> > +   if (ttl_inherit && nla_put_flag(skb, IFLA_GENEVE_TTL_INHERIT))
> > goto nla_put_failure;
> >  
> > return 0;
> 

Hi Michal,

> Is it desirable to switch to a flag? If I read geneve_changelink() and
> geneve_nl2info() correctly, it allows you to set the ttl_inherit flag
> for an existing device but doesn't allow you to clear it. With NLA_U8,
> you could distinguish three cases: set the flag (non-zero value), clear
> the flag (zero value) and preserve current state (attribute not
> present).

I re-read geneve_changelink() and I agree with you. Since we can change ttl
number, we should also be able to set/unset ttl inherit.

Phil, what do you think?

> The same problem exists for vxlan but vxlan code intentionally disallows
> changing the flag value for an existing device (I'm not sure if it's
> because it's really impossible or just due to limits of the interface).

I will re-read VXLAN RFC to confirm this.

> Unfortunately it has been already released with NLA_FLAG in 4.18,
> AFAICS, so we have to live with it. But it's not too late for geneve.

Thanks
Hangbin


Re: [PATCH net] vxlan: use nla_put_flag for ttl inherit

2018-09-29 Thread Hangbin Liu
On Fri, Sep 28, 2018 at 11:56:10AM -0600, David Ahern wrote:
> On 9/28/18 6:38 AM, Hangbin Liu wrote:
> > On Fri, Sep 28, 2018 at 12:37:00PM +0200, Phil Sutter wrote:
> >> On Fri, Sep 28, 2018 at 09:08:26AM +0800, Hangbin Liu wrote:
> >>> Phil pointed out that there is a mismatch between vxlan and geneve ttl 
> >>> inherit.
> >>> We should define it as a flag and use nla_put_flag to export this opiton.
> >>
> >> s/opiton/option/
> >>
> >> Apart from that, LGTM!
> >>
> >> Thanks, Phil
> > 
> > Opps, sorry...
> > 
> > Hi David,
> > 
> > Should I re-send a patch or will you help fix it directly?
> > 
> > Thanks
> > Hangbin
> > 
> 
> you have this targeted at net; is it a bug in current iproute2 or an
> update to a new feature in -next?

Hi David Ahern,

This patch targets to kernel net tree. The previous question is for
"David Miller". Sorry for the confusing. Anyway, I will send a v2 patch
for this one as I need to change the commit message.

Thanks
Hangbin