[ovs-dev] [PATCH v2] dpif-netlink: don't allocate per thread netlink sockets

Matteo Croce mcroce at redhat.com
Fri Oct 5 23:49:06 UTC 2018


On Fri, Oct 5, 2018 at 11:27 PM Guru Shetty <guru at ovn.org> wrote:
> I get a segfault with this patch with the following backtrace. I have not investigated.
>
> Program received signal SIGSEGV, Segmentation fault.
> nl_sock_pid (sock=0x0) at lib/netlink-socket.c:1424
> 1424     return sock->pid;
> (gdb) where
> #0  nl_sock_pid (sock=0x0) at lib/netlink-socket.c:1424
> #1  0x000000000052fb79 in dpif_netlink_port_add__ (dpif=dpif at entry=0x89de90, name=name at entry=0x7fffffffdf20 "genev_sys_6081", type=type at entry=OVS_VPORT_TYPE_GENEVE,
>     options=0x7fffffffdee0, port_nop=0x7fffffffdf9c) at lib/dpif-netlink.c:731
> #2  0x000000000052fdc7 in dpif_netlink_port_add_compat (port_nop=0x7fffffffdf9c, netdev=<optimized out>, dpif=0x89de90) at lib/dpif-netlink.c:836
> #3  dpif_netlink_port_add (dpif_=0x89de90, netdev=<optimized out>, port_nop=0x7fffffffdf9c) at lib/dpif-netlink.c:882
> #4  0x00000000004778be in dpif_port_add (dpif=0x89de90, netdev=netdev at entry=0x911830, port_nop=port_nop at entry=0x7fffffffdffc) at lib/dpif.c:579
> #5  0x0000000000426efe in port_add (ofproto_=0x8a97f0, netdev=0x911830) at ofproto/ofproto-dpif.c:3689
> #6  0x000000000041d951 in ofproto_port_add (ofproto=0x8a97f0, netdev=0x911830, ofp_portp=ofp_portp at entry=0x7fffffffe0d8) at ofproto/ofproto.c:2008
> #7  0x000000000040c709 in iface_do_create (errp=0x7fffffffe0e8, netdevp=0x7fffffffe0e0, ofp_portp=0x7fffffffe0d8, iface_cfg=0x8a0620, br=0x8a8bb0) at vswitchd/bridge.c:1803
> #8  iface_create (port_cfg=0x8a4e60, iface_cfg=0x8a0620, br=0x8a8bb0) at vswitchd/bridge.c:1841
> #9  bridge_add_ports__ (br=br at entry=0x8a8bb0, wanted_ports=wanted_ports at entry=0x8a8c90, with_requested_port=with_requested_port at entry=false) at vswitchd/bridge.c:935
> #10 0x000000000040e02f in bridge_add_ports (wanted_ports=0x8a8c90, br=0x8a8bb0) at vswitchd/bridge.c:951
> #11 bridge_reconfigure (ovs_cfg=ovs_cfg at entry=0x8a7fc0) at vswitchd/bridge.c:665
> #12 0x00000000004114b9 in bridge_run () at vswitchd/bridge.c:3023
> #13 0x00000000004080c5 in main (argc=2, argv=0x7fffffffe5e8) at vswitchd/ovs-vswitchd.c:125
>
>

Hi Guru,

I received a similar report on IRC and I have already investigated it.
Can you try if the following patch fixes it?

Fixes: 69c51582f ("dpif-netlink: don't allocate per thread netlink sockets")
Signed-off-by: Matteo Croce <mcroce at redhat.com>
---
 lib/dpif-netlink.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c
index 21315033cc..310bc947db 100644
--- a/lib/dpif-netlink.c
+++ b/lib/dpif-netlink.c
@@ -712,7 +712,7 @@ dpif_netlink_port_add__(struct dpif_netlink *dpif,
const char *name,
     struct dpif_netlink_vport request, reply;
     struct ofpbuf *buf;
     struct nl_sock *socksp = NULL;
-    uint32_t upcall_pids;
+    uint32_t upcall_pids = 0;
     int error = 0;

     if (dpif->handlers) {
@@ -728,7 +728,8 @@ dpif_netlink_port_add__(struct dpif_netlink *dpif,
const char *name,
     request.name = name;

     request.port_no = *port_nop;
-    upcall_pids = nl_sock_pid(socksp);
+    if (socksp)
+        upcall_pids = nl_sock_pid(socksp);
     request.n_upcall_pids = 1;
     request.upcall_pids = &upcall_pids;


--
Matteo Croce
per aspera ad upstream


More information about the dev mailing list