netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2 V2] vxlan fdb replace an existing entry
@ 2013-07-19 15:20 Thomas Richter
  2013-07-19 15:20 ` [PATCH 2/2 V2] macvlan fdb replace support Thomas Richter
  2013-07-23 23:36 ` [PATCH 1/2 V2] vxlan fdb replace an existing entry David Miller
  0 siblings, 2 replies; 7+ messages in thread
From: Thomas Richter @ 2013-07-19 15:20 UTC (permalink / raw)
  To: netdev; +Cc: davem, stephen, Thomas Richter

Add support to replace an existing entry found in the
vxlan fdb database. The entry in question is identified
by its unicast mac address and the destination information
is changed. If the entry is not found, it is added in the
forwarding database. This is similar to changing an entry
in the neighbour table.

Multicast mac addresses can not be changed with the replace
option.

This is useful for virtual machine migration when the
destination of a target virtual machine changes. The replace
feature can be used instead of delete followed by add.

Resubmitted because net-next was closed last week.

Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
---
 drivers/net/vxlan.c | 40 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 227b54a..17681c6 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -407,6 +407,26 @@ static struct vxlan_rdst *vxlan_fdb_find_rdst(struct vxlan_fdb *f,
 	return NULL;
 }
 
+/* Replace destination of unicast mac */
+static int vxlan_fdb_replace(struct vxlan_fdb *f,
+			    __be32 ip, __be16 port, __u32 vni, __u32 ifindex)
+{
+	struct vxlan_rdst *rd;
+
+	rd = vxlan_fdb_find_rdst(f, ip, port, vni, ifindex);
+	if (rd)
+		return 0;
+
+	rd = list_first_entry_or_null(&f->remotes, struct vxlan_rdst, list);
+	if (!rd)
+		return 0;
+	rd->remote_ip = ip;
+	rd->remote_port = port;
+	rd->remote_vni = vni;
+	rd->remote_ifindex = ifindex;
+	return 1;
+}
+
 /* Add/update destinations for multicast */
 static int vxlan_fdb_append(struct vxlan_fdb *f,
 			    __be32 ip, __be16 port, __u32 vni, __u32 ifindex)
@@ -457,6 +477,19 @@ static int vxlan_fdb_create(struct vxlan_dev *vxlan,
 			f->updated = jiffies;
 			notify = 1;
 		}
+		if ((flags & NLM_F_REPLACE)) {
+			/* Only change unicasts */
+			if (!(is_multicast_ether_addr(f->eth_addr) ||
+			     is_zero_ether_addr(f->eth_addr))) {
+				int rc = vxlan_fdb_replace(f, ip, port, vni,
+							   ifindex);
+
+				if (rc < 0)
+					return rc;
+				notify |= rc;
+			} else
+				return -EOPNOTSUPP;
+		}
 		if ((flags & NLM_F_APPEND) &&
 		    (is_multicast_ether_addr(f->eth_addr) ||
 		     is_zero_ether_addr(f->eth_addr))) {
@@ -473,6 +506,11 @@ static int vxlan_fdb_create(struct vxlan_dev *vxlan,
 		if (vxlan->addrmax && vxlan->addrcnt >= vxlan->addrmax)
 			return -ENOSPC;
 
+		/* Disallow replace to add a multicast entry */
+		if ((flags & NLM_F_REPLACE) &&
+		    (is_multicast_ether_addr(mac) || is_zero_ether_addr(mac)))
+			return -EOPNOTSUPP;
+
 		netdev_dbg(vxlan->dev, "add %pM -> %pI4\n", mac, &ip);
 		f = kmalloc(sizeof(*f), GFP_ATOMIC);
 		if (!f)
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2 V2] macvlan fdb replace support
  2013-07-19 15:20 [PATCH 1/2 V2] vxlan fdb replace an existing entry Thomas Richter
@ 2013-07-19 15:20 ` Thomas Richter
  2013-07-19 16:18   ` Stephen Hemminger
  2013-07-23 23:36   ` David Miller
  2013-07-23 23:36 ` [PATCH 1/2 V2] vxlan fdb replace an existing entry David Miller
  1 sibling, 2 replies; 7+ messages in thread
From: Thomas Richter @ 2013-07-19 15:20 UTC (permalink / raw)
  To: netdev; +Cc: davem, stephen, Thomas Richter

Add support for iproute2 command 'bridge fdb replace ...'.
The rtnletlink call back function ndo_fdb_add will be called
with the NLM_F_REPLACE flag set.
Simply return -EOPNOTSUP.

Resubmitted because net-next was closed last week.

Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
---
 drivers/net/macvlan.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 18373b6..74907f5 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -597,6 +597,9 @@ static int macvlan_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
 	if (!vlan->port->passthru)
 		return -EOPNOTSUPP;
 
+	if (flags & NLM_F_REPLACE)
+		return -EOPNOTSUPP;
+
 	if (is_unicast_ether_addr(addr))
 		err = dev_uc_add_excl(dev, addr);
 	else if (is_multicast_ether_addr(addr))
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2 V2] macvlan fdb replace support
  2013-07-19 15:20 ` [PATCH 2/2 V2] macvlan fdb replace support Thomas Richter
@ 2013-07-19 16:18   ` Stephen Hemminger
  2013-07-22 13:16     ` Thomas-Mich Richter
  2013-07-23 23:36   ` David Miller
  1 sibling, 1 reply; 7+ messages in thread
From: Stephen Hemminger @ 2013-07-19 16:18 UTC (permalink / raw)
  To: Thomas Richter; +Cc: netdev, davem

On Fri, 19 Jul 2013 17:20:08 +0200
Thomas Richter <tmricht@linux.vnet.ibm.com> wrote:

> Add support for iproute2 command 'bridge fdb replace ...'.
> The rtnletlink call back function ndo_fdb_add will be called
> with the NLM_F_REPLACE flag set.
> Simply return -EOPNOTSUP.
> 
> Resubmitted because net-next was closed last week.
> 
> Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
> ---
>  drivers/net/macvlan.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
> index 18373b6..74907f5 100644
> --- a/drivers/net/macvlan.c
> +++ b/drivers/net/macvlan.c
> @@ -597,6 +597,9 @@ static int macvlan_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
>  	if (!vlan->port->passthru)
>  		return -EOPNOTSUPP;
>  
> +	if (flags & NLM_F_REPLACE)
> +		return -EOPNOTSUPP;
> +
>  	if (is_unicast_ether_addr(addr))
>  		err = dev_uc_add_excl(dev, addr);
>  	else if (is_multicast_ether_addr(addr))

What about bridge that also uses netlink FDB interface?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2 V2] macvlan fdb replace support
  2013-07-19 16:18   ` Stephen Hemminger
@ 2013-07-22 13:16     ` Thomas-Mich Richter
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas-Mich Richter @ 2013-07-22 13:16 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev, davem

On 07/19/2013 06:18 PM, Stephen Hemminger wrote:
> On Fri, 19 Jul 2013 17:20:08 +0200
> Thomas Richter <tmricht@linux.vnet.ibm.com> wrote:
> 
>> Add support for iproute2 command 'bridge fdb replace ...'.
>> The rtnletlink call back function ndo_fdb_add will be called
>> with the NLM_F_REPLACE flag set.
>> Simply return -EOPNOTSUP.
>>
>> Resubmitted because net-next was closed last week.
>>
>> Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
>> ---
>>  drivers/net/macvlan.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
>> index 18373b6..74907f5 100644
>> --- a/drivers/net/macvlan.c
>> +++ b/drivers/net/macvlan.c
>> @@ -597,6 +597,9 @@ static int macvlan_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
>>  	if (!vlan->port->passthru)
>>  		return -EOPNOTSUPP;
>>  
>> +	if (flags & NLM_F_REPLACE)
>> +		return -EOPNOTSUPP;
>> +
>>  	if (is_unicast_ether_addr(addr))
>>  		err = dev_uc_add_excl(dev, addr);
>>  	else if (is_multicast_ether_addr(addr))
> 
> What about bridge that also uses netlink FDB interface?
> 
The bridge function br_fdb_add() calls fdb_add_entry().
There is no need to check flag NLM_F_REPLACE.
The code already changes an entry if it is found
in the fdb. If the entry is missing in the
fdb, it is added when flag NLM_F_CREATE is set.


-- 
Thomas Richter, Dept 3250, IBM LTC Boeblingen, Data Center Networking
--
Vorsitzende des Aufsichtsrats: Martina Koederitz 
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2 V2] vxlan fdb replace an existing entry
  2013-07-19 15:20 [PATCH 1/2 V2] vxlan fdb replace an existing entry Thomas Richter
  2013-07-19 15:20 ` [PATCH 2/2 V2] macvlan fdb replace support Thomas Richter
@ 2013-07-23 23:36 ` David Miller
  1 sibling, 0 replies; 7+ messages in thread
From: David Miller @ 2013-07-23 23:36 UTC (permalink / raw)
  To: tmricht; +Cc: netdev, stephen

From: Thomas Richter <tmricht@linux.vnet.ibm.com>
Date: Fri, 19 Jul 2013 17:20:07 +0200

> Add support to replace an existing entry found in the
> vxlan fdb database. The entry in question is identified
> by its unicast mac address and the destination information
> is changed. If the entry is not found, it is added in the
> forwarding database. This is similar to changing an entry
> in the neighbour table.
> 
> Multicast mac addresses can not be changed with the replace
> option.
> 
> This is useful for virtual machine migration when the
> destination of a target virtual machine changes. The replace
> feature can be used instead of delete followed by add.
> 
> Resubmitted because net-next was closed last week.
> 
> Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>

Applied.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2 V2] macvlan fdb replace support
  2013-07-19 15:20 ` [PATCH 2/2 V2] macvlan fdb replace support Thomas Richter
  2013-07-19 16:18   ` Stephen Hemminger
@ 2013-07-23 23:36   ` David Miller
  1 sibling, 0 replies; 7+ messages in thread
From: David Miller @ 2013-07-23 23:36 UTC (permalink / raw)
  To: tmricht; +Cc: netdev, stephen

From: Thomas Richter <tmricht@linux.vnet.ibm.com>
Date: Fri, 19 Jul 2013 17:20:08 +0200

> Add support for iproute2 command 'bridge fdb replace ...'.
> The rtnletlink call back function ndo_fdb_add will be called
> with the NLM_F_REPLACE flag set.
> Simply return -EOPNOTSUP.
> 
> Resubmitted because net-next was closed last week.
> 
> Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>

Applied.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/2 V2] macvlan fdb replace support
  2013-07-12  7:10 Thomas Richter
@ 2013-07-12  7:10 ` Thomas Richter
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Richter @ 2013-07-12  7:10 UTC (permalink / raw)
  To: netdev; +Cc: Thomas Richter

Add support for iproute2 command 'bridge fdb replace ...'.
The rtnletlink call back function ndo_fdb_add will be called
with the NLM_F_REPLACE flag set.
Simply return -EOPNOTSUP.

Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
---
 drivers/net/macvlan.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 18373b6..74907f5 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -597,6 +597,9 @@ static int macvlan_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
 	if (!vlan->port->passthru)
 		return -EOPNOTSUPP;
 
+	if (flags & NLM_F_REPLACE)
+		return -EOPNOTSUPP;
+
 	if (is_unicast_ether_addr(addr))
 		err = dev_uc_add_excl(dev, addr);
 	else if (is_multicast_ether_addr(addr))
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-07-23 23:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-19 15:20 [PATCH 1/2 V2] vxlan fdb replace an existing entry Thomas Richter
2013-07-19 15:20 ` [PATCH 2/2 V2] macvlan fdb replace support Thomas Richter
2013-07-19 16:18   ` Stephen Hemminger
2013-07-22 13:16     ` Thomas-Mich Richter
2013-07-23 23:36   ` David Miller
2013-07-23 23:36 ` [PATCH 1/2 V2] vxlan fdb replace an existing entry David Miller
  -- strict thread matches above, loose matches on Subject: below --
2013-07-12  7:10 Thomas Richter
2013-07-12  7:10 ` [PATCH 2/2 V2] macvlan fdb replace support Thomas Richter

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).