From: Jason Wang <jasowang@redhat.com>
To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, jbrouer@redhat.com,
mst@redhat.com, Jason Wang <jasowang@redhat.com>
Subject: [RFC PATCH net-next V2 4/6] macvlan: count the number of vlan in source mode
Date: Mon, 13 Aug 2018 11:17:28 +0800 [thread overview]
Message-ID: <1534130250-5302-5-git-send-email-jasowang@redhat.com> (raw)
In-Reply-To: <1534130250-5302-1-git-send-email-jasowang@redhat.com>
This patch tries to count the number of vlans in source mode. This
will be used for implementing XDP rx handler for macvlan.
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
drivers/net/macvlan.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index cfda146..b7c814d 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -53,6 +53,7 @@ struct macvlan_port {
struct hlist_head vlan_source_hash[MACVLAN_HASH_SIZE];
DECLARE_BITMAP(mc_filter, MACVLAN_MC_FILTER_SZ);
unsigned char perm_addr[ETH_ALEN];
+ unsigned long source_count;
};
struct macvlan_source_entry {
@@ -1433,6 +1434,9 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
if (err)
goto unregister_netdev;
+ if (vlan->mode == MACVLAN_MODE_SOURCE)
+ port->source_count++;
+
list_add_tail_rcu(&vlan->list, &port->vlans);
netif_stacked_transfer_operstate(lowerdev, dev);
linkwatch_fire_event(dev);
@@ -1477,6 +1481,7 @@ static int macvlan_changelink(struct net_device *dev,
struct netlink_ext_ack *extack)
{
struct macvlan_dev *vlan = netdev_priv(dev);
+ struct macvlan_port *port = vlan->port;
enum macvlan_mode mode;
bool set_mode = false;
enum macvlan_macaddr_mode macmode;
@@ -1491,8 +1496,10 @@ static int macvlan_changelink(struct net_device *dev,
(vlan->mode == MACVLAN_MODE_PASSTHRU))
return -EINVAL;
if (vlan->mode == MACVLAN_MODE_SOURCE &&
- vlan->mode != mode)
+ vlan->mode != mode) {
macvlan_flush_sources(vlan->port, vlan);
+ port->source_count--;
+ }
}
if (data && data[IFLA_MACVLAN_FLAGS]) {
@@ -1510,8 +1517,13 @@ static int macvlan_changelink(struct net_device *dev,
}
vlan->flags = flags;
}
- if (set_mode)
+ if (set_mode) {
vlan->mode = mode;
+ if (mode == MACVLAN_MODE_SOURCE &&
+ vlan->mode != mode) {
+ port->source_count++;
+ }
+ }
if (data && data[IFLA_MACVLAN_MACADDR_MODE]) {
if (vlan->mode != MACVLAN_MODE_SOURCE)
return -EINVAL;
--
2.7.4
next prev parent reply other threads:[~2018-08-13 3:17 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-13 3:17 [RFC PATCH net-next V2 0/6] XDP rx handler Jason Wang
2018-08-13 3:17 ` [RFC PATCH net-next V2 1/6] net: core: factor out generic XDP check and process routine Jason Wang
2018-08-13 3:17 ` [RFC PATCH net-next V2 2/6] net: core: generic XDP support for stacked device Jason Wang
2018-08-13 3:17 ` [RFC PATCH net-next V2 3/6] net: core: introduce XDP rx handler Jason Wang
2018-08-13 3:17 ` Jason Wang [this message]
2018-08-13 3:17 ` [RFC PATCH net-next V2 5/6] macvlan: basic XDP support Jason Wang
2018-08-13 3:17 ` [RFC PATCH net-next V2 6/6] virtio-net: support XDP rx handler Jason Wang
2018-08-14 9:22 ` Jesper Dangaard Brouer
2018-08-14 13:01 ` Jason Wang
2018-08-14 0:32 ` [RFC PATCH net-next V2 0/6] " Alexei Starovoitov
2018-08-14 7:59 ` Jason Wang
2018-08-14 10:17 ` Jesper Dangaard Brouer
2018-08-14 13:20 ` Jason Wang
2018-08-14 14:03 ` David Ahern
2018-08-15 0:29 ` Jason Wang
2018-08-15 5:35 ` Alexei Starovoitov
2018-08-15 7:04 ` Jason Wang
2018-08-16 2:49 ` Alexei Starovoitov
2018-08-16 4:21 ` Jason Wang
2018-08-15 17:17 ` David Ahern
2018-08-16 3:34 ` Jason Wang
2018-08-16 4:05 ` Alexei Starovoitov
2018-08-16 4:24 ` Jason Wang
2018-08-17 21:15 ` David Ahern
2018-08-20 6:34 ` Jason Wang
2018-09-05 17:20 ` David Ahern
2018-09-06 5:12 ` Jason Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1534130250-5302-5-git-send-email-jasowang@redhat.com \
--to=jasowang@redhat.com \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=jbrouer@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).