* [net-next RFC 1/4] bindtosubnet: infrastructure
From: Gilberto Bertin @ 2016-03-16 13:19 UTC (permalink / raw)
To: netdev; +Cc: Gilberto Bertin
In-Reply-To: <1458134349-2454-1-git-send-email-gilberto.bertin@gmail.com>
Signed-off-by: Gilberto Bertin <gilberto.bertin@gmail.com>
---
include/net/sock.h | 20 +++++++
include/uapi/asm-generic/socket.h | 1 +
net/core/sock.c | 111 ++++++++++++++++++++++++++++++++++++++
3 files changed, 132 insertions(+)
diff --git a/include/net/sock.h b/include/net/sock.h
index f5ea148..c115c48 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -109,6 +109,16 @@ typedef struct {
#endif
} socket_lock_t;
+struct ipv4_subnet {
+ __be32 net;
+ u_char plen;
+};
+
+struct ipv6_subnet {
+ struct in6_addr net;
+ u_char plen;
+};
+
struct sock;
struct proto;
struct net;
@@ -176,6 +186,13 @@ struct sock_common {
unsigned char skc_ipv6only:1;
unsigned char skc_net_refcnt:1;
int skc_bound_dev_if;
+
+ unsigned char skc_bind_to_subnet;
+ union {
+ struct ipv4_subnet skc_bind_subnet4;
+ struct ipv6_subnet skc_bind_subnet6;
+ };
+
union {
struct hlist_node skc_bind_node;
struct hlist_nulls_node skc_portaddr_node;
@@ -327,6 +344,9 @@ struct sock {
#define sk_state __sk_common.skc_state
#define sk_reuse __sk_common.skc_reuse
#define sk_reuseport __sk_common.skc_reuseport
+#define sk_bind_to_subnet __sk_common.skc_bind_to_subnet
+#define sk_bind_subnet4 __sk_common.skc_bind_subnet4
+#define sk_bind_subnet6 __sk_common.skc_bind_subnet6
#define sk_ipv6only __sk_common.skc_ipv6only
#define sk_net_refcnt __sk_common.skc_net_refcnt
#define sk_bound_dev_if __sk_common.skc_bound_dev_if
diff --git a/include/uapi/asm-generic/socket.h b/include/uapi/asm-generic/socket.h
index fb8a416..b4bcac2 100644
--- a/include/uapi/asm-generic/socket.h
+++ b/include/uapi/asm-generic/socket.h
@@ -30,6 +30,7 @@
#define SO_SNDLOWAT 19
#define SO_RCVTIMEO 20
#define SO_SNDTIMEO 21
+#define SO_BINDTOSUBNET 22
#endif
/* Security levels - as per NRL IPv6 - don't actually do anything */
diff --git a/net/core/sock.c b/net/core/sock.c
index 6c1c8bc..7626153 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -571,6 +571,68 @@ out:
return ret;
}
+static int sock_setbindtosubnet(struct sock *sk, char __user *optval,
+ int optlen)
+{
+ int ret = -ENOPROTOOPT;
+
+ if (sk->sk_family == AF_INET) {
+ struct ipv4_subnet bind_subnet4;
+
+ ret = -EFAULT;
+ if (optlen != sizeof(struct ipv4_subnet))
+ goto out;
+
+ if (copy_from_user(&bind_subnet4, optval,
+ sizeof(struct ipv4_subnet)))
+ goto out;
+
+ ret = -EINVAL;
+ if (bind_subnet4.plen > 32)
+ goto out;
+
+ lock_sock(sk);
+
+ sk->sk_bind_to_subnet = 1;
+ sk->sk_bind_subnet4.net = bind_subnet4.net;
+ sk->sk_bind_subnet4.plen = bind_subnet4.plen;
+ sk_dst_reset(sk);
+
+ release_sock(sk);
+
+ ret = 0;
+ } else if (sk->sk_family == AF_INET6) {
+ struct ipv6_subnet bind_subnet6;
+
+ ret = -EFAULT;
+ if (optlen != sizeof(struct ipv6_subnet))
+ goto out;
+
+ if (copy_from_user(&bind_subnet6, optval,
+ sizeof(struct ipv6_subnet)))
+ goto out;
+
+ ret = -EINVAL;
+ if (bind_subnet6.plen > 128)
+ goto out;
+
+ lock_sock(sk);
+
+ sk->sk_bind_to_subnet = 1;
+ memcpy(&sk->sk_bind_subnet6.net, &bind_subnet6.net,
+ sizeof(struct in6_addr));
+ sk->sk_bind_subnet6.plen = bind_subnet6.plen;
+ sk_dst_reset(sk);
+
+ release_sock(sk);
+
+ ret = 0;
+ }
+
+out:
+ return ret;
+}
+
static int sock_getbindtodevice(struct sock *sk, char __user *optval,
int __user *optlen, int len)
{
@@ -611,6 +673,49 @@ out:
return ret;
}
+static int sock_getbindtosubnet(struct sock *sk, char __user *optval,
+ int __user *optlen, int len)
+{
+ int ret;
+
+ if (sk->sk_bind_to_subnet == 0) {
+ len = 0;
+ goto zero;
+ }
+
+ if (sk->sk_family == AF_INET) {
+ ret = -EINVAL;
+ if (len < sizeof(struct ipv4_subnet))
+ goto out;
+
+ len = sizeof(struct ipv4_subnet);
+
+ ret = -EFAULT;
+ if (copy_to_user(optval, &sk->sk_bind_subnet4, len))
+ goto out;
+
+ } else if (sk->sk_family == AF_INET6) {
+ ret = -EINVAL;
+ if (len < sizeof(struct ipv6_subnet))
+ goto out;
+
+ len = sizeof(struct ipv6_subnet);
+
+ ret = -EFAULT;
+ if (copy_to_user(optval, &sk->sk_bind_subnet6, len))
+ goto out;
+ }
+
+zero:
+ ret = -EFAULT;
+ if (put_user(len, optlen))
+ goto out;
+
+ ret = 0;
+out:
+ return ret;
+}
+
static inline void sock_valbool_flag(struct sock *sk, int bit, int valbool)
{
if (valbool)
@@ -659,6 +764,9 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
if (optname == SO_BINDTODEVICE)
return sock_setbindtodevice(sk, optval, optlen);
+ else if (optname == SO_BINDTOSUBNET)
+ return sock_setbindtosubnet(sk, optval, optlen);
+
if (optlen < sizeof(int))
return -EINVAL;
@@ -1214,6 +1322,9 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
case SO_BINDTODEVICE:
return sock_getbindtodevice(sk, optval, optlen, len);
+ case SO_BINDTOSUBNET:
+ return sock_getbindtosubnet(sk, optval, optlen, len);
+
case SO_GET_FILTER:
len = sk_get_filter(sk, (struct sock_filter __user *)optval, len);
if (len < 0)
--
2.7.2
^ permalink raw reply related
* [net-next RFC 2/4] bindtosubnet: TCP/IPv4 implementation
From: Gilberto Bertin @ 2016-03-16 13:19 UTC (permalink / raw)
To: netdev; +Cc: Gilberto Bertin
In-Reply-To: <1458134349-2454-1-git-send-email-gilberto.bertin@gmail.com>
Signed-off-by: Gilberto Bertin <gilberto.bertin@gmail.com>
---
net/ipv4/inet_connection_sock.c | 20 +++++++++++++++++++-
net/ipv4/inet_hashtables.c | 9 +++++++++
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index 6414891..0a3777c 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -15,6 +15,7 @@
#include <linux/module.h>
#include <linux/jhash.h>
+#include <linux/inetdevice.h>
#include <net/inet_connection_sock.h>
#include <net/inet_hashtables.h>
@@ -43,6 +44,22 @@ void inet_get_local_port_range(struct net *net, int *low, int *high)
}
EXPORT_SYMBOL(inet_get_local_port_range);
+static inline int inet_csk_bind_subnet_conflict(const struct sock *sk,
+ const struct sock *sk2)
+{
+ __be32 mask;
+
+ if (sk->sk_bind_to_subnet && sk2->sk_bind_to_subnet) {
+ mask = inet_make_mask(min(sk->sk_bind_subnet4.plen,
+ sk2->sk_bind_subnet4.plen));
+
+ return (sk->sk_bind_subnet4.net & mask) ==
+ (sk2->sk_bind_subnet4.net & mask);
+ }
+
+ return 0;
+}
+
int inet_csk_bind_conflict(const struct sock *sk,
const struct inet_bind_bucket *tb, bool relax)
{
@@ -63,7 +80,8 @@ int inet_csk_bind_conflict(const struct sock *sk,
!inet_v6_ipv6only(sk2) &&
(!sk->sk_bound_dev_if ||
!sk2->sk_bound_dev_if ||
- sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
+ sk->sk_bound_dev_if == sk2->sk_bound_dev_if) &&
+ inet_csk_bind_subnet_conflict(sk, sk2)) {
if ((!reuse || !sk2->sk_reuse ||
sk2->sk_state == TCP_LISTEN) &&
(!reuseport || !sk2->sk_reuseport ||
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index ccc5980..1a0229c 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -13,6 +13,7 @@
* 2 of the License, or (at your option) any later version.
*/
+#include <linux/inetdevice.h>
#include <linux/module.h>
#include <linux/random.h>
#include <linux/sched.h>
@@ -189,6 +190,14 @@ static inline int compute_score(struct sock *sk, struct net *net,
return -1;
score += 4;
}
+ if (sk->sk_bind_to_subnet) {
+ __be32 mask = inet_make_mask(sk->sk_bind_subnet4.plen);
+
+ if ((sk->sk_bind_subnet4.net & mask) != (daddr & mask))
+ return -1;
+ score += 4;
+ }
+
if (sk->sk_incoming_cpu == raw_smp_processor_id())
score++;
}
--
2.7.2
^ permalink raw reply related
* [net-next RFC 4/4] bindtosubnet: UPD implementation
From: Gilberto Bertin @ 2016-03-16 13:19 UTC (permalink / raw)
To: netdev; +Cc: Gilberto Bertin
In-Reply-To: <1458134349-2454-1-git-send-email-gilberto.bertin@gmail.com>
Signed-off-by: Gilberto Bertin <gilberto.bertin@gmail.com>
---
net/ipv4/udp.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 95d2f19..1ecffa8 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -133,6 +133,23 @@ EXPORT_SYMBOL(udp_memory_allocated);
#define MAX_UDP_PORTS 65536
#define PORTS_PER_CHAIN (MAX_UDP_PORTS / UDP_HTABLE_SIZE_MIN)
+static inline int udp_csk_bind_subnet_conflict(const struct sock *sk,
+ const struct sock *sk2)
+{
+ __be32 mask;
+
+ if (sk->sk_bind_to_subnet && sk2->sk_bind_to_subnet) {
+ mask = inet_make_mask(min(sk->sk_bind_subnet4.plen,
+ sk2->sk_bind_subnet4.plen));
+
+ return (sk->sk_bind_subnet4.net & mask) ==
+ (sk2->sk_bind_subnet4.net & mask);
+ }
+
+ return 0;
+}
+
+
static int udp_lib_lport_inuse(struct net *net, __u16 num,
const struct udp_hslot *hslot,
unsigned long *bitmap,
@@ -153,6 +170,7 @@ static int udp_lib_lport_inuse(struct net *net, __u16 num,
(!sk2->sk_reuse || !sk->sk_reuse) &&
(!sk2->sk_bound_dev_if || !sk->sk_bound_dev_if ||
sk2->sk_bound_dev_if == sk->sk_bound_dev_if) &&
+ udp_csk_bind_subnet_conflict(sk, sk2) &&
(!sk2->sk_reuseport || !sk->sk_reuseport ||
rcu_access_pointer(sk->sk_reuseport_cb) ||
!uid_eq(uid, sock_i_uid(sk2))) &&
@@ -189,6 +207,7 @@ static int udp_lib_lport_inuse2(struct net *net, __u16 num,
(!sk2->sk_reuse || !sk->sk_reuse) &&
(!sk2->sk_bound_dev_if || !sk->sk_bound_dev_if ||
sk2->sk_bound_dev_if == sk->sk_bound_dev_if) &&
+ udp_csk_bind_subnet_conflict(sk, sk2) &&
(!sk2->sk_reuseport || !sk->sk_reuseport ||
rcu_access_pointer(sk->sk_reuseport_cb) ||
!uid_eq(uid, sock_i_uid(sk2))) &&
@@ -426,6 +445,15 @@ static inline int compute_score(struct sock *sk, struct net *net,
return -1;
score += 4;
}
+
+ if (sk->sk_bind_to_subnet) {
+ __be32 mask = inet_make_mask(sk->sk_bind_subnet4.plen);
+
+ if ((sk->sk_bind_subnet4.net & mask) != (daddr & mask))
+ return -1;
+ score += 4;
+ }
+
if (sk->sk_incoming_cpu == raw_smp_processor_id())
score++;
return score;
@@ -471,6 +499,14 @@ static inline int compute_score2(struct sock *sk, struct net *net,
score += 4;
}
+ if (sk->sk_bind_to_subnet) {
+ __be32 mask = inet_make_mask(sk->sk_bind_subnet4.plen);
+
+ if ((sk->sk_bind_subnet4.net & mask) != (daddr & mask))
+ return -1;
+ score += 4;
+ }
+
if (sk->sk_incoming_cpu == raw_smp_processor_id())
score++;
--
2.7.2
^ permalink raw reply related
* [net-next RFC 3/4] bindtosubnet: TCP/IPv6 implementation
From: Gilberto Bertin @ 2016-03-16 13:19 UTC (permalink / raw)
To: netdev; +Cc: Gilberto Bertin
In-Reply-To: <1458134349-2454-1-git-send-email-gilberto.bertin@gmail.com>
Signed-off-by: Gilberto Bertin <gilberto.bertin@gmail.com>
---
net/ipv6/inet6_connection_sock.c | 17 ++++++++++++++++-
net/ipv6/inet6_hashtables.c | 6 ++++++
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/net/ipv6/inet6_connection_sock.c b/net/ipv6/inet6_connection_sock.c
index 36c3f01..288bab6 100644
--- a/net/ipv6/inet6_connection_sock.c
+++ b/net/ipv6/inet6_connection_sock.c
@@ -27,6 +27,20 @@
#include <net/sock.h>
#include <net/inet6_connection_sock.h>
+int inet6_csk_bind_subnet_conflict(const struct sock *sk,
+ const struct sock *sk2)
+{
+ u_char plen;
+
+ plen = min(sk->sk_bind_subnet6.plen, sk2->sk_bind_subnet6.plen);
+
+ if (sk->sk_bind_to_subnet && sk2->sk_bind_to_subnet)
+ return ipv6_prefix_equal(&sk->sk_bind_subnet6.net,
+ &sk2->sk_bind_subnet6.net, plen);
+
+ return 0;
+}
+
int inet6_csk_bind_conflict(const struct sock *sk,
const struct inet_bind_bucket *tb, bool relax)
{
@@ -44,7 +58,8 @@ int inet6_csk_bind_conflict(const struct sock *sk,
if (sk != sk2 &&
(!sk->sk_bound_dev_if ||
!sk2->sk_bound_dev_if ||
- sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
+ sk->sk_bound_dev_if == sk2->sk_bound_dev_if) &&
+ inet6_csk_bind_subnet_conflict(sk, sk2)) {
if ((!reuse || !sk2->sk_reuse ||
sk2->sk_state == TCP_LISTEN) &&
(!reuseport || !sk2->sk_reuseport ||
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
index 21ace5a..e88c82d 100644
--- a/net/ipv6/inet6_hashtables.c
+++ b/net/ipv6/inet6_hashtables.c
@@ -114,6 +114,12 @@ static inline int compute_score(struct sock *sk, struct net *net,
return -1;
score++;
}
+ if (sk->sk_bind_to_subnet) {
+ if (!ipv6_prefix_equal(&sk->sk_bind_subnet6.net, daddr,
+ sk->sk_bind_subnet6.plen))
+ return -1;
+ score++;
+ }
if (sk->sk_incoming_cpu == raw_smp_processor_id())
score++;
}
--
2.7.2
^ permalink raw reply related
* Re: [PATCH 1/5] net: macb: Fix coding style error message
From: Nicolas Ferre @ 2016-03-16 13:39 UTC (permalink / raw)
To: Moritz Fischer
Cc: michal.simek, joe, davem, netdev, linux-kernel,
moritz.fischer.private
In-Reply-To: <1457896247-25934-2-git-send-email-moritz.fischer@ettus.com>
Le 13/03/2016 20:10, Moritz Fischer a écrit :
> checkpatch.pl gave the following error:
>
> ERROR: space required before the open parenthesis '('
> + for(; p < end; p++, offset += 4)
>
> Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
> ---
> drivers/net/ethernet/cadence/macb.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
> index 50c9410..4370f37 100644
> --- a/drivers/net/ethernet/cadence/macb.c
> +++ b/drivers/net/ethernet/cadence/macb.c
> @@ -496,7 +496,7 @@ static void macb_update_stats(struct macb *bp)
>
> WARN_ON((unsigned long)(end - p - 1) != (MACB_TPF - MACB_PFR) / 4);
>
> - for(; p < end; p++, offset += 4)
> + for (; p < end; p++, offset += 4)
> *p += bp->macb_reg_readl(bp, offset);
> }
>
>
--
Nicolas Ferre
^ permalink raw reply
* Re: [PATCH 0/5] net: macb: Checkpatch cleanups
From: Nicolas Ferre @ 2016-03-16 13:39 UTC (permalink / raw)
To: Moritz Fischer
Cc: michal.simek, joe, davem, netdev, linux-kernel,
moritz.fischer.private
In-Reply-To: <1457896247-25934-1-git-send-email-moritz.fischer@ettus.com>
Le 13/03/2016 20:10, Moritz Fischer a écrit :
> Hi all,
>
> I backed out the variable scope changes and made a separate
> patch for the ether_addr_copy change.
>
> Changes from v1:
As it's v2, it's better to add it in each subject of the patch series like:
"[PATCH v2 0/5] net: macb: Checkpatch cleanups"
> * Backed out variable scope changes
> * Separated out ether_addr_copy into it's own commit
> * Fixed typo in comments as suggested by Joe
>
> Cheers,
>
> Moritz
>
> Moritz Fischer (5):
> net: macb: Fix coding style error message
> net: macb: Fix coding style warnings
> net: macb: Address checkpatch 'check' suggestions
> net: macb: Use ether_addr_copy over memcpy
> net: macb: Fix simple typo.
>
> drivers/net/ethernet/cadence/macb.c | 153 +++++++++++++++++-------------------
> 1 file changed, 70 insertions(+), 83 deletions(-)
>
--
Nicolas Ferre
^ permalink raw reply
* Re: [PATCH 2/5] net: macb: Fix coding style warnings
From: Nicolas Ferre @ 2016-03-16 13:46 UTC (permalink / raw)
To: Michal Simek, Moritz Fischer
Cc: joe, davem, netdev, linux-kernel, moritz.fischer.private
In-Reply-To: <56E724BB.5030600@xilinx.com>
Le 14/03/2016 21:53, Michal Simek a écrit :
> On 13.3.2016 20:10, Moritz Fischer wrote:
>> This commit takes care of the coding style warnings
>> that are mostly due to a different comment style and
>> lines over 80 chars, as well as a dangling else.
>>
>> Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
>> ---
>> drivers/net/ethernet/cadence/macb.c | 101 +++++++++++++++---------------------
>> 1 file changed, 43 insertions(+), 58 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
>> index 4370f37..c2d31c5 100644
>> --- a/drivers/net/ethernet/cadence/macb.c
>> +++ b/drivers/net/ethernet/cadence/macb.c
>> @@ -58,8 +58,7 @@
>>
>> #define GEM_MTU_MIN_SIZE 68
>>
>> -/*
>> - * Graceful stop timeouts in us. We should allow up to
>> +/* Graceful stop timeouts in us. We should allow up to
>> * 1 frame time (10 Mbits/s, full-duplex, ignoring collisions)
>> */
>> #define MACB_HALT_TIMEOUT 1230
>> @@ -127,8 +126,7 @@ static void hw_writel(struct macb *bp, int offset, u32 value)
>> writel_relaxed(value, bp->regs + offset);
>> }
>>
>> -/*
>> - * Find the CPU endianness by using the loopback bit of NCR register. When the
>> +/* Find the CPU endianness by using the loopback bit of NCR register. When the
>
> TBH: I would rather see this converting to kernel-doc format instead of
> using this networking block.
As there is hardly any kernel-doc comments in this driver, I won't force
Moritz to move this one to it.
I would advice, if someone want to move to kernel-doc for some function
comments, to do it in a separate patch (series).
> Also splitting this to more patches will be better. Just by categories
> but that's just my opinion.
Well, yes... but I won't be too picky for such a patch. So here is my:
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Thank for your feedback, bye,
--
Nicolas Ferre
^ permalink raw reply
* Re: [PATCH 3/5] net: macb: Address checkpatch 'check' suggestions
From: Nicolas Ferre @ 2016-03-16 13:46 UTC (permalink / raw)
To: Moritz Fischer
Cc: michal.simek, joe, davem, netdev, linux-kernel,
moritz.fischer.private
In-Reply-To: <1457896247-25934-4-git-send-email-moritz.fischer@ettus.com>
Le 13/03/2016 20:10, Moritz Fischer a écrit :
> This commit deals with a bunch of checkpatch suggestions
> that without changing behavior make checkpatch happier.
>
> Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
> ---
> drivers/net/ethernet/cadence/macb.c | 46 +++++++++++++++++++------------------
> 1 file changed, 24 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
> index c2d31c5..53400f6 100644
> --- a/drivers/net/ethernet/cadence/macb.c
> +++ b/drivers/net/ethernet/cadence/macb.c
> @@ -184,7 +184,7 @@ static void macb_get_hwaddr(struct macb *bp)
>
> pdata = dev_get_platdata(&bp->pdev->dev);
>
> - /* Check all 4 address register for vaild address */
> + /* Check all 4 address register for valid address */
> for (i = 0; i < 4; i++) {
> bottom = macb_or_gem_readl(bp, SA1B + i * 8);
> top = macb_or_gem_readl(bp, SA1T + i * 8);
> @@ -292,7 +292,7 @@ static void macb_set_tx_clk(struct clk *clk, int speed, struct net_device *dev)
> ferr = DIV_ROUND_UP(ferr, rate / 100000);
> if (ferr > 5)
> netdev_warn(dev, "unable to generate target frequency: %ld Hz\n",
> - rate);
> + rate);
>
> if (clk_set_rate(clk, rate_rounded))
> netdev_err(dev, "adjusting tx_clk failed.\n");
> @@ -426,7 +426,7 @@ static int macb_mii_init(struct macb *bp)
> macb_writel(bp, NCR, MACB_BIT(MPE));
>
> bp->mii_bus = mdiobus_alloc();
> - if (bp->mii_bus == NULL) {
> + if (!bp->mii_bus) {
> err = -ENOMEM;
> goto err_out;
> }
> @@ -435,7 +435,7 @@ static int macb_mii_init(struct macb *bp)
> bp->mii_bus->read = &macb_mdio_read;
> bp->mii_bus->write = &macb_mdio_write;
> snprintf(bp->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
> - bp->pdev->name, bp->pdev->id);
> + bp->pdev->name, bp->pdev->id);
> bp->mii_bus->priv = bp;
> bp->mii_bus->parent = &bp->dev->dev;
> pdata = dev_get_platdata(&bp->pdev->dev);
> @@ -656,7 +656,7 @@ static void macb_tx_interrupt(struct macb_queue *queue)
> queue_writel(queue, ISR, MACB_BIT(TCOMP));
>
> netdev_vdbg(bp->dev, "macb_tx_interrupt status = 0x%03lx\n",
> - (unsigned long)status);
> + (unsigned long)status);
>
> head = queue->tx_head;
> for (tail = queue->tx_tail; tail != head; tail++) {
> @@ -725,10 +725,10 @@ static void gem_rx_refill(struct macb *bp)
>
> bp->rx_prepared_head++;
>
> - if (bp->rx_skbuff[entry] == NULL) {
> + if (!bp->rx_skbuff[entry]) {
> /* allocate sk_buff for this free entry in ring */
> skb = netdev_alloc_skb(bp->dev, bp->rx_buffer_size);
> - if (unlikely(skb == NULL)) {
> + if (unlikely(!skb)) {
> netdev_err(bp->dev,
> "Unable to allocate sk_buff\n");
> break;
> @@ -762,7 +762,7 @@ static void gem_rx_refill(struct macb *bp)
> wmb();
>
> netdev_vdbg(bp->dev, "rx ring: prepared head %d, tail %d\n",
> - bp->rx_prepared_head, bp->rx_tail);
> + bp->rx_prepared_head, bp->rx_tail);
> }
>
> /* Mark DMA descriptors from begin up to and not including end as unused */
> @@ -876,8 +876,8 @@ static int macb_rx_frame(struct macb *bp, unsigned int first_frag,
> len = desc->ctrl & bp->rx_frm_len_mask;
>
> netdev_vdbg(bp->dev, "macb_rx_frame frags %u - %u (len %u)\n",
> - macb_rx_ring_wrap(first_frag),
> - macb_rx_ring_wrap(last_frag), len);
> + macb_rx_ring_wrap(first_frag),
> + macb_rx_ring_wrap(last_frag), len);
>
> /* The ethernet header starts NET_IP_ALIGN bytes into the
> * first buffer. Since the header is 14 bytes, this makes the
> @@ -916,7 +916,8 @@ static int macb_rx_frame(struct macb *bp, unsigned int first_frag,
> frag_len = len - offset;
> }
> skb_copy_to_linear_data_offset(skb, offset,
> - macb_rx_buffer(bp, frag), frag_len);
> + macb_rx_buffer(bp, frag),
> + frag_len);
> offset += bp->rx_buffer_size;
> desc = macb_rx_desc(bp, frag);
> desc->addr &= ~MACB_BIT(RX_USED);
> @@ -934,7 +935,7 @@ static int macb_rx_frame(struct macb *bp, unsigned int first_frag,
> bp->stats.rx_packets++;
> bp->stats.rx_bytes += skb->len;
> netdev_vdbg(bp->dev, "received skb of length %u, csum: %08x\n",
> - skb->len, skb->csum);
> + skb->len, skb->csum);
> netif_receive_skb(skb);
>
> return 0;
> @@ -999,7 +1000,7 @@ static int macb_poll(struct napi_struct *napi, int budget)
> work_done = 0;
>
> netdev_vdbg(bp->dev, "poll: status = %08lx, budget = %d\n",
> - (unsigned long)status, budget);
> + (unsigned long)status, budget);
>
> work_done = bp->macbgem_ops.mog_rx(bp, budget);
> if (work_done < budget) {
> @@ -1214,7 +1215,7 @@ static unsigned int macb_tx_map(struct macb *bp,
> }
>
> /* Should never happen */
> - if (unlikely(tx_skb == NULL)) {
> + if (unlikely(!tx_skb)) {
> netdev_err(bp->dev, "BUG! empty skb!\n");
> return 0;
> }
> @@ -1284,16 +1285,16 @@ static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev)
>
> #if defined(DEBUG) && defined(VERBOSE_DEBUG)
> netdev_vdbg(bp->dev,
> - "start_xmit: queue %hu len %u head %p data %p tail %p end %p\n",
> - queue_index, skb->len, skb->head, skb->data,
> - skb_tail_pointer(skb), skb_end_pointer(skb));
> + "start_xmit: queue %hu len %u head %p data %p tail %p end %p\n",
> + queue_index, skb->len, skb->head, skb->data,
> + skb_tail_pointer(skb), skb_end_pointer(skb));
> print_hex_dump(KERN_DEBUG, "data: ", DUMP_PREFIX_OFFSET, 16, 1,
> skb->data, 16, true);
> #endif
>
> /* Count how many TX buffer descriptors are needed to send this
> * socket buffer: skb fragments of jumbo frames may need to be
> - * splitted into many buffer descriptors.
> + * split into many buffer descriptors.
> */
> count = DIV_ROUND_UP(skb_headlen(skb), bp->max_tx_length);
> nr_frags = skb_shinfo(skb)->nr_frags;
> @@ -1344,8 +1345,8 @@ static void macb_init_rx_buffer_size(struct macb *bp, size_t size)
>
> if (bp->rx_buffer_size % RX_BUFFER_MULTIPLE) {
> netdev_dbg(bp->dev,
> - "RX buffer must be multiple of %d bytes, expanding\n",
> - RX_BUFFER_MULTIPLE);
> + "RX buffer must be multiple of %d bytes, expanding\n",
> + RX_BUFFER_MULTIPLE);
> bp->rx_buffer_size =
> roundup(bp->rx_buffer_size, RX_BUFFER_MULTIPLE);
> }
> @@ -1368,7 +1369,7 @@ static void gem_free_rx_buffers(struct macb *bp)
> for (i = 0; i < RX_RING_SIZE; i++) {
> skb = bp->rx_skbuff[i];
>
> - if (skb == NULL)
> + if (!skb)
> continue;
>
> desc = &bp->rx_ring[i];
> @@ -1776,7 +1777,8 @@ static void macb_sethashtable(struct net_device *dev)
> unsigned int bitnr;
> struct macb *bp = netdev_priv(dev);
>
> - mc_filter[0] = mc_filter[1] = 0;
> + mc_filter[0] = 0;
> + mc_filter[1] = 0;
>
> netdev_for_each_mc_addr(ha, dev) {
> bitnr = hash_get_index(ha->addr);
>
--
Nicolas Ferre
^ permalink raw reply
* Re: [PATCH 4/5] net: macb: Use ether_addr_copy over memcpy
From: Nicolas Ferre @ 2016-03-16 13:48 UTC (permalink / raw)
To: Moritz Fischer
Cc: michal.simek, joe, davem, netdev, linux-kernel,
moritz.fischer.private
In-Reply-To: <1457896247-25934-5-git-send-email-moritz.fischer@ettus.com>
Le 13/03/2016 20:10, Moritz Fischer a écrit :
> Checkpatch suggests using ether_addr_copy over memcpy
> to copy the mac address.
>
> Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
Yes:
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
> ---
> drivers/net/ethernet/cadence/macb.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
> index 53400f6..a0c01e5 100644
> --- a/drivers/net/ethernet/cadence/macb.c
> +++ b/drivers/net/ethernet/cadence/macb.c
> @@ -2891,7 +2891,7 @@ static int macb_probe(struct platform_device *pdev)
>
> mac = of_get_mac_address(np);
> if (mac)
> - memcpy(bp->dev->dev_addr, mac, ETH_ALEN);
> + ether_addr_copy(bp->dev->dev_addr, mac);
> else
> macb_get_hwaddr(bp);
>
>
--
Nicolas Ferre
^ permalink raw reply
* Re: [PATCH 5/5] net: macb: Fix simple typo.
From: Nicolas Ferre @ 2016-03-16 13:51 UTC (permalink / raw)
To: Michal Simek, Moritz Fischer
Cc: joe, davem, netdev, linux-kernel, moritz.fischer.private
In-Reply-To: <56E7237A.10401@xilinx.com>
Le 14/03/2016 21:47, Michal Simek a écrit :
> On 13.3.2016 20:10, Moritz Fischer wrote:
>> Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
>> ---
>> drivers/net/ethernet/cadence/macb.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
>> index a0c01e5..681e5bf 100644
>> --- a/drivers/net/ethernet/cadence/macb.c
>> +++ b/drivers/net/ethernet/cadence/macb.c
>> @@ -127,7 +127,7 @@ static void hw_writel(struct macb *bp, int offset, u32 value)
>> }
>>
>> /* Find the CPU endianness by using the loopback bit of NCR register. When the
>> - * CPU is in big endian we need to program swaped mode for management
>> + * CPU is in big endian we need to program swapped mode for management
>> * descriptor access.
>> */
>> static bool hw_is_native_io(void __iomem *addr)
>>
>
> Remove dot at the end of subject and feel free to add my:
> Acked-by: Michal Simek <michal.simek@xilinx.com>
Yes, same for me, no dot. But anyway, here is my:
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Thanks Moritz for the patches and Michal for the reviews.
Bye,
--
Nicolas Ferre
^ permalink raw reply
* Re: [PATCH net-next 1/6] bridge: add rtnl_lock in fdb_flush in br_sysfs_br.c
From: Nikolay Aleksandrov @ 2016-03-16 13:55 UTC (permalink / raw)
To: Xin Long, network dev; +Cc: davem, Hannes Frederic Sowa
In-Reply-To: <059d608901fd86407fed374e567c46447aa8c88f.1458134414.git.lucien.xin@gmail.com>
On 03/16/2016 02:34 PM, Xin Long wrote:
> In fdb_delete, it will send rtnl msg, so before that, we should
> hold rtnl_lock in the function that call it in sysfs.
>
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
> ---
> net/bridge/br_sysfs_br.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
IIRC rtnl_notify() doesn't require rtnl lock to be held so this patch is not
needed
^ permalink raw reply
* Re: [PATCH] openvswitch: call only into reachable nf-nat code
From: Arnd Bergmann @ 2016-03-16 13:56 UTC (permalink / raw)
To: Pablo Neira Ayuso
Cc: dev-yBygre7rU0TnMu66kgdUjQ, netdev-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Joe Stringer, Paolo Abeni,
David S. Miller
In-Reply-To: <20160316132536.GA29550@salvia>
On Wednesday 16 March 2016 14:25:36 Pablo Neira Ayuso wrote:
> Not related with this patch, just a side note/recommendation.
>
> I understand this code just got into tree, and that this needs a bit
> work/iterations but this thing above is ugly, I wonder if there is a
> better way to avoid this.
>
> Probably with some modularization of the openvswitch code this will
> look better, I mean:
>
> 1) adding Kconfig switches to enable conntrack and NAT support to
> net/openvswitch/Kconfig.
>
> 2) Move the NAT code to the corresponding openvswitch/nat.c file.
>
> Just my two cents.
Yes, I think that would be good too. I also found that the driver
used to look like that but it was changed as part of f88f69dd17f1
("openvswitch: Remove conntrack Kconfig option.").
Arnd
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev
^ permalink raw reply
* Re: [PATCH v3 2/9] net: arc_emac: add phy reset is optional for device tree
From: Sergei Shtylyov @ 2016-03-16 13:57 UTC (permalink / raw)
To: Caesar Wang, Heiko Stuebner, David S. Miller, Rob Herring
Cc: linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
keescook-hpIqsD4AKlfQT0dZR+AlfA, leozwang-hpIqsD4AKlfQT0dZR+AlfA,
netdev-u79uwXL29TY76Z2rM5mHXA, devicetree-u79uwXL29TY76Z2rM5mHXA,
Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1457942520-12859-3-git-send-email-wxt-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
Hello.
On 3/14/2016 11:01 AM, Caesar Wang wrote:
> This patch adds the following property for arc_emac.
>
> 1) phy-reset-gpios:
> The phy-reset-gpio is an optional property for arc emac device tree boot.
> Change the binding document to match the driver code.
>
> 2) phy-reset-duration:
> Different boards may require different phy reset duration. Add property
> phy-reset-duration for device tree probe, so that the boards that need
> a longer reset duration can specify it in their device tree.
>
> Anyway, we can add the above property for arc emac.
>
> Signed-off-by: Caesar Wang <wxt-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
Could you have a look at drivers/net/ethernet/cadence/macb/? It seems to be
the only driver which places the PHY's "reset-gpios" prop correctly, into the
PHY subnode? I'm currently working on adding support of this prop into phylib...
MBR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH net-next 2/6] bridge: simplify the forward_delay_store by calling store_bridge_parm
From: Nikolay Aleksandrov @ 2016-03-16 13:58 UTC (permalink / raw)
To: Xin Long, network dev; +Cc: davem, Hannes Frederic Sowa
In-Reply-To: <f379a033c5b7798906c57dd1bb67df89b7de02cb.1458134414.git.lucien.xin@gmail.com>
On 03/16/2016 02:34 PM, Xin Long wrote:
> There are some repetitive codes in forward_delay_store, we can remove
> them by calling store_bridge_parm.
>
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
> ---
> net/bridge/br_sysfs_br.c | 27 ++++++++++-----------------
> 1 file changed, 10 insertions(+), 17 deletions(-)
>
I actually have a similar patch in my tree. :-)
Acked-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
^ permalink raw reply
* Re: [net-next 1/2] bonding: remove duplicate set of flag IFF_MULTICAST
From: Andy Gospodarek @ 2016-03-16 14:01 UTC (permalink / raw)
To: Zhang Shengju; +Cc: davem, j.vosburgh, jiri, netdev
In-Reply-To: <1458122356-25021-2-git-send-email-zhangshengju@cmss.chinamobile.com>
On Wed, Mar 16, 2016 at 09:59:15AM +0000, Zhang Shengju wrote:
> Remove unnecessary set of flag IFF_MULTICAST, since ether_setup
> already does this.
>
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
Signed-off-by: Andy Gospodarek <gospo@cumulusnetworks.com>
> ---
> drivers/net/bonding/bond_main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index b6236ff..270b39c 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -4175,7 +4175,7 @@ void bond_setup(struct net_device *bond_dev)
> SET_NETDEV_DEVTYPE(bond_dev, &bond_type);
>
> /* Initialize the device options */
> - bond_dev->flags |= IFF_MASTER|IFF_MULTICAST;
> + bond_dev->flags |= IFF_MASTER;
> bond_dev->priv_flags |= IFF_BONDING | IFF_UNICAST_FLT | IFF_NO_QUEUE;
> bond_dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING);
>
> --
> 1.8.3.1
>
>
>
^ permalink raw reply
* Re: [PATCH net-next 3/6] bridge: simplify the stp_state_store by calling store_bridge_parm
From: Nikolay Aleksandrov @ 2016-03-16 14:06 UTC (permalink / raw)
To: Xin Long, network dev; +Cc: davem, Hannes Frederic Sowa
In-Reply-To: <45f430c026ce8a2fb358c650a41452aebff9ec36.1458134414.git.lucien.xin@gmail.com>
On 03/16/2016 02:34 PM, Xin Long wrote:
> There are some repetitive codes in stp_state_store, we can remove
> them by calling store_bridge_parm.
>
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
> ---
> net/bridge/br_sysfs_br.c | 24 +++++++-----------------
> 1 file changed, 7 insertions(+), 17 deletions(-)
>
LGTM. Note: it introduces a bug (missing rtnl) until patch 04 is applied.
Acked-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
^ permalink raw reply
* Re: [RFC v2 -next 2/2] virtio_net: Read the advised MTU
From: Sergei Shtylyov @ 2016-03-16 14:11 UTC (permalink / raw)
To: Aaron Conole, netdev, Michael S. Tsirkin, virtualization,
linux-kernel
In-Reply-To: <1458075853-14789-3-git-send-email-aconole@redhat.com>
Hello.
On 3/16/2016 12:04 AM, Aaron Conole wrote:
> This patch checks the feature bit for the VIRTIO_NET_F_MTU feature. If it
> exists, read the advised MTU and use it.
>
> No proper error handling is provided for the case where a user changes the
> negotiated MTU. A future commit will add proper error handling. Instead, a
> warning is emitted if the guest changes the device MTU after previously
> being given advice.
>
> Signed-off-by: Aaron Conole <aconole@bytheb.org>
> ---
> v2:
> * Whitespace cleanup in the last hunk
> * Code style change around the pr_warn
> * Additional test for mtu change before printing warning
>
> drivers/net/virtio_net.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 767ab11..429fe01 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
[...]
> @@ -1390,8 +1391,11 @@ static const struct ethtool_ops virtnet_ethtool_ops = {
>
> static int virtnet_change_mtu(struct net_device *dev, int new_mtu)
> {
> + struct virtnet_info *vi = netdev_priv(dev);
> if (new_mtu < MIN_MTU || new_mtu > MAX_MTU)
> return -EINVAL;
> + if ((vi->negotiated_mtu) && (dev->mtu != new_mtu))
Inner parens not needed, please be consistent with the code above.
[...]
MBR, Sergei
^ permalink raw reply
* Re: [PATCH net-next 4/6] bridge: a netlink notification should be sent when those attributes are changed by br_sysfs_br
From: Nikolay Aleksandrov @ 2016-03-16 14:14 UTC (permalink / raw)
To: Xin Long, network dev; +Cc: davem, Hannes Frederic Sowa
In-Reply-To: <38a10eecc6347a3c47b55c86b4783c49b6dbbc99.1458134414.git.lucien.xin@gmail.com>
On 03/16/2016 02:34 PM, Xin Long wrote:
> Now when we change the attributes of bridge or br_port by netlink,
> a relevant netlink notification will be sent, but if we change them
> by ioctl or sysfs, no notification will be sent.
>
> We should ensure that whenever those attributes change internally or from
> sysfs/ioctl, that a netlink notification is sent out to listeners.
>
> Also, NetworkManager will use this in the future to listen for out-of-band
> bridge master attribute updates and incorporate them into the runtime
> configuration.
>
> This patch is used for br_sysfs_br. and we also need to remove some
> rtnl_trylock in old functions so that we can call it in a common one.
>
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
> ---
> net/bridge/br_sysfs_br.c | 17 ++++++++---------
> net/bridge/br_vlan.c | 30 +++++-------------------------
> 2 files changed, 13 insertions(+), 34 deletions(-)
>
What about the group_addr option ? Changing it will not generate a notification.
^ permalink raw reply
* Re: [PATCH 2/2] lan78xx: add ndo_get_stats64
From: Sergei Shtylyov @ 2016-03-16 14:16 UTC (permalink / raw)
To: Woojung.Huh, davem, netdev; +Cc: UNGLinuxDriver
In-Reply-To: <9235D6609DB808459E95D78E17F2E43D404C906A@CHN-SV-EXMX02.mchp-main.com>
Hello.
On 3/16/2016 1:52 AM, Woojung.Huh@microchip.com wrote:
> From: Woojung Huh <woojung.huh@microchip.com>
>
> Add lan78xx_get_stats64 of ndo_get_stats64 to report
> all statistics counters including errors from HW statistics.
>
> Read from HW when auto suspend is disabled, use saved counter when
> auto suspend is enabled because periodic call to ndo_get_stats64
> prevents USB auto suspend.
>
> Signed-off-by: Woojung Huh <woojung.huh@microchip.com>
> ---
> drivers/net/usb/lan78xx.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 49 insertions(+)
>
> diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
> index f20890e..f4a9708f 100644
> --- a/drivers/net/usb/lan78xx.c
> +++ b/drivers/net/usb/lan78xx.c
> @@ -3261,6 +3261,54 @@ void lan78xx_tx_timeout(struct net_device *net)
> tasklet_schedule(&dev->bh);
> }
>
> +struct rtnl_link_stats64 *lan78xx_get_stats64(struct net_device *netdev,
> + struct rtnl_link_stats64 *storage)
> +{
[...]
> + storage->rx_length_errors = (stats.rx_undersize_frame_errors +
> + stats.rx_oversize_frame_errors);
Parens not needed.
> + storage->rx_crc_errors = stats.rx_fcs_errors;
> + storage->rx_frame_errors = stats.rx_alignment_errors;
> + storage->rx_fifo_errors = stats.rx_dropped_frames;
> + storage->rx_over_errors = stats.rx_oversize_frame_errors;
> + storage->rx_errors = (stats.rx_fcs_errors +
> + stats.rx_alignment_errors +
> + stats.rx_fragment_errors +
> + stats.rx_jabber_errors +
> + stats.rx_undersize_frame_errors +
> + stats.rx_oversize_frame_errors +
> + stats.rx_dropped_frames);
Neither here.
> +
> + storage->tx_carrier_errors = stats.tx_carrier_errors;
> + storage->tx_errors = (stats.tx_fcs_errors +
> + stats.tx_excess_deferral_errors +
> + stats.tx_carrier_errors);
And here.
[...]
MBR, Sergei
^ permalink raw reply
* [BUG] bcmgenet tx path
From: Eric Dumazet @ 2016-03-16 14:18 UTC (permalink / raw)
To: Florian Fainelli; +Cc: netdev
Hi Florian
I was looking at drivers/net/ethernet/broadcom/genet/bcmgenet.c
and found TX completion (__bcmgenet_tx_reclaim()) was freeing skb before
frags were actually dma unmapped.
Are you sure this is OK ? bnx2 and bnx2x actually do the reverse (unmap
all frags before freeing skb)
A second problem is the dma_unmap_single() uses tx_cb_ptr->skb->len for
the length, while it really should be the same thing that was used in
bcmgenet_xmit_single()
skb_len = skb_headlen(skb) < ETH_ZLEN ? ETH_ZLEN : skb_headlen(skb);
So maybe something like :
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index d7e01a7..9211b9c7 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -1197,7 +1197,7 @@ static unsigned int __bcmgenet_tx_reclaim(struct net_device *dev,
dev->stats.tx_bytes += tx_cb_ptr->skb->len;
dma_unmap_single(&dev->dev,
dma_unmap_addr(tx_cb_ptr, dma_addr),
- tx_cb_ptr->skb->len,
+ dma_unmap_len(tx_cb_ptr, dma_len),
DMA_TO_DEVICE);
bcmgenet_free_cb(tx_cb_ptr);
} else if (dma_unmap_addr(tx_cb_ptr, dma_addr)) {
@@ -1308,7 +1308,7 @@ static int bcmgenet_xmit_single(struct net_device *dev,
}
dma_unmap_addr_set(tx_cb_ptr, dma_addr, mapping);
- dma_unmap_len_set(tx_cb_ptr, dma_len, skb->len);
+ dma_unmap_len_set(tx_cb_ptr, dma_len, skb_len);
length_status = (skb_len << DMA_BUFLENGTH_SHIFT) | dma_desc_flags |
(priv->hw_params->qtag_mask << DMA_TX_QTAG_SHIFT) |
DMA_TX_APPEND_CRC;
^ permalink raw reply related
* Re: [PATCH net-next 5/6] bridge: a netlink notification should be sent when those attributes are changed by br_sysfs_if
From: Nikolay Aleksandrov @ 2016-03-16 14:23 UTC (permalink / raw)
To: Xin Long, network dev; +Cc: davem, Hannes Frederic Sowa
In-Reply-To: <7c788b65786582209a3ba4bc4d4ed279f6f77568.1458134414.git.lucien.xin@gmail.com>
On 03/16/2016 02:34 PM, Xin Long wrote:
> Now when we change the attributes of bridge or br_port by netlink,
> a relevant netlink notification will be sent, but if we change them
> by ioctl or sysfs, no notification will be sent.
>
> We should ensure that whenever those attributes change internally or from
> sysfs/ioctl, that a netlink notification is sent out to listeners.
>
> Also, NetworkManager will use this in the future to listen for out-of-band
> bridge master attribute updates and incorporate them into the runtime
> configuration.
>
> This patch is used for br_sysfs_if, and we also move br_ifinfo_notify out
> of store_flag.
>
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
> ---
> net/bridge/br_sysfs_if.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
Generally looks good, but it creates an inconsistency between bridge fdb_flush
and port fdb_flush since the latter will generate a notification while the
bridge flush will not.
^ permalink raw reply
* Re: [RFC v2 -next 2/2] virtio_net: Read the advised MTU
From: Michael S. Tsirkin @ 2016-03-16 14:24 UTC (permalink / raw)
To: Aaron Conole; +Cc: netdev, linux-kernel, virtualization
In-Reply-To: <1458075853-14789-3-git-send-email-aconole@redhat.com>
On Tue, Mar 15, 2016 at 05:04:13PM -0400, Aaron Conole wrote:
> This patch checks the feature bit for the VIRTIO_NET_F_MTU feature. If it
> exists, read the advised MTU and use it.
>
> No proper error handling is provided for the case where a user changes the
> negotiated MTU. A future commit will add proper error handling. Instead, a
> warning is emitted if the guest changes the device MTU after previously
> being given advice.
I don't see this as an error. Device might at best give a hint,
user/network admin always knows best.
>
> Signed-off-by: Aaron Conole <aconole@bytheb.org>
> ---
> v2:
> * Whitespace cleanup in the last hunk
> * Code style change around the pr_warn
> * Additional test for mtu change before printing warning
>
> drivers/net/virtio_net.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 767ab11..429fe01 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -146,6 +146,7 @@ struct virtnet_info {
> virtio_net_ctrl_ack ctrl_status;
> u8 ctrl_promisc;
> u8 ctrl_allmulti;
> + bool negotiated_mtu;
> };
>
> struct padded_vnet_hdr {
> @@ -1390,8 +1391,11 @@ static const struct ethtool_ops virtnet_ethtool_ops = {
>
> static int virtnet_change_mtu(struct net_device *dev, int new_mtu)
> {
> + struct virtnet_info *vi = netdev_priv(dev);
> if (new_mtu < MIN_MTU || new_mtu > MAX_MTU)
> return -EINVAL;
> + if ((vi->negotiated_mtu) && (dev->mtu != new_mtu))
> + pr_warn("changing mtu while the advised mtu bit exists.");
I don't really see why are we warning here. Just drop this chunk,
as well as the flag in struct virtnet_info.
> dev->mtu = new_mtu;
> return 0;
> }
> @@ -1836,6 +1840,13 @@ static int virtnet_probe(struct virtio_device *vdev)
> if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ))
> vi->has_cvq = true;
>
> + if (virtio_has_feature(vdev, VIRTIO_NET_F_MTU)) {
> + vi->negotiated_mtu = true;
> + dev->mtu = virtio_cread16(vdev,
> + offsetof(struct virtio_net_config,
> + mtu));
> + }
> +
> if (vi->any_header_sg)
> dev->needed_headroom = vi->hdr_len;
>
> @@ -2019,6 +2030,7 @@ static unsigned int features[] = {
> VIRTIO_NET_F_GUEST_ANNOUNCE, VIRTIO_NET_F_MQ,
> VIRTIO_NET_F_CTRL_MAC_ADDR,
> VIRTIO_F_ANY_LAYOUT,
> + VIRTIO_NET_F_MTU,
> };
>
> static struct virtio_driver virtio_net_driver = {
> --
> 2.5.0
^ permalink raw reply
* Re: linux-next: manual merge of the rdma tree with the net-next tree
From: Maor Gottlieb @ 2016-03-16 14:27 UTC (permalink / raw)
To: Stephen Rothwell
Cc: Doug Ledford, David Miller, netdev, linux-next, linux-kernel,
Amir Vadai, Maor Gottlieb
In-Reply-To: <20160316115809.61b4478e@canb.auug.org.au>
2016-03-16 2:58 GMT+02:00 Stephen Rothwell <sfr@canb.auug.org.au>:
> Hi all,
>
> Today's linux-next merge of the rdma tree got a conflict in:
>
> drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
>
> between commit:
>
> 60ab4584f5bf ("net/mlx5_core: Set flow steering dest only for forward rules")
>
> from the net-next tree and commit:
>
> b3638e1a7664 ("net/mlx5_core: Introduce forward to next priority action")
>
> from the rdma tree.
>
> I fixed it up (see below) and can carry the fix as necessary (no action
> is required).
>
> --
> Cheers,
> Stephen Rothwell
>
> diff --cc drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
> index e848d708d2b7,bf3446794bd5..000000000000
> --- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
> @@@ -73,10 -73,13 +73,13 @@@
> #define BY_PASS_MIN_LEVEL (KENREL_MIN_LEVEL + MLX5_BY_PASS_NUM_PRIOS +\
> LEFTOVERS_MAX_FT)
>
> -#define KERNEL_MAX_FT 2
> -#define KERNEL_NUM_PRIOS 1
> +#define KERNEL_MAX_FT 3
> +#define KERNEL_NUM_PRIOS 2
> #define KENREL_MIN_LEVEL 2
>
> + #define ANCHOR_MAX_FT 1
> + #define ANCHOR_NUM_PRIOS 1
> + #define ANCHOR_MIN_LEVEL (BY_PASS_MIN_LEVEL + 1)
> struct node_caps {
> size_t arr_sz;
> long *caps;
> @@@ -360,8 -367,13 +367,13 @@@ static void del_rule(struct fs_node *no
> memcpy(match_value, fte->val, sizeof(fte->val));
> fs_get_obj(ft, fg->node.parent);
> list_del(&rule->node.list);
> + if (rule->sw_action == MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_PRIO) {
> + mutex_lock(&rule->dest_attr.ft->lock);
> + list_del(&rule->next_ft);
> + mutex_unlock(&rule->dest_attr.ft->lock);
> + }
> - fte->dests_size--;
> - if (fte->dests_size) {
> + if ((fte->action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST) &&
> + --fte->dests_size) {
> err = mlx5_cmd_update_fte(dev, ft,
> fg->id, fte);
> if (err)
> @@@ -762,9 -835,9 +835,10 @@@ static struct mlx5_flow_rule *alloc_rul
> if (!rule)
> return NULL;
>
> + INIT_LIST_HEAD(&rule->next_ft);
> rule->node.type = FS_TYPE_FLOW_DEST;
> - memcpy(&rule->dest_attr, dest, sizeof(*dest));
> + if (dest)
> + memcpy(&rule->dest_attr, dest, sizeof(*dest));
>
> return rule;
> }
> @@@ -783,12 -856,16 +857,17 @@@ static struct mlx5_flow_rule *add_rule_
> return ERR_PTR(-ENOMEM);
>
> fs_get_obj(ft, fg->node.parent);
> - /* Add dest to dests list- added as first element after the head */
> + /* Add dest to dests list- we need flow tables to be in the
> + * end of the list for forward to next prio rules.
> + */
> tree_init_node(&rule->node, 1, del_rule);
> - list_add_tail(&rule->node.list, &fte->node.children);
> + if (dest && dest->type != MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE)
> + list_add(&rule->node.list, &fte->node.children);
> + else
> + list_add_tail(&rule->node.list, &fte->node.children);
> - fte->dests_size++;
> - if (fte->dests_size == 1)
> + if (dest)
> + fte->dests_size++;
> + if (fte->dests_size == 1 || !dest)
> err = mlx5_cmd_create_fte(get_dev(&ft->node),
> ft, fg->id, fte);
> else
Hi Stephen,
I reveiwed your merge and it's fine.
Thanks,
Maor
^ permalink raw reply
* Re: [PATCH net-next 6/6] bridge: a netlink notification should be sent when those attributes are changed by ioctl
From: Nikolay Aleksandrov @ 2016-03-16 14:28 UTC (permalink / raw)
To: Xin Long, network dev; +Cc: davem, Hannes Frederic Sowa
In-Reply-To: <9cadf4925a11b60a5420406b4eb164e9a2d13b50.1458134414.git.lucien.xin@gmail.com>
On 03/16/2016 02:34 PM, Xin Long wrote:
> Now when we change the attributes of bridge or br_port by netlink,
> a relevant netlink notification will be sent, but if we change them
> by ioctl or sysfs, no notification will be sent.
>
> We should ensure that whenever those attributes change internally or from
> sysfs/ioctl, that a netlink notification is sent out to listeners.
>
> Also, NetworkManager will use this in the future to listen for out-of-band
> bridge master attribute updates and incorporate them into the runtime
> configuration.
>
> This patch is used for ioctl.
>
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
> ---
> net/bridge/br_ioctl.c | 40 ++++++++++++++++++++++++----------------
> 1 file changed, 24 insertions(+), 16 deletions(-)
>
LGTM,
Acked-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
^ permalink raw reply
* Re: [PATCH net-next 4/6] bridge: a netlink notification should be sent when those attributes are changed by br_sysfs_br
From: Xin Long @ 2016-03-16 14:29 UTC (permalink / raw)
To: Nikolay Aleksandrov; +Cc: network dev, davem, Hannes Frederic Sowa
In-Reply-To: <56E96A3B.1030907@cumulusnetworks.com>
On Wed, Mar 16, 2016 at 10:14 PM, Nikolay Aleksandrov
<nikolay@cumulusnetworks.com> wrote:
> On 03/16/2016 02:34 PM, Xin Long wrote:
>> Now when we change the attributes of bridge or br_port by netlink,
>> a relevant netlink notification will be sent, but if we change them
>> by ioctl or sysfs, no notification will be sent.
>>
>> We should ensure that whenever those attributes change internally or from
>> sysfs/ioctl, that a netlink notification is sent out to listeners.
>>
>> Also, NetworkManager will use this in the future to listen for out-of-band
>> bridge master attribute updates and incorporate them into the runtime
>> configuration.
>>
>> This patch is used for br_sysfs_br. and we also need to remove some
>> rtnl_trylock in old functions so that we can call it in a common one.
>>
>> Signed-off-by: Xin Long <lucien.xin@gmail.com>
>> ---
>> net/bridge/br_sysfs_br.c | 17 ++++++++---------
>> net/bridge/br_vlan.c | 30 +++++-------------------------
>> 2 files changed, 13 insertions(+), 34 deletions(-)
>>
>
> What about the group_addr option ? Changing it will not generate a notification.
>
>
group_addr is not a string-to-long convert in sysfs. so it's hard to use
store_bridge_parm, that's why I didn't modify it.
in group_addr_store():
it also tries to hold rtnl_lock. maybe we can send rtnl msg there.
what do you think?
when I cooked this patch, I was wondering why br_recalculate_fwd_mask
"Must be protected by RTNL."
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox