Imported Upstream version 16.07-rc1
[deb_dpdk.git] / debian / patches / ubuntu-backport-38-dpdk-dev-Memory-leak-when-adding-removing-vhost_user-ports.patch
1 Description: backport of dpdk 16.07 fix for LP: #1570466
2
3 Backported from this discussion
4 http://dpdk.org/dev/patchwork/patch/12103/
5 Not accepted yet, but likely to be accepted in some form once tested and
6 confirmed.
7
8 Update 2016-05-17:
9 Moving to 16.04 this now applies as-is without modifications, dropping the
10 former backport changes.
11
12 Also along the discussion vserver-fh is now initialized with -1 to avoid
13 accidentially deleting the first connected port if we delete another not yet
14 connected port.
15
16 Forwarded: yes (based on an upstream discussion)
17 Author: Christian Ehrhardt <christian.ehrhardt@canonical.com>
18 Last-Update: 2016-05-17
19
20 Index: dpdk/lib/librte_vhost/vhost_user/vhost-net-user.c
21 ===================================================================
22 --- dpdk.orig/lib/librte_vhost/vhost_user/vhost-net-user.c
23 +++ dpdk/lib/librte_vhost/vhost_user/vhost-net-user.c
24 @@ -310,6 +310,7 @@ vserver_new_vq_conn(int fd, void *dat, _
25         }
26  
27         vdev_ctx.fh = fh;
28 +       vserver->fh = fh;
29         size = strnlen(vserver->path, PATH_MAX);
30         vhost_set_ifname(vdev_ctx, vserver->path,
31                 size);
32 @@ -486,6 +487,7 @@ rte_vhost_driver_register(const char *pa
33         }
34  
35         vserver->path = strdup(path);
36 +       vserver->fh = -1;
37  
38         ret = fdset_add(&g_vhost_server.fdset, vserver->listenfd,
39                 vserver_new_vq_conn, NULL, vserver);
40 @@ -520,6 +522,11 @@ rte_vhost_driver_unregister(const char *
41  
42         for (i = 0; i < g_vhost_server.vserver_cnt; i++) {
43                 if (!strcmp(g_vhost_server.server[i]->path, path)) {
44 +                       struct vhost_device_ctx ctx;
45 +
46 +                       ctx.fh = g_vhost_server.server[i]->fh;
47 +                       vhost_destroy_device(ctx);
48 +
49                         fdset_del(&g_vhost_server.fdset,
50                                 g_vhost_server.server[i]->listenfd);
51  
52 Index: dpdk/lib/librte_vhost/vhost_user/vhost-net-user.h
53 ===================================================================
54 --- dpdk.orig/lib/librte_vhost/vhost_user/vhost-net-user.h
55 +++ dpdk/lib/librte_vhost/vhost_user/vhost-net-user.h
56 @@ -43,6 +43,7 @@
57  struct vhost_server {
58         char *path; /**< The path the uds is bind to. */
59         int listenfd;     /**< The listener sockfd. */
60 +       uint32_t fh;
61  };
62  
63  /* refer to hw/virtio/vhost-user.c */