X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=debian%2Fpatches%2Ffix-vhost-user-socket-permission.patch;h=932da857af34d07852b00e881a2b6d90e2ec74fe;hb=2b5cfa5c30b4680cfc37c9cd7389bf033218cce1;hp=ab3d6322f7a65b5fef69b493848ec5e4f6e85c65;hpb=e0c51da63f97d9b90bae4ed9cf242ccd06002f71;p=deb_dpdk.git diff --git a/debian/patches/fix-vhost-user-socket-permission.patch b/debian/patches/fix-vhost-user-socket-permission.patch index ab3d6322..932da857 100644 --- a/debian/patches/fix-vhost-user-socket-permission.patch +++ b/debian/patches/fix-vhost-user-socket-permission.patch @@ -25,15 +25,26 @@ Fixes LP: #1546565 So over time we have to check when we can drop it at the price of a config transition - likely OVS 2.6 won't need it anymore. +*Update* + - the handling and lifecycle of this changed in Openvswitch 2.7 so we can no + more use internal_config. + - Also the upstreaming was aborted as that now clearly goes towards client + mode vhost sockets for this (and other issues). + - But until that is fully working we have to carry the workaround. + - Updated to work with Openvswitch 2.7 (and backward compatible to 2.6) + +*Update* + - in 17.05 the patch now needs to be hooked up on a different place in vhost + socket.c + - also the former rebase dropped a create socket call which is now restored + Forwarded: yes Author: Christian Ehrhardt -Last-Update: 2016-07-25 +Last-Update: 2017-08-23 -diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst -index 7712bd2..28776b9 100644 --- a/doc/guides/testpmd_app_ug/run_app.rst +++ b/doc/guides/testpmd_app_ug/run_app.rst -@@ -156,6 +156,25 @@ See the DPDK Getting Started Guides for more information on these options. +@@ -156,6 +156,25 @@ See the DPDK Getting Started Guides for Use malloc instead of hugetlbfs. @@ -59,8 +70,6 @@ index 7712bd2..28776b9 100644 Testpmd Command-line Options ---------------------------- -diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c -index 481c732..2126140 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -95,6 +95,8 @@ eal_long_options[] = { @@ -72,30 +81,6 @@ index 481c732..2126140 100644 {0, 0, NULL, 0 } }; -@@ -166,6 +168,8 @@ eal_reset_internal_config(struct internal_config *internal_cfg) - #endif - internal_cfg->vmware_tsc_map = 0; - internal_cfg->create_uio_dev = 0; -+ internal_cfg->vhost_sock_owner = NULL; -+ internal_cfg->vhost_sock_perm = NULL; - } - - static int -diff --git a/lib/librte_eal/common/eal_internal_cfg.h b/lib/librte_eal/common/eal_internal_cfg.h -index 5f1367e..bdf34e3 100644 ---- a/lib/librte_eal/common/eal_internal_cfg.h -+++ b/lib/librte_eal/common/eal_internal_cfg.h -@@ -83,6 +83,8 @@ struct internal_config { - volatile enum rte_intr_mode vfio_intr_mode; - const char *hugefile_prefix; /**< the base filename of hugetlbfs files */ - const char *hugepage_dir; /**< specific hugetlbfs directory to use */ -+ const char *vhost_sock_owner; /**< owner:group of vhost_user sockets */ -+ const char *vhost_sock_perm; /**< permissions of vhost_user sockets */ - - unsigned num_hugepage_sizes; /**< how many sizes on this system */ - struct hugepage_info hugepage_info[MAX_HUGEPAGE_SIZES]; -diff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h -index a881c62..1161083 100644 --- a/lib/librte_eal/common/eal_options.h +++ b/lib/librte_eal/common/eal_options.h @@ -83,6 +83,10 @@ enum { @@ -109,13 +94,11 @@ index a881c62..1161083 100644 OPT_LONG_MAX_NUM }; -diff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h -index a71d6f5..506cf24 100644 --- a/lib/librte_eal/common/include/rte_eal.h +++ b/lib/librte_eal/common/include/rte_eal.h -@@ -252,6 +252,11 @@ static inline int rte_gettid(void) - return RTE_PER_LCORE(_thread_id); - } +@@ -286,6 +286,11 @@ static inline int rte_gettid(void) + #define RTE_INIT(func) \ + static void __attribute__((constructor, used)) func(void) +/** + * Set owner/permissions on sockets if requested on EAL commandline @@ -125,8 +108,6 @@ index a71d6f5..506cf24 100644 #ifdef __cplusplus } #endif -diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c -index 3fb2188..dc84c5b 100644 --- a/lib/librte_eal/linuxapp/eal/eal.c +++ b/lib/librte_eal/linuxapp/eal/eal.c @@ -53,6 +53,9 @@ @@ -139,7 +120,20 @@ index 3fb2188..dc84c5b 100644 #include #include -@@ -344,6 +347,8 @@ eal_usage(const char *prgname) +@@ -119,6 +122,12 @@ struct lcore_config lcore_config[RTE_MAX + /* internal configuration */ + struct internal_config internal_config; + ++/* workaround to be able to create the sockets under a certain set of ++ * owner/permissions as specified to EAL until solved upstream */ ++static uid_t debian_vhost_sock_uid = (uid_t)-1; ++static gid_t debian_vhost_sock_gid = (gid_t)-1; ++static mode_t debian_vhost_sock_perm = 0; ++ + /* used by rte_rdtsc() */ + int rte_cycles_vmware_tsc_map; + +@@ -356,6 +365,8 @@ eal_usage(const char *prgname) " --"OPT_CREATE_UIO_DEV" Create /dev/uioX (usually done by hotplug)\n" " --"OPT_VFIO_INTR" Interrupt mode for VFIO (legacy|msi|msix)\n" " --"OPT_XEN_DOM0" Support running on Xen dom0 without hugetlbfs\n" @@ -148,26 +142,10 @@ index 3fb2188..dc84c5b 100644 "\n"); /* Allow the application to print its usage message too if hook is set */ if ( rte_application_usage_hook ) { -@@ -601,6 +606,14 @@ eal_parse_args(int argc, char **argv) - internal_config.create_uio_dev = 1; - break; - -+ case OPT_VHOST_OWNER_NUM: -+ internal_config.vhost_sock_owner = optarg; -+ break; -+ -+ case OPT_VHOST_PERM_NUM: -+ internal_config.vhost_sock_perm = optarg; -+ break; -+ - default: - if (opt < OPT_LONG_MIN_NUM && isprint(opt)) { - RTE_LOG(ERR, EAL, "Option %c is not supported " -@@ -943,3 +956,172 @@ rte_eal_check_module(const char *module_name) - /* Module has been found */ - return 1; +@@ -515,6 +526,121 @@ eal_log_level_parse(int argc, char **arg + optarg = old_optarg; } -+ + +/* Try to double the size of '*buf', return true + * if successful, and '*sizep' will be updated with + * the new size. Otherwise, return false. */ @@ -282,65 +260,88 @@ index 3fb2188..dc84c5b 100644 + free(user_search); + return e; +} ++ + /* Parse the argument given in the command line of the application */ + static int + eal_parse_args(int argc, char **argv) +@@ -611,6 +737,26 @@ eal_parse_args(int argc, char **argv) + internal_config.create_uio_dev = 1; + break; + ++ case OPT_VHOST_OWNER_NUM: ++ if (get_owners_from_str(optarg, &debian_vhost_sock_uid, ++ &debian_vhost_sock_gid)) { ++ RTE_LOG(ERR, EAL,"vhost-user socket unable to get" ++ " specified user/group: %s\n", optarg); ++ debian_vhost_sock_uid = (uid_t)-1; ++ debian_vhost_sock_gid = (gid_t)-1; ++ } ++ else { ++ RTE_LOG(INFO, EAL,"socket owner specified as %s (%d:%d)\n", ++ optarg, debian_vhost_sock_uid, debian_vhost_sock_gid); ++ } ++ break; ++ ++ case OPT_VHOST_PERM_NUM: ++ debian_vhost_sock_perm = (mode_t)strtoul(optarg, NULL, 0); ++ RTE_LOG(INFO, EAL,"socket perm specified as '%#o' from '%s'\n", ++ debian_vhost_sock_perm, optarg); ++ break; ++ + default: + if (opt < OPT_LONG_MIN_NUM && isprint(opt)) { + RTE_LOG(ERR, EAL, "Option %c is not supported " +@@ -995,3 +1141,47 @@ rte_eal_check_module(const char *module_ + /* Module has been found */ + return 1; + } + +static void +vhost_set_permissions(const char *vhost_sock_location) +{ -+ unsigned long int mode = strtoul(internal_config.vhost_sock_perm, NULL, 0); -+ int err = chmod(vhost_sock_location, (mode_t)mode); ++ int err = chmod(vhost_sock_location, debian_vhost_sock_perm); + if (err) { + RTE_LOG(ERR, EAL,"vhost-user socket cannot set" -+ " permissions to %s (%s).\n", -+ internal_config.vhost_sock_perm, strerror(err)); ++ " permissions to %#o (%s).\n", ++ debian_vhost_sock_perm, strerror(err)); + return; + } + RTE_LOG(INFO, EAL,"Socket %s changed permissions" -+ " to %s\n", vhost_sock_location, -+ internal_config.vhost_sock_perm); ++ " to %#o\n", vhost_sock_location, ++ debian_vhost_sock_perm); +} + +static void +vhost_set_ownership(const char *vhost_sock_location) +{ -+ uid_t vhuid=0; -+ gid_t vhgid=0; -+ -+ if (get_owners_from_str(internal_config.vhost_sock_owner, &vhuid, &vhgid)) { -+ RTE_LOG(ERR, EAL,"vhost-user socket unable to get" -+ " specified user/group: %s\n", -+ internal_config.vhost_sock_owner); -+ return; -+ } -+ -+ int err = chown(vhost_sock_location, vhuid, vhgid); ++ int err = chown(vhost_sock_location, debian_vhost_sock_uid, debian_vhost_sock_gid); + if (err) { + RTE_LOG(ERR, EAL,"vhost-user socket unable to set" -+ " ownership to %s (%s).\n", -+ internal_config.vhost_sock_owner, strerror(err)); ++ " ownership to %d:%d (%s).\n", ++ debian_vhost_sock_uid, debian_vhost_sock_gid, ++ strerror(err)); + return; + } + + RTE_LOG(INFO, EAL,"Socket %s changed ownership" -+ " to %s.\n", vhost_sock_location, -+ internal_config.vhost_sock_owner); ++ " to %d:%d.\n", vhost_sock_location, ++ debian_vhost_sock_uid, debian_vhost_sock_gid); +} + +void +rte_eal_set_socket_permissions(const char *path) +{ -+ if (internal_config.vhost_sock_perm) { ++ if (debian_vhost_sock_perm != 0) { + vhost_set_permissions(path); + } + -+ if (internal_config.vhost_sock_owner) { ++ if (debian_vhost_sock_uid != (uid_t)-1 || debian_vhost_sock_gid != (gid_t)-1) { + vhost_set_ownership(path); + } +} -diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map -index db8c984..bb92e57 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map -@@ -139,6 +139,7 @@ DPDK_2.2 { +@@ -120,6 +120,7 @@ DPDK_2.2 { rte_keepalive_register_core; rte_xen_dom0_supported; rte_xen_mem_phy2mch; @@ -348,11 +349,9 @@ index db8c984..bb92e57 100644 } DPDK_2.1; -diff --git a/lib/librte_vhost/vhost_user/vhost-net-user.c b/lib/librte_vhost/vhost_user/vhost-net-user.c -index b35594d..dbdb8ad 100644 ---- a/lib/librte_vhost/vhost_user/vhost-net-user.c -+++ b/lib/librte_vhost/vhost_user/vhost-net-user.c -@@ -79,6 +79,8 @@ struct vhost_user { +--- a/lib/librte_vhost/socket.c ++++ b/lib/librte_vhost/socket.c +@@ -98,6 +98,8 @@ struct vhost_user { pthread_mutex_t mutex; }; @@ -361,11 +360,11 @@ index b35594d..dbdb8ad 100644 #define MAX_VIRTIO_BACKLOG 128 static void vhost_user_server_new_connection(int fd, void *data, int *remove); -@@ -682,6 +684,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags) - if (!vsocket) - goto out; - memset(vsocket, 0, sizeof(struct vhost_user_socket)); +@@ -348,6 +350,7 @@ vhost_user_start_server(struct vhost_use + goto err; + } + + rte_eal_set_socket_permissions(path); - vsocket->path = strdup(path); - vsocket->connfd = -1; + return 0; + err: