[ovs-dev] [PATCH] datapath: Remove redundant check for IFF_NO_QUEUE

2017-10-30 Thread fukaige
From: Kaige Fu 

IFF_NO_QUEUE is checked twice. This cause a situation
that HAVE_IFF_NO_QUEUE is defined no matter whether
the flag IFF_NO_QUEUE is defined in kernel or not.

Signed-off-by: Kaige Fu 
---
 datapath/linux/compat/include/linux/netdevice.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/datapath/linux/compat/include/linux/netdevice.h 
b/datapath/linux/compat/include/linux/netdevice.h
index a5d4ee8..3c3cf42 100644
--- a/datapath/linux/compat/include/linux/netdevice.h
+++ b/datapath/linux/compat/include/linux/netdevice.h
@@ -22,9 +22,6 @@ struct net;
 #define IFF_LIVE_ADDR_CHANGE 0
 #endif
 
-#ifndef IFF_NO_QUEUE
-#define IFF_NO_QUEUE   0
-#endif
 #ifndef IFF_OPENVSWITCH
 #define IFF_OPENVSWITCH 0
 #endif
-- 
1.8.3.1


___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH] netdev-linux: Fix wrong ceil rate when max-rate less than 8bit.

2017-11-01 Thread fukaige
From: Kaige Fu 

When max-rate is less than 8bit, the hc->max_rate will be set
as htb->max_rate mistakenly instead of mtu of netdev.

Fixes: 13c1637 ("smap: New function smap_get_ullong().")

Signed-off-by: Kaige Fu 
---
 lib/netdev-linux.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index 2ff3e2b..66ca5fe 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -3762,6 +3762,7 @@ htb_parse_class_details__(struct netdev *netdev,
 {
 const struct htb *htb = htb_get__(netdev);
 int mtu, error;
+unsigned long long int max_rate_bit;
 
 error = netdev_linux_get_mtu__(netdev_linux_cast(netdev), &mtu);
 if (error) {
@@ -3777,10 +3778,10 @@ htb_parse_class_details__(struct netdev *netdev,
 hc->min_rate = MIN(hc->min_rate, htb->max_rate);
 
 /* max-rate */
-hc->max_rate = smap_get_ullong(details, "max-rate", 0) / 8;
-if (!hc->max_rate) {
-hc->max_rate = htb->max_rate;
-}
+max_rate_bit = smap_get_ullong(details, "max-rate", 0);
+hc->max_rate = (max_rate_bit
+? max_rate_bit / 8
+: htb->max_rate); 
 hc->max_rate = MAX(hc->max_rate, hc->min_rate);
 hc->max_rate = MIN(hc->max_rate, htb->max_rate);
 
-- 
1.8.3.1


___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [bug] failed to add ovs bridge

2017-05-16 Thread fukaige
Hi, all

I am using ovs-2.5.2 and get error when creating a bridge using “ovs-vsctl 
add-br br-eth”


ovs-vsctl: Error detected while setting up 'br-eth'.  See ovs-vswitchd log for 
details.

ovs-vswitchd log is as below:

2017-05-11T03:45:25.293Z|00026|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports recirculation
2017-05-11T03:45:25.293Z|00027|ofproto_dpif|INFO|system@ovs-system: MPLS label 
stack length probed as 1
2017-05-11T03:45:25.293Z|00028|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports unique flow ids
2017-05-11T03:45:25.293Z|00029|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_state
2017-05-11T03:45:25.293Z|00030|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_zone
2017-05-11T03:45:25.293Z|00031|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_mark
2017-05-11T03:45:25.293Z|00032|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_label
2017-05-11T03:45:25.364Z|1|ofproto_dpif_upcall(handler226)|INFO|received 
packet on unassociated datapath port 0
2017-05-11T03:45:25.368Z|00033|netdev_linux|WARN|ethtool command ETHTOOL_GFLAGS 
on network device br-eth failed: No such device
2017-05-11T03:45:25.368Z|00034|dpif|WARN|system@ovs-system: failed to add 
br-eth as port: No such device
2017-05-11T03:45:25.368Z|00035|bridge|INFO|bridge br-eth: using datapath ID 
2a51cf9f2841
2017-05-11T03:45:25.368Z|00036|connmgr|INFO|br-eth: added service controller 
"punix:/var/run/openvswitch/br-eth.mgmt"


Reproduce step:


1.   sh reproduce.sh

2.   sh del_br.sh

Reproduce scripts:

1.   reproduce.sh:

#!/bin/sh



outer_loop=1



test ()

{

echo "=start $outer_loop time test"

brctl addbr br0;ifconfig br0 up

inner_loop=1

while [ $inner_loop -le 10 ]

do

   echo "==start $inner_loop time vm life="

   echo `date`

   virsh create /vm.xml

   sleep 30

   virsh destroy test-ovs



   let inner_loop++

done

ifconfig br0 down; brctl delbr br0

ovs-vsctl add-br br0

ovs-vsctl del-br br0

}



while [ $outer_loop -le 100 ]

do

test

let outer_loop++

done


2.   del_br.sh

#!/bin/sh



count=1



test ()

{

echo "=start $count time test"

echo `date`

sleep 10

ifconfig br0 down; brctl delbr br0

}



while [ $count -le 100 ]

do

test

let count++

done

FYI, more information, please refer to “Failed to add ovs bridge” in 
ovs-discuss mail list.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [bug] failed to add ovs bridge

2017-05-16 Thread fukaige
I test ovs 2.5.0/2.5.2/2.5.3 on ARM64&x86. All got the same error.

From: fukaige
Sent: Wednesday, May 17, 2017 9:16 AM
To: 'd...@openvswitch.org'
Cc: 'Ben Pfaff'
Subject: [bug] failed to add ovs bridge

Hi, all

I am using ovs-2.5.2 and get error when creating a bridge using “ovs-vsctl 
add-br br-eth”


ovs-vsctl: Error detected while setting up 'br-eth'.  See ovs-vswitchd log for 
details.

ovs-vswitchd log is as below:

2017-05-11T03:45:25.293Z|00026|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports recirculation
2017-05-11T03:45:25.293Z|00027|ofproto_dpif|INFO|system@ovs-system: MPLS label 
stack length probed as 1
2017-05-11T03:45:25.293Z|00028|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports unique flow ids
2017-05-11T03:45:25.293Z|00029|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_state
2017-05-11T03:45:25.293Z|00030|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_zone
2017-05-11T03:45:25.293Z|00031|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_mark
2017-05-11T03:45:25.293Z|00032|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_label
2017-05-11T03:45:25.364Z|1|ofproto_dpif_upcall(handler226)|INFO|received 
packet on unassociated datapath port 0
2017-05-11T03:45:25.368Z|00033|netdev_linux|WARN|ethtool command ETHTOOL_GFLAGS 
on network device br-eth failed: No such device
2017-05-11T03:45:25.368Z|00034|dpif|WARN|system@ovs-system: failed to add 
br-eth as port: No such device
2017-05-11T03:45:25.368Z|00035|bridge|INFO|bridge br-eth: using datapath ID 
2a51cf9f2841
2017-05-11T03:45:25.368Z|00036|connmgr|INFO|br-eth: added service controller 
"punix:/var/run/openvswitch/br-eth.mgmt"


Reproduce step:


1.   sh reproduce.sh

2.   sh del_br.sh

Reproduce scripts:

1.   reproduce.sh:

#!/bin/sh



outer_loop=1



test ()

{

echo "=start $outer_loop time test"

brctl addbr br0;ifconfig br0 up

inner_loop=1

while [ $inner_loop -le 10 ]

do

   echo "==start $inner_loop time vm life="

   echo `date`

   virsh create /vm.xml

   sleep 30

   virsh destroy test-ovs



   let inner_loop++

done

ifconfig br0 down; brctl delbr br0

ovs-vsctl add-br br0

ovs-vsctl del-br br0

}



while [ $outer_loop -le 100 ]

do

test

let outer_loop++

done


2.   del_br.sh

#!/bin/sh



count=1



test ()

{

echo "=start $count time test"

echo `date`

sleep 10

ifconfig br0 down; brctl delbr br0

}



while [ $count -le 100 ]

do

test

let count++

done

FYI, more information, please refer to “Failed to add ovs bridge” in 
ovs-discuss mail list.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [bug] failed to add ovs bridge

2017-05-16 Thread fukaige
I start a vm with its backend tap device "vnet0" attached to a Linux bridge, 
then delete the bridge and vm.
Next time, vm will start failed. this is as expected. But, seeing that linux 
bridge was already delelted; 
there is no reason that the OVS bridge with the same name can not be created. 
What do you think?

Thanks
fukaige

> -Original Message-
> From: Ben Pfaff [mailto:b...@ovn.org]
> Sent: Wednesday, May 17, 2017 11:37 AM
> To: fukaige
> Cc: d...@openvswitch.org
> Subject: Re: [bug] failed to add ovs bridge
> 
> On Wed, May 17, 2017 at 01:16:11AM +, fukaige wrote:
> > I am using ovs-2.5.2 and get error when creating a bridge using “ovs-vsctl
> add-br br-eth”
> 
> > brctl addbr br0;ifconfig br0 up
> 
> [...]
> 
> > ifconfig br0 down; brctl delbr br0
> >
> > ovs-vsctl add-br br0
> >
> > ovs-vsctl del-br br0
> 
> Wait, what?  Why are you mixing brctl and ovs-vsctl?  That makes no sense.
> Use the Linux bridge *or* OVS, not a mix of them.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [bug] failed to add ovs bridge

2017-05-17 Thread fukaige
No. I just hit this in the situation. Do you think this is a bug? What's your 
next plan?

> -Original Message-
> From: Ben Pfaff [mailto:b...@ovn.org]
> Sent: Wednesday, May 17, 2017 11:55 PM
> To: fukaige
> Cc: d...@openvswitch.org
> Subject: Re: [bug] failed to add ovs bridge
> 
> Do you still see failures when the Linux bridge is not involved at all?
> 
> On Wed, May 17, 2017 at 03:52:54AM +, fukaige wrote:
> > I start a vm with its backend tap device "vnet0" attached to a Linux bridge,
> then delete the bridge and vm.
> > Next time, vm will start failed. this is as expected. But, seeing that
> > linux bridge was already delelted; there is no reason that the OVS bridge 
> > with
> the same name can not be created. What do you think?
> >
> > Thanks
> > fukaige
> >
> > > -Original Message-
> > > From: Ben Pfaff [mailto:b...@ovn.org]
> > > Sent: Wednesday, May 17, 2017 11:37 AM
> > > To: fukaige
> > > Cc: d...@openvswitch.org
> > > Subject: Re: [bug] failed to add ovs bridge
> > >
> > > On Wed, May 17, 2017 at 01:16:11AM +, fukaige wrote:
> > > > I am using ovs-2.5.2 and get error when creating a bridge using
> > > > “ovs-vsctl
> > > add-br br-eth”
> > >
> > > > brctl addbr br0;ifconfig br0 up
> > >
> > > [...]
> > >
> > > > ifconfig br0 down; brctl delbr br0
> > > >
> > > > ovs-vsctl add-br br0
> > > >
> > > > ovs-vsctl del-br br0
> > >
> > > Wait, what?  Why are you mixing brctl and ovs-vsctl?  That makes no
> sense.
> > > Use the Linux bridge *or* OVS, not a mix of them.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [bug] failed to add ovs bridge

2017-05-17 Thread fukaige
Ok, thank you. I'll pursue this.

> -Original Message-
> From: Ben Pfaff [mailto:b...@ovn.org]
> Sent: Thursday, May 18, 2017 10:41 AM
> To: fukaige
> Cc: d...@openvswitch.org
> Subject: Re: [bug] failed to add ovs bridge
> 
> I don't plan to pursue this because it only triggers when you do something 
> that
> I don't think makes sense.  It could be a bug in the Linux bridge, or in OVS, 
> or
> in their interaction, or in libvirt.  If you narrow down the problem, or find 
> a fix,
> please let us know.
> 
> On Thu, May 18, 2017 at 12:47:51AM +, fukaige wrote:
> > No. I just hit this in the situation. Do you think this is a bug? What's 
> > your next
> plan?
> >
> > > -Original Message-
> > > From: Ben Pfaff [mailto:b...@ovn.org]
> > > Sent: Wednesday, May 17, 2017 11:55 PM
> > > To: fukaige
> > > Cc: d...@openvswitch.org
> > > Subject: Re: [bug] failed to add ovs bridge
> > >
> > > Do you still see failures when the Linux bridge is not involved at all?
> > >
> > > On Wed, May 17, 2017 at 03:52:54AM +, fukaige wrote:
> > > > I start a vm with its backend tap device "vnet0" attached to a
> > > > Linux bridge,
> > > then delete the bridge and vm.
> > > > Next time, vm will start failed. this is as expected. But, seeing
> > > > that linux bridge was already delelted; there is no reason that
> > > > the OVS bridge with
> > > the same name can not be created. What do you think?
> > > >
> > > > Thanks
> > > > fukaige
> > > >
> > > > > -Original Message-
> > > > > From: Ben Pfaff [mailto:b...@ovn.org]
> > > > > Sent: Wednesday, May 17, 2017 11:37 AM
> > > > > To: fukaige
> > > > > Cc: d...@openvswitch.org
> > > > > Subject: Re: [bug] failed to add ovs bridge
> > > > >
> > > > > On Wed, May 17, 2017 at 01:16:11AM +, fukaige wrote:
> > > > > > I am using ovs-2.5.2 and get error when creating a bridge
> > > > > > using “ovs-vsctl
> > > > > add-br br-eth”
> > > > >
> > > > > > brctl addbr br0;ifconfig br0 up
> > > > >
> > > > > [...]
> > > > >
> > > > > > ifconfig br0 down; brctl delbr br0
> > > > > >
> > > > > > ovs-vsctl add-br br0
> > > > > >
> > > > > > ovs-vsctl del-br br0
> > > > >
> > > > > Wait, what?  Why are you mixing brctl and ovs-vsctl?  That makes
> > > > > no
> > > sense.
> > > > > Use the Linux bridge *or* OVS, not a mix of them.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v1] netdev-linux: Remove device in netdev_shash when deleted

2017-05-30 Thread fukaige
Start a virtual machine with its backend tap device attached to a brought up 
linux bridge.
If we delete the linux bridge when vm is still running, we'll get the following 
error when
trying to create a ovs bridge with the same name.

The reason is that ovs-router subsystem add the linux bridge into netdev_shash, 
but does
not remove it when the bridge is deleted in the situation. When the bridge is 
deleted, ovs
will receive a RTM_DELLINK msg, take this chance to remove the bridge in 
netdev_shash.

ovs-vsctl: Error detected while setting up 'br-eth'.  See ovs-vswitchd log for 
details.

ovs-vswitchd log:
2017-05-11T03:45:25.293Z|00026|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports recirculation
2017-05-11T03:45:25.293Z|00027|ofproto_dpif|INFO|system@ovs-system: MPLS label 
stack length probed as 1
2017-05-11T03:45:25.293Z|00028|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports unique flow ids
2017-05-11T03:45:25.293Z|00029|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_state
2017-05-11T03:45:25.293Z|00030|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_zone
2017-05-11T03:45:25.293Z|00031|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_mark
2017-05-11T03:45:25.293Z|00032|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_label
2017-05-11T03:45:25.364Z|1|ofproto_dpif_upcall(handler226)|INFO|received 
packet on unassociated datapath port 0
2017-05-11T03:45:25.368Z|00033|netdev_linux|WARN|ethtool command ETHTOOL_GFLAGS 
on network device br-eth failed: No such device
2017-05-11T03:45:25.368Z|00034|dpif|WARN|system@ovs-system: failed to add 
br-eth as port: No such device
2017-05-11T03:45:25.368Z|00035|bridge|INFO|bridge br-eth: using datapath ID 
2a51cf9f2841
2017-05-11T03:45:25.368Z|00036|connmgr|INFO|br-eth: added service controller 
"punix:/var/run/openvswitch/br-eth.mgmt"

Change-Id: Ib5ead59bc91453f83549da89937c0d3607e0385e
Signed-off-by: fukaige 
---
 lib/netdev-linux.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index 1e03c75..fae78e5 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -73,6 +73,7 @@
 #include "timer.h"
 #include "unaligned.h"
 #include "openvswitch/vlog.h"
+#include "tnl-ports.h"
 
 VLOG_DEFINE_THIS_MODULE(netdev_linux);
 
@@ -749,6 +750,7 @@ netdev_linux_update(struct netdev_linux *dev,
 dev->get_ifindex_error = 0;
 } else {
 netdev_linux_changed(dev, change->ifi_flags, 0);
+tnl_port_map_delete_ipdev(dev->up.name);
 }
 } else if (rtnetlink_type_is_rtnlgrp_addr(change->nlmsg_type)) {
 /* Invalidates in4, in6. */
-- 
1.8.3.1


___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v1] netdev-linux: Remove device in netdev_shash when deleted

2017-05-30 Thread fukaige
Start a virtual machine with its backend tap device attached to a brought up 
linux bridge.
If we delete the linux bridge when vm is still running, we'll get the following 
error when
trying to create a ovs bridge with the same name.

The reason is that ovs-router subsystem add the linux bridge into netdev_shash, 
but does
not remove it when the bridge is deleted in the situation. When the bridge is 
deleted, ovs
will receive a RTM_DELLINK msg, take this chance to remove the bridge in 
netdev_shash.

ovs-vsctl: Error detected while setting up 'br-eth'.  See ovs-vswitchd log for 
details.

ovs-vswitchd log:
2017-05-11T03:45:25.293Z|00026|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports recirculation
2017-05-11T03:45:25.293Z|00027|ofproto_dpif|INFO|system@ovs-system: MPLS label 
stack length probed as 1
2017-05-11T03:45:25.293Z|00028|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports unique flow ids
2017-05-11T03:45:25.293Z|00029|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_state
2017-05-11T03:45:25.293Z|00030|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_zone
2017-05-11T03:45:25.293Z|00031|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_mark
2017-05-11T03:45:25.293Z|00032|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_label
2017-05-11T03:45:25.364Z|1|ofproto_dpif_upcall(handler226)|INFO|received 
packet on unassociated datapath port 0
2017-05-11T03:45:25.368Z|00033|netdev_linux|WARN|ethtool command ETHTOOL_GFLAGS 
on network device br-eth failed: No such device
2017-05-11T03:45:25.368Z|00034|dpif|WARN|system@ovs-system: failed to add 
br-eth as port: No such device
2017-05-11T03:45:25.368Z|00035|bridge|INFO|bridge br-eth: using datapath ID 
2a51cf9f2841
2017-05-11T03:45:25.368Z|00036|connmgr|INFO|br-eth: added service controller 
"punix:/var/run/openvswitch/br-eth.mgmt"

Change-Id: Ib5ead59bc91453f83549da89937c0d3607e0385e
Signed-off-by: fukaige 
---
 lib/netdev-linux.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index 1e03c75..fae78e5 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -73,6 +73,7 @@
 #include "timer.h"
 #include "unaligned.h"
 #include "openvswitch/vlog.h"
+#include "tnl-ports.h"
 
 VLOG_DEFINE_THIS_MODULE(netdev_linux);
 
@@ -749,6 +750,7 @@ netdev_linux_update(struct netdev_linux *dev,
 dev->get_ifindex_error = 0;
 } else {
 netdev_linux_changed(dev, change->ifi_flags, 0);
+tnl_port_map_delete_ipdev(dev->up.name);
 }
 } else if (rtnetlink_type_is_rtnlgrp_addr(change->nlmsg_type)) {
 /* Invalidates in4, in6. */
-- 
1.8.3.1


___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v3] tnl-ports: Remove netdevs in netdev_hash when deleted

2017-08-08 Thread fukaige


> -Original Message-
> From: Ben Pfaff [mailto:b...@ovn.org]
> Sent: Wednesday, August 09, 2017 4:06 AM
> To: fukaige
> Cc: d...@openvswitch.org; Zhaoshenglong
> Subject: Re: [PATCH v3] tnl-ports: Remove netdevs in netdev_hash when
> deleted
> 
> On Thu, Jul 13, 2017 at 02:04:53AM +, fukaige wrote:
> >
> >
> > > -Original Message-
> > > From: fukaige
> > > Sent: Tuesday, July 11, 2017 3:34 PM
> > > To: 'Ben Pfaff'
> > > Cc: d...@openvswitch.org; Zhaoshenglong
> > > Subject: RE: [PATCH v3] tnl-ports: Remove netdevs in netdev_hash
> > > when deleted
> > >
> > >
> > > > -Original Message-
> > > > From: Ben Pfaff [mailto:b...@ovn.org]
> > > > Sent: Saturday, July 08, 2017 5:54 AM
> > > > To: fukaige
> > > > Cc: d...@openvswitch.org; Zhaoshenglong
> > > > Subject: Re: [PATCH v3] tnl-ports: Remove netdevs in netdev_hash
> > > > when deleted
> > > >
> > > > On Thu, Jun 15, 2017 at 09:58:57AM +0800, fukaige wrote:
> > > > > tart a virtual machine with its backend tap device attached to a
> > > > > brought up
> > > > linux bridge.
> > > > > If we delete the linux bridge when vm is still running, we'll
> > > > > get the following error when trying to create a ovs bridge with the 
> > > > > same
> name.
> > > > >
> > > > > The reason is that ovs-router subsystem add the linux bridge
> > > > > into netdev_shash, but does not remove it when the bridge is
> > > > > deleted in the situation. When the bridge is deleted, ovs will
> > > > > receive a RTM_DELLINK msg,
> > > > take this chance to remove the bridge in netdev_shash.
> > > > >
> > > > > ovs-vsctl: Error detected while setting up 'br-eth'.  See
> > > > > ovs-vswitchd log for
> > > > details.
> > > > >
> > > > > ovs-vswitchd log:
> > > > >
> > >
> 2017-05-11T03:45:25.293Z|00026|ofproto_dpif|INFO|system@ovs-system:
> > > > > Datapath supports recirculation
> > > > >
> > >
> 2017-05-11T03:45:25.293Z|00027|ofproto_dpif|INFO|system@ovs-system:
> > > > > MPLS label stack length probed as 1
> > > > >
> > >
> 2017-05-11T03:45:25.293Z|00028|ofproto_dpif|INFO|system@ovs-system:
> > > > > Datapath supports unique flow ids
> > > > >
> > >
> 2017-05-11T03:45:25.293Z|00029|ofproto_dpif|INFO|system@ovs-system:
> > > > > Datapath supports ct_state
> > > > >
> > >
> 2017-05-11T03:45:25.293Z|00030|ofproto_dpif|INFO|system@ovs-system:
> > > > > Datapath supports ct_zone
> > > > >
> > >
> 2017-05-11T03:45:25.293Z|00031|ofproto_dpif|INFO|system@ovs-system:
> > > > > Datapath supports ct_mark
> > > > >
> > >
> 2017-05-11T03:45:25.293Z|00032|ofproto_dpif|INFO|system@ovs-system:
> > > > > Datapath supports ct_label
> > > > > 2017-05-11T03:45:25.364Z|1|ofproto_dpif_upcall(handler226)|I
> > > > > NFO| re ceived packet on unassociated datapath port 0
> > > > > 2017-05-11T03:45:25.368Z|00033|netdev_linux|WARN|ethtool
> command
> > > > > ETHTOOL_GFLAGS on network device br-eth failed: No such device
> > > > > 2017-05-11T03:45:25.368Z|00034|dpif|WARN|system@ovs-system:
> > > > > failed
> > > > to
> > > > > add br-eth as port: No such device
> > > > > 2017-05-11T03:45:25.368Z|00035|bridge|INFO|bridge br-eth: using
> > > > > datapath ID 2a51cf9f2841
> > > > > 2017-05-11T03:45:25.368Z|00036|connmgr|INFO|br-eth: added
> > > > > service
> > > > controller "punix:/var/run/openvswitch/br-eth.mgmt"
> > > > >
> > > > > Signed-off-by: fukaige 
> > > >
> > > > Thank you for the updated patch.
> > > >
> > > > This patch raises some difficulties.  First, it uses rtnetlink,
> > > > which is Linux specific.  We do not want tnl-ports to be Linux-specific.
> > > > The more generic alternative is ifnotifier, but it provides no
> > > > information about the change that took place, so it is harder to
> > > > deal with.  Second, it will dereference a null pointer if the 'change'
> > > > passed in is null, which can happen if the sy

[ovs-dev] [PATCH v3] route-table: Remove netdevs in netdev_hash when deleted

2017-08-09 Thread fukaige
From: Kaige Fu 

Start a virtual machine with its backend tap device attached to a brought up 
linux bridge.
If we delete the linux bridge when vm is still running, we'll get the following 
error when
trying to create a ovs bridge with the same name.

The reason is that ovs-router subsystem add the linux bridge into netdev_shash, 
but does
not remove it when the bridge is deleted in the situation. When the bridge is 
deleted, ovs
will receive a RTM_DELLINK msg, take this chance to remove the bridge in 
netdev_shash.

ovs-vsctl: Error detected while setting up 'br-eth'.  See ovs-vswitchd log for 
details.

ovs-vswitchd log:
2017-05-11T03:45:25.293Z|00026|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports recirculation
2017-05-11T03:45:25.293Z|00027|ofproto_dpif|INFO|system@ovs-system: MPLS label 
stack length probed as 1
2017-05-11T03:45:25.293Z|00028|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports unique flow ids
2017-05-11T03:45:25.293Z|00029|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_state
2017-05-11T03:45:25.293Z|00030|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_zone
2017-05-11T03:45:25.293Z|00031|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_mark
2017-05-11T03:45:25.293Z|00032|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_label
2017-05-11T03:45:25.364Z|1|ofproto_dpif_upcall(handler226)|INFO|received 
packet on unassociated datapath port 0
2017-05-11T03:45:25.368Z|00033|netdev_linux|WARN|ethtool command ETHTOOL_GFLAGS 
on network device br-eth failed: No such device
2017-05-11T03:45:25.368Z|00034|dpif|WARN|system@ovs-system: failed to add 
br-eth as port: No such device
2017-05-11T03:45:25.368Z|00035|bridge|INFO|bridge br-eth: using datapath ID 
2a51cf9f2841
2017-05-11T03:45:25.368Z|00036|connmgr|INFO|br-eth: added service controller 
"punix:/var/run/openvswitch/br-eth.mgmt"

Signed-off-by: Kaige Fu 
---
 lib/route-table.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/lib/route-table.c b/lib/route-table.c
index 67fda31..5107056 100644
--- a/lib/route-table.c
+++ b/lib/route-table.c
@@ -33,6 +33,7 @@
 #include "ovs-router.h"
 #include "packets.h"
 #include "rtnetlink.h"
+#include "tnl-ports.h"
 #include "openvswitch/vlog.h"
 
 /* Linux 2.6.36 added RTA_MARK, so define it just in case we're building with
@@ -79,6 +80,7 @@ static int route_table_reset(void);
 static void route_table_handle_msg(const struct route_table_msg *);
 static int route_table_parse(struct ofpbuf *, struct route_table_msg *);
 static void route_table_change(const struct route_table_msg *, void *);
+static void route_table_link_del(const struct rtnetlink_change *, void *);
 static void route_map_clear(void);
 
 static void name_table_init(void);
@@ -112,6 +114,8 @@ route_table_init(void)
 nln_notifier_create(nln, RTNLGRP_IPV6_ROUTE,
 (nln_notify_func *) route_table_change, NULL);
 
+rtnetlink_notifier_create(route_table_link_del, NULL);
+
 route_table_reset();
 name_table_init();
 
@@ -297,6 +301,17 @@ route_table_change(const struct route_table_msg *change 
OVS_UNUSED,
 }
 
 static void
+route_table_link_del(const struct rtnetlink_change *change,
+ void *aux OVS_UNUSED)
+{
+if(change && change->nlmsg_type == RTM_DELLINK) {
+if(change->ifname) {
+tnl_port_map_delete_ipdev(change->ifname);
+}
+}
+}
+
+static void
 route_table_handle_msg(const struct route_table_msg *change)
 {
 if (change->relevant && change->nlmsg_type == RTM_NEWROUTE) {
-- 
1.8.3.1


___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v3] route-table: Remove netdevs in netdev_hash when deleted

2017-08-13 Thread fukaige


> -Original Message-
> From: Tonghao Zhang [mailto:xiangxia.m@gmail.com]
> Sent: Thursday, August 10, 2017 9:23 AM
> To: fukaige
> Cc: ovs dev
> Subject: Re: [ovs-dev] [PATCH v3] route-table: Remove netdevs in netdev_hash
> when deleted
> 
> why not remove the function of route_table_link_del to name_table_change() ?
> 

Thanks for review. Seems it is a better way to use function of 
name_table_change() instead of
rewriting a new function. 
I will modify it in v4 patch.

> On Wed, Aug 9, 2017 at 3:41 PM, fukaige  wrote:
> > From: Kaige Fu 
> >
> > Start a virtual machine with its backend tap device attached to a brought up
> linux bridge.
> > If we delete the linux bridge when vm is still running, we'll get the
> > following error when trying to create a ovs bridge with the same name.
> >
> > The reason is that ovs-router subsystem add the linux bridge into
> > netdev_shash, but does not remove it when the bridge is deleted in the
> > situation. When the bridge is deleted, ovs will receive a RTM_DELLINK msg,
> take this chance to remove the bridge in netdev_shash.
> >
> > ovs-vsctl: Error detected while setting up 'br-eth'.  See ovs-vswitchd log 
> > for
> details.
> >
> > ovs-vswitchd log:
> > 2017-05-11T03:45:25.293Z|00026|ofproto_dpif|INFO|system@ovs-system:
> > Datapath supports recirculation
> > 2017-05-11T03:45:25.293Z|00027|ofproto_dpif|INFO|system@ovs-system:
> > MPLS label stack length probed as 1
> > 2017-05-11T03:45:25.293Z|00028|ofproto_dpif|INFO|system@ovs-system:
> > Datapath supports unique flow ids
> > 2017-05-11T03:45:25.293Z|00029|ofproto_dpif|INFO|system@ovs-system:
> > Datapath supports ct_state
> > 2017-05-11T03:45:25.293Z|00030|ofproto_dpif|INFO|system@ovs-system:
> > Datapath supports ct_zone
> > 2017-05-11T03:45:25.293Z|00031|ofproto_dpif|INFO|system@ovs-system:
> > Datapath supports ct_mark
> > 2017-05-11T03:45:25.293Z|00032|ofproto_dpif|INFO|system@ovs-system:
> > Datapath supports ct_label
> > 2017-05-11T03:45:25.364Z|1|ofproto_dpif_upcall(handler226)|INFO|re
> > ceived packet on unassociated datapath port 0
> > 2017-05-11T03:45:25.368Z|00033|netdev_linux|WARN|ethtool command
> > ETHTOOL_GFLAGS on network device br-eth failed: No such device
> > 2017-05-11T03:45:25.368Z|00034|dpif|WARN|system@ovs-system: failed
> to
> > add br-eth as port: No such device
> > 2017-05-11T03:45:25.368Z|00035|bridge|INFO|bridge br-eth: using
> > datapath ID 2a51cf9f2841
> > 2017-05-11T03:45:25.368Z|00036|connmgr|INFO|br-eth: added service
> controller "punix:/var/run/openvswitch/br-eth.mgmt"
> >
> > Signed-off-by: Kaige Fu 
> > ---
> >  lib/route-table.c | 15 +++
> >  1 file changed, 15 insertions(+)
> >
> > diff --git a/lib/route-table.c b/lib/route-table.c index
> > 67fda31..5107056 100644
> > --- a/lib/route-table.c
> > +++ b/lib/route-table.c
> > @@ -33,6 +33,7 @@
> >  #include "ovs-router.h"
> >  #include "packets.h"
> >  #include "rtnetlink.h"
> > +#include "tnl-ports.h"
> >  #include "openvswitch/vlog.h"
> >
> >  /* Linux 2.6.36 added RTA_MARK, so define it just in case we're
> > building with @@ -79,6 +80,7 @@ static int route_table_reset(void);
> > static void route_table_handle_msg(const struct route_table_msg *);
> > static int route_table_parse(struct ofpbuf *, struct route_table_msg
> > *);  static void route_table_change(const struct route_table_msg *,
> > void *);
> > +static void route_table_link_del(const struct rtnetlink_change *,
> > +void *);
> >  static void route_map_clear(void);
> >
> >  static void name_table_init(void);
> > @@ -112,6 +114,8 @@ route_table_init(void)
> >  nln_notifier_create(nln, RTNLGRP_IPV6_ROUTE,
> >  (nln_notify_func *) route_table_change,
> > NULL);
> >
> > +rtnetlink_notifier_create(route_table_link_del, NULL);
> > +
> >  route_table_reset();
> >  name_table_init();
> >
> > @@ -297,6 +301,17 @@ route_table_change(const struct route_table_msg
> > *change OVS_UNUSED,  }
> >
> >  static void
> > +route_table_link_del(const struct rtnetlink_change *change,
> > + void *aux OVS_UNUSED) {
> > +if(change && change->nlmsg_type == RTM_DELLINK) {
> > +if(change->ifname) {
> > +tnl_port_map_delete_ipdev(change->ifname);
> > +}
> > +}
> > +}
> > +
> > +static void
> >  route_table_handle_msg(const struct route_table_msg *change)  {
> >  if (change->relevant && change->nlmsg_type == RTM_NEWROUTE) {
> > --
> > 1.8.3.1
> >
> >
> > ___
> > dev mailing list
> > d...@openvswitch.org
> > https://mail.openvswitch.org/mailman/listinfo/ovs-dev
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v4] route-table: Remove netdevs in netdev_hash when deleted

2017-08-14 Thread fukaige
From: Kaige Fu 

Start a virtual machine with its backend tap device attached to a brought up 
linux bridge.
If we delete the linux bridge when vm is still running, we'll get the following 
error when
trying to create a ovs bridge with the same name.

The reason is that ovs-router subsystem add the linux bridge into netdev_shash, 
but does
not remove it when the bridge is deleted in the situation. When the bridge is 
deleted, ovs
will receive a RTM_DELLINK msg, take this chance to remove the bridge in 
netdev_shash.

ovs-vsctl: Error detected while setting up 'br-eth'.  See ovs-vswitchd log for 
details.

ovs-vswitchd log:
2017-05-11T03:45:25.293Z|00026|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports recirculation
2017-05-11T03:45:25.293Z|00027|ofproto_dpif|INFO|system@ovs-system: MPLS label 
stack length probed as 1
2017-05-11T03:45:25.293Z|00028|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports unique flow ids
2017-05-11T03:45:25.293Z|00029|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_state
2017-05-11T03:45:25.293Z|00030|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_zone
2017-05-11T03:45:25.293Z|00031|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_mark
2017-05-11T03:45:25.293Z|00032|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_label
2017-05-11T03:45:25.364Z|1|ofproto_dpif_upcall(handler226)|INFO|received 
packet on unassociated datapath port 0
2017-05-11T03:45:25.368Z|00033|netdev_linux|WARN|ethtool command ETHTOOL_GFLAGS 
on network device br-eth failed: No such device
2017-05-11T03:45:25.368Z|00034|dpif|WARN|system@ovs-system: failed to add 
br-eth as port: No such device
2017-05-11T03:45:25.368Z|00035|bridge|INFO|bridge br-eth: using datapath ID 
2a51cf9f2841
2017-05-11T03:45:25.368Z|00036|connmgr|INFO|br-eth: added service controller 
"punix:/var/run/openvswitch/br-eth.mgmt"

Signed-off-by: Kaige Fu 
---
 lib/route-table.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/route-table.c b/lib/route-table.c
index 67fda31..4e40c37 100644
--- a/lib/route-table.c
+++ b/lib/route-table.c
@@ -33,6 +33,7 @@
 #include "ovs-router.h"
 #include "packets.h"
 #include "rtnetlink.h"
+#include "tnl-ports.h"
 #include "openvswitch/vlog.h"
 
 /* Linux 2.6.36 added RTA_MARK, so define it just in case we're building with
@@ -333,10 +334,16 @@ name_table_init(void)
 
 
 static void
-name_table_change(const struct rtnetlink_change *change OVS_UNUSED,
+name_table_change(const struct rtnetlink_change *change,
   void *aux OVS_UNUSED)
 {
 /* Changes to interface status can cause routing table changes that some
  * versions of the linux kernel do not advertise for some reason. */
 route_table_valid = false;
+
+if (change && change->nlmsg_type == RTM_DELLINK) {
+if (change->ifname) {
+tnl_port_map_delete_ipdev(change->ifname);
+}
+}
 }
-- 
1.8.3.1


___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH] dpif: Remove duplicated word in comment for dpif_recv()

2017-08-25 Thread fukaige
From: Kaige Fu 

Signed-off-by: Kaige Fu 
---
 lib/dpif.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/dpif.c b/lib/dpif.c
index 79b2e6c..a4471d5 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1547,11 +1547,11 @@ dpif_set_config(struct dpif *dpif, const struct smap 
*cfg)
 return error;
 }
 
-/* Polls for an upcall from 'dpif' for an upcall handler.  Since there
- * there can be multiple poll loops, 'handler_id' is needed as index to
- * identify the corresponding poll loop.  If successful, stores the upcall
- * into '*upcall', using 'buf' for storage.  Should only be called if
- * 'recv_set' has been used to enable receiving packets from 'dpif'.
+/* Polls for an upcall from 'dpif' for an upcall handler.  Since there can
+ * be multiple poll loops, 'handler_id' is needed as index to identify the
+ * corresponding poll loop.  If successful, stores the upcall into '*upcall',
+ * using 'buf' for storage.  Should only be called if 'recv_set' has been used
+ * to enable receiving packets from 'dpif'.
  *
  * 'upcall->key' and 'upcall->userdata' point into data in the caller-provided
  * 'buf', so their memory cannot be freed separately from 'buf'.
-- 
1.8.3.1


___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v1] netdev-linux: Remove device in netdev_shash when deleted

2017-06-11 Thread fukaige
Thanks for review, I will consider your suggestion and push v2 patch as soon as 
possible.

Thanks

fukaige

> -Original Message-
> From: Ben Pfaff [mailto:b...@ovn.org]
> Sent: Friday, June 09, 2017 4:35 AM
> To: fukaige
> Cc: d...@openvswitch.org
> Subject: Re: [PATCH v1] netdev-linux: Remove device in netdev_shash when
> deleted
> 
> On Wed, May 31, 2017 at 09:30:43AM +0800, fukaige wrote:
> > Start a virtual machine with its backend tap device attached to a brought up
> linux bridge.
> > If we delete the linux bridge when vm is still running, we'll get the
> > following error when trying to create a ovs bridge with the same name.
> >
> > The reason is that ovs-router subsystem add the linux bridge into
> > netdev_shash, but does not remove it when the bridge is deleted in the
> > situation. When the bridge is deleted, ovs will receive a RTM_DELLINK msg,
> take this chance to remove the bridge in netdev_shash.
> >
> > ovs-vsctl: Error detected while setting up 'br-eth'.  See ovs-vswitchd log 
> > for
> details.
> >
> > ovs-vswitchd log:
> > 2017-05-11T03:45:25.293Z|00026|ofproto_dpif|INFO|system@ovs-system:
> > Datapath supports recirculation
> > 2017-05-11T03:45:25.293Z|00027|ofproto_dpif|INFO|system@ovs-system:
> > MPLS label stack length probed as 1
> > 2017-05-11T03:45:25.293Z|00028|ofproto_dpif|INFO|system@ovs-system:
> > Datapath supports unique flow ids
> > 2017-05-11T03:45:25.293Z|00029|ofproto_dpif|INFO|system@ovs-system:
> > Datapath supports ct_state
> > 2017-05-11T03:45:25.293Z|00030|ofproto_dpif|INFO|system@ovs-system:
> > Datapath supports ct_zone
> > 2017-05-11T03:45:25.293Z|00031|ofproto_dpif|INFO|system@ovs-system:
> > Datapath supports ct_mark
> > 2017-05-11T03:45:25.293Z|00032|ofproto_dpif|INFO|system@ovs-system:
> > Datapath supports ct_label
> > 2017-05-11T03:45:25.364Z|1|ofproto_dpif_upcall(handler226)|INFO|re
> > ceived packet on unassociated datapath port 0
> > 2017-05-11T03:45:25.368Z|00033|netdev_linux|WARN|ethtool command
> > ETHTOOL_GFLAGS on network device br-eth failed: No such device
> > 2017-05-11T03:45:25.368Z|00034|dpif|WARN|system@ovs-system: failed
> to
> > add br-eth as port: No such device
> > 2017-05-11T03:45:25.368Z|00035|bridge|INFO|bridge br-eth: using
> > datapath ID 2a51cf9f2841
> > 2017-05-11T03:45:25.368Z|00036|connmgr|INFO|br-eth: added service
> controller "punix:/var/run/openvswitch/br-eth.mgmt"
> >
> > Change-Id: Ib5ead59bc91453f83549da89937c0d3607e0385e
> > Signed-off-by: fukaige 
> 
> Thanks for identifying the problem and coming up with a fix.
> 
> The fix looks to me like it works at the wrong level of abstraction.
> netdev-linux and tnl-port-map are not directly related, and I believe that the
> same problem could arise with other kinds of netdevs and tnl-port-map.  So, I
> think that it would be better if tnl-ports itself registered a callback upon 
> device
> destruction, for example via a call to
> if_notifier_create() from tnl_port_map_init().
> 
> Thanks,
> 
> Ben.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v2] tnl-ports: Remove netdevs in netdev_hash when deleted

2017-06-13 Thread fukaige
Start a virtual machine with its backend tap device attached to a brought up 
linux bridge.
If we delete the linux bridge when vm is still running, we'll get the following 
error when
trying to create a ovs bridge with the same name.

The reason is that ovs-router subsystem add the linux bridge into netdev_shash, 
but does
not remove it when the bridge is deleted in the situation. When the bridge is 
deleted, ovs
will receive a RTM_DELLINK msg, take this chance to remove the bridge in 
netdev_shash.

ovs-vsctl: Error detected while setting up 'br-eth'.  See ovs-vswitchd log for 
details.

ovs-vswitchd log:
2017-05-11T03:45:25.293Z|00026|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports recirculation
2017-05-11T03:45:25.293Z|00027|ofproto_dpif|INFO|system@ovs-system: MPLS label 
stack length probed as 1
2017-05-11T03:45:25.293Z|00028|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports unique flow ids
2017-05-11T03:45:25.293Z|00029|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_state
2017-05-11T03:45:25.293Z|00030|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_zone
2017-05-11T03:45:25.293Z|00031|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_mark
2017-05-11T03:45:25.293Z|00032|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_label
2017-05-11T03:45:25.364Z|1|ofproto_dpif_upcall(handler226)|INFO|received 
packet on unassociated datapath port 0
2017-05-11T03:45:25.368Z|00033|netdev_linux|WARN|ethtool command ETHTOOL_GFLAGS 
on network device br-eth failed: No such device
2017-05-11T03:45:25.368Z|00034|dpif|WARN|system@ovs-system: failed to add 
br-eth as port: No such device
2017-05-11T03:45:25.368Z|00035|bridge|INFO|bridge br-eth: using datapath ID 
2a51cf9f2841
2017-05-11T03:45:25.368Z|00036|connmgr|INFO|br-eth: added service controller 
"punix:/var/run/openvswitch/br-eth.mgmt"

Signed-off-by: fukaige 
---
 lib/tnl-ports.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/lib/tnl-ports.c b/lib/tnl-ports.c
index bcf4b94..75b5909 100644
--- a/lib/tnl-ports.c
+++ b/lib/tnl-ports.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "classifier.h"
 #include "dynamic-string.h"
@@ -33,6 +34,7 @@
 #include "ovs-thread.h"
 #include "unixctl.h"
 #include "util.h"
+#include "rtnetlink.h"
 
 static struct ovs_mutex mutex = OVS_MUTEX_INITIALIZER;
 static struct classifier cls;   /* Tunnel ports. */
@@ -463,11 +465,19 @@ tnl_port_map_run(void)
 ovs_mutex_unlock(&mutex);
 }
 
+static void
+rtnetlink_del_cb(const struct rtnetlink_change *change, void *aux OVS_UNUSED)
+{
+if(change->nlmsg_type == RTM_DELLINK)
+tnl_port_map_delete_ipdev(change->ifname);
+}
+
 void
 tnl_port_map_init(void)
 {
 classifier_init(&cls, flow_segment_u64s);
 list_init(&addr_list);
 list_init(&port_list);
+rtnetlink_notifier_create(rtnetlink_del_cb, NULL);
 unixctl_command_register("tnl/ports/show", "-v", 0, 1, tnl_port_show, 
NULL);
 }
-- 
1.8.3.1


___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v2] tnl-ports: Remove netdevs in netdev_hash when deleted

2017-06-14 Thread fukaige


> -Original Message-
> From: Ben Pfaff [mailto:b...@ovn.org]
> Sent: Thursday, June 15, 2017 5:25 AM
> To: fukaige
> Cc: d...@openvswitch.org; Zhaoshenglong
> Subject: Re: [PATCH v2] tnl-ports: Remove netdevs in netdev_hash when
> deleted
> 
> On Wed, Jun 14, 2017 at 01:44:37PM +0800, fukaige wrote:
> > Start a virtual machine with its backend tap device attached to a brought up
> linux bridge.
> > If we delete the linux bridge when vm is still running, we'll get the
> > following error when trying to create a ovs bridge with the same name.
> >
> > The reason is that ovs-router subsystem add the linux bridge into
> > netdev_shash, but does not remove it when the bridge is deleted in the
> > situation. When the bridge is deleted, ovs will receive a RTM_DELLINK msg,
> take this chance to remove the bridge in netdev_shash.
> 
> Thanks for the patch.
> 
> This has multiple patch rejects.  Is it against current master?  Please rebase
> it and repost.
> 

It is against branch-2.5. I will rebase it against current master and repost.

> Thanks again!
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v3] tnl-ports: Remove netdevs in netdev_hash when deleted

2017-06-14 Thread fukaige
tart a virtual machine with its backend tap device attached to a brought up 
linux bridge.
If we delete the linux bridge when vm is still running, we'll get the following 
error when
trying to create a ovs bridge with the same name.

The reason is that ovs-router subsystem add the linux bridge into netdev_shash, 
but does
not remove it when the bridge is deleted in the situation. When the bridge is 
deleted, ovs
will receive a RTM_DELLINK msg, take this chance to remove the bridge in 
netdev_shash.

ovs-vsctl: Error detected while setting up 'br-eth'.  See ovs-vswitchd log for 
details.

ovs-vswitchd log:
2017-05-11T03:45:25.293Z|00026|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports recirculation
2017-05-11T03:45:25.293Z|00027|ofproto_dpif|INFO|system@ovs-system: MPLS label 
stack length probed as 1
2017-05-11T03:45:25.293Z|00028|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports unique flow ids
2017-05-11T03:45:25.293Z|00029|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_state
2017-05-11T03:45:25.293Z|00030|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_zone
2017-05-11T03:45:25.293Z|00031|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_mark
2017-05-11T03:45:25.293Z|00032|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_label
2017-05-11T03:45:25.364Z|1|ofproto_dpif_upcall(handler226)|INFO|received 
packet on unassociated datapath port 0
2017-05-11T03:45:25.368Z|00033|netdev_linux|WARN|ethtool command ETHTOOL_GFLAGS 
on network device br-eth failed: No such device
2017-05-11T03:45:25.368Z|00034|dpif|WARN|system@ovs-system: failed to add 
br-eth as port: No such device
2017-05-11T03:45:25.368Z|00035|bridge|INFO|bridge br-eth: using datapath ID 
2a51cf9f2841
2017-05-11T03:45:25.368Z|00036|connmgr|INFO|br-eth: added service controller 
"punix:/var/run/openvswitch/br-eth.mgmt"

Signed-off-by: fukaige 
---
 lib/tnl-ports.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/lib/tnl-ports.c b/lib/tnl-ports.c
index 4a07dcb..5f5791c 100644
--- a/lib/tnl-ports.c
+++ b/lib/tnl-ports.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "classifier.h"
 #include "openvswitch/dynamic-string.h"
@@ -33,6 +34,7 @@
 #include "ovs-thread.h"
 #include "unixctl.h"
 #include "util.h"
+#include "rtnetlink.h"
 
 static struct ovs_mutex mutex = OVS_MUTEX_INITIALIZER;
 static struct classifier cls;   /* Tunnel ports. */
@@ -499,11 +501,19 @@ tnl_port_map_run(void)
 ovs_mutex_unlock(&mutex);
 }
 
+static void
+rtnetlink_del_cb(const struct rtnetlink_change *change, void *aux OVS_UNUSED)
+{
+if(change->nlmsg_type == RTM_DELLINK)
+tnl_port_map_delete_ipdev(change->ifname);
+}
+
 void
 tnl_port_map_init(void)
 {
 classifier_init(&cls, flow_segment_u64s);
 ovs_list_init(&addr_list);
 ovs_list_init(&port_list);
+rtnetlink_notifier_create(rtnetlink_del_cb, NULL);
 unixctl_command_register("tnl/ports/show", "-v", 0, 1, tnl_port_show, 
NULL);
 }
-- 
1.8.3.1


___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [resend PATCH v3] tnl-ports: Remove netdevs in netdev_hash when deleted

2017-06-26 Thread fukaige
tart a virtual machine with its backend tap device attached to a brought up 
linux bridge.
If we delete the linux bridge when vm is still running, we'll get the following 
error when
trying to create a ovs bridge with the same name.

The reason is that ovs-router subsystem add the linux bridge into netdev_shash, 
but does
not remove it when the bridge is deleted in the situation. When the bridge is 
deleted, ovs
will receive a RTM_DELLINK msg, take this chance to remove the bridge in 
netdev_shash.

ovs-vsctl: Error detected while setting up 'br-eth'.  See ovs-vswitchd log for 
details.

ovs-vswitchd log:
2017-05-11T03:45:25.293Z|00026|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports recirculation
2017-05-11T03:45:25.293Z|00027|ofproto_dpif|INFO|system@ovs-system: MPLS label 
stack length probed as 1
2017-05-11T03:45:25.293Z|00028|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports unique flow ids
2017-05-11T03:45:25.293Z|00029|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_state
2017-05-11T03:45:25.293Z|00030|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_zone
2017-05-11T03:45:25.293Z|00031|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_mark
2017-05-11T03:45:25.293Z|00032|ofproto_dpif|INFO|system@ovs-system: Datapath 
supports ct_label
2017-05-11T03:45:25.364Z|1|ofproto_dpif_upcall(handler226)|INFO|received 
packet on unassociated datapath port 0
2017-05-11T03:45:25.368Z|00033|netdev_linux|WARN|ethtool command ETHTOOL_GFLAGS 
on network device br-eth failed: No such device
2017-05-11T03:45:25.368Z|00034|dpif|WARN|system@ovs-system: failed to add 
br-eth as port: No such device
2017-05-11T03:45:25.368Z|00035|bridge|INFO|bridge br-eth: using datapath ID 
2a51cf9f2841
2017-05-11T03:45:25.368Z|00036|connmgr|INFO|br-eth: added service controller 
"punix:/var/run/openvswitch/br-eth.mgmt"

Signed-off-by: fukaige 
---
 lib/tnl-ports.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/lib/tnl-ports.c b/lib/tnl-ports.c
index 4a07dcb..5f5791c 100644
--- a/lib/tnl-ports.c
+++ b/lib/tnl-ports.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "classifier.h"
 #include "openvswitch/dynamic-string.h"
@@ -33,6 +34,7 @@
 #include "ovs-thread.h"
 #include "unixctl.h"
 #include "util.h"
+#include "rtnetlink.h"
 
 static struct ovs_mutex mutex = OVS_MUTEX_INITIALIZER;
 static struct classifier cls;   /* Tunnel ports. */
@@ -499,11 +501,19 @@ tnl_port_map_run(void)
 ovs_mutex_unlock(&mutex);
 }
 
+static void
+rtnetlink_del_cb(const struct rtnetlink_change *change, void *aux OVS_UNUSED)
+{
+if(change->nlmsg_type == RTM_DELLINK)
+tnl_port_map_delete_ipdev(change->ifname);
+}
+
 void
 tnl_port_map_init(void)
 {
 classifier_init(&cls, flow_segment_u64s);
 ovs_list_init(&addr_list);
 ovs_list_init(&port_list);
+rtnetlink_notifier_create(rtnetlink_del_cb, NULL);
 unixctl_command_register("tnl/ports/show", "-v", 0, 1, tnl_port_show, 
NULL);
 }
-- 
1.8.3.1


___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v3] tnl-ports: Remove netdevs in netdev_hash when deleted

2017-07-11 Thread fukaige

> -Original Message-
> From: Ben Pfaff [mailto:b...@ovn.org]
> Sent: Saturday, July 08, 2017 5:54 AM
> To: fukaige
> Cc: d...@openvswitch.org; Zhaoshenglong
> Subject: Re: [PATCH v3] tnl-ports: Remove netdevs in netdev_hash when
> deleted
> 
> On Thu, Jun 15, 2017 at 09:58:57AM +0800, fukaige wrote:
> > tart a virtual machine with its backend tap device attached to a brought up
> linux bridge.
> > If we delete the linux bridge when vm is still running, we'll get the
> > following error when trying to create a ovs bridge with the same name.
> >
> > The reason is that ovs-router subsystem add the linux bridge into
> > netdev_shash, but does not remove it when the bridge is deleted in the
> > situation. When the bridge is deleted, ovs will receive a RTM_DELLINK msg,
> take this chance to remove the bridge in netdev_shash.
> >
> > ovs-vsctl: Error detected while setting up 'br-eth'.  See ovs-vswitchd log 
> > for
> details.
> >
> > ovs-vswitchd log:
> > 2017-05-11T03:45:25.293Z|00026|ofproto_dpif|INFO|system@ovs-system:
> > Datapath supports recirculation
> > 2017-05-11T03:45:25.293Z|00027|ofproto_dpif|INFO|system@ovs-system:
> > MPLS label stack length probed as 1
> > 2017-05-11T03:45:25.293Z|00028|ofproto_dpif|INFO|system@ovs-system:
> > Datapath supports unique flow ids
> > 2017-05-11T03:45:25.293Z|00029|ofproto_dpif|INFO|system@ovs-system:
> > Datapath supports ct_state
> > 2017-05-11T03:45:25.293Z|00030|ofproto_dpif|INFO|system@ovs-system:
> > Datapath supports ct_zone
> > 2017-05-11T03:45:25.293Z|00031|ofproto_dpif|INFO|system@ovs-system:
> > Datapath supports ct_mark
> > 2017-05-11T03:45:25.293Z|00032|ofproto_dpif|INFO|system@ovs-system:
> > Datapath supports ct_label
> > 2017-05-11T03:45:25.364Z|1|ofproto_dpif_upcall(handler226)|INFO|re
> > ceived packet on unassociated datapath port 0
> > 2017-05-11T03:45:25.368Z|00033|netdev_linux|WARN|ethtool command
> > ETHTOOL_GFLAGS on network device br-eth failed: No such device
> > 2017-05-11T03:45:25.368Z|00034|dpif|WARN|system@ovs-system: failed
> to
> > add br-eth as port: No such device
> > 2017-05-11T03:45:25.368Z|00035|bridge|INFO|bridge br-eth: using
> > datapath ID 2a51cf9f2841
> > 2017-05-11T03:45:25.368Z|00036|connmgr|INFO|br-eth: added service
> controller "punix:/var/run/openvswitch/br-eth.mgmt"
> >
> > Signed-off-by: fukaige 
> 
> Thank you for the updated patch.
> 
> This patch raises some difficulties.  First, it uses rtnetlink, which is Linux
> specific.  We do not want tnl-ports to be Linux-specific.  The more generic
> alternative is ifnotifier, but it provides no information about the change 
> that
> took place, so it is harder to deal with.  Second, it will dereference a null
> pointer if the 'change' passed in is null, which can happen if the system is 
> busy
> or devices are changing quickly, as described in rtnetlink.h:
> 
> /* Function called to report that a netdev has changed.  'change'
> describes the
>  * specific change.  It may be null if the buffer of change information
>  * overflowed, in which case the function must assume that every device
> may
>  * have changed.  'aux' is as specified in the call to
>  * rtnetlink_notifier_register().  */
> typedef
> void rtnetlink_notify_func(const struct rtnetlink_change *change,
>void *aux);
> 
> I am not sure the best way to proceed.  One way would be to revamp ifnotifier
> so that it provides information on the device that changed and the kind of
> change, and then adapt each of the implementations to pass that along as well.
> Other approaches along these lines are also possible.
> 
> Another approach might be to notify the ovs-router subsystem when a bridge is
> deleted, so that it can drop all of the references it has for that bridge.  I
> haven't looked into how much work this would be.
> 
> What do you think?
> 
> Thanks,
> 
> Ben.

Thanks for your review.

I prefer the second approach you mentioned. May be we can register a callback 
in ovs-router level, like route_table_init.
When a bridge is deleted, ovs-router subsystem will get a msg, like RTM_DELLINK 
on linux. So it can drop all of the references
it has for that bridge. 

I don't know if there is same bug in other OSes, like bsd, and which type of 
msg will be sent in the situation. 

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v3] tnl-ports: Remove netdevs in netdev_hash when deleted

2017-07-12 Thread fukaige


> -Original Message-
> From: fukaige
> Sent: Tuesday, July 11, 2017 3:34 PM
> To: 'Ben Pfaff'
> Cc: d...@openvswitch.org; Zhaoshenglong
> Subject: RE: [PATCH v3] tnl-ports: Remove netdevs in netdev_hash when
> deleted
> 
> 
> > -Original Message-
> > From: Ben Pfaff [mailto:b...@ovn.org]
> > Sent: Saturday, July 08, 2017 5:54 AM
> > To: fukaige
> > Cc: d...@openvswitch.org; Zhaoshenglong
> > Subject: Re: [PATCH v3] tnl-ports: Remove netdevs in netdev_hash when
> > deleted
> >
> > On Thu, Jun 15, 2017 at 09:58:57AM +0800, fukaige wrote:
> > > tart a virtual machine with its backend tap device attached to a
> > > brought up
> > linux bridge.
> > > If we delete the linux bridge when vm is still running, we'll get
> > > the following error when trying to create a ovs bridge with the same name.
> > >
> > > The reason is that ovs-router subsystem add the linux bridge into
> > > netdev_shash, but does not remove it when the bridge is deleted in
> > > the situation. When the bridge is deleted, ovs will receive a
> > > RTM_DELLINK msg,
> > take this chance to remove the bridge in netdev_shash.
> > >
> > > ovs-vsctl: Error detected while setting up 'br-eth'.  See
> > > ovs-vswitchd log for
> > details.
> > >
> > > ovs-vswitchd log:
> > >
> 2017-05-11T03:45:25.293Z|00026|ofproto_dpif|INFO|system@ovs-system:
> > > Datapath supports recirculation
> > >
> 2017-05-11T03:45:25.293Z|00027|ofproto_dpif|INFO|system@ovs-system:
> > > MPLS label stack length probed as 1
> > >
> 2017-05-11T03:45:25.293Z|00028|ofproto_dpif|INFO|system@ovs-system:
> > > Datapath supports unique flow ids
> > >
> 2017-05-11T03:45:25.293Z|00029|ofproto_dpif|INFO|system@ovs-system:
> > > Datapath supports ct_state
> > >
> 2017-05-11T03:45:25.293Z|00030|ofproto_dpif|INFO|system@ovs-system:
> > > Datapath supports ct_zone
> > >
> 2017-05-11T03:45:25.293Z|00031|ofproto_dpif|INFO|system@ovs-system:
> > > Datapath supports ct_mark
> > >
> 2017-05-11T03:45:25.293Z|00032|ofproto_dpif|INFO|system@ovs-system:
> > > Datapath supports ct_label
> > > 2017-05-11T03:45:25.364Z|1|ofproto_dpif_upcall(handler226)|INFO|
> > > re ceived packet on unassociated datapath port 0
> > > 2017-05-11T03:45:25.368Z|00033|netdev_linux|WARN|ethtool command
> > > ETHTOOL_GFLAGS on network device br-eth failed: No such device
> > > 2017-05-11T03:45:25.368Z|00034|dpif|WARN|system@ovs-system: failed
> > to
> > > add br-eth as port: No such device
> > > 2017-05-11T03:45:25.368Z|00035|bridge|INFO|bridge br-eth: using
> > > datapath ID 2a51cf9f2841
> > > 2017-05-11T03:45:25.368Z|00036|connmgr|INFO|br-eth: added service
> > controller "punix:/var/run/openvswitch/br-eth.mgmt"
> > >
> > > Signed-off-by: fukaige 
> >
> > Thank you for the updated patch.
> >
> > This patch raises some difficulties.  First, it uses rtnetlink, which
> > is Linux specific.  We do not want tnl-ports to be Linux-specific.
> > The more generic alternative is ifnotifier, but it provides no
> > information about the change that took place, so it is harder to deal
> > with.  Second, it will dereference a null pointer if the 'change'
> > passed in is null, which can happen if the system is busy or devices are
> changing quickly, as described in rtnetlink.h:
> >
> > /* Function called to report that a netdev has changed.  'change'
> > describes the
> >  * specific change.  It may be null if the buffer of change information
> >  * overflowed, in which case the function must assume that every
> > device may
> >  * have changed.  'aux' is as specified in the call to
> >  * rtnetlink_notifier_register().  */
> > typedef
> > void rtnetlink_notify_func(const struct rtnetlink_change *change,
> >void *aux);
> >
> > I am not sure the best way to proceed.  One way would be to revamp
> > ifnotifier so that it provides information on the device that changed
> > and the kind of change, and then adapt each of the implementations to pass
> that along as well.
> > Other approaches along these lines are also possible.
> >
> > Another approach might be to notify the ovs-router subsystem when a
> > bridge is deleted, so that it can drop all of the references it has
> > for that bridge.  I haven't looked into how much work this would b