From 8284b34f95639ad7c2e3a97b514529201c20e2ed Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 25 Jan 2016 03:38:54 +0100 Subject: s3:lib: extend interpret_interface() to optionally read speed, caps, and index from config New syntax for interfaces parameter: interfaces = address[;key=value[,key=value[,...]]] - keys can be 'speed', 'capability', and 'if_index'. - speed is in bits per second. - capability can be RSS and RDMA. - if_index should be used with care, because these indexes should not conicide with indexes the kernel sets... Signed-off-by: Michael Adam Reviewed-by: Stefan Metzmacher --- source3/lib/interface.c | 105 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) (limited to 'source3/lib/interface.c') diff --git a/source3/lib/interface.c b/source3/lib/interface.c index 69b10418650..a3bc5d24e91 100644 --- a/source3/lib/interface.c +++ b/source3/lib/interface.c @@ -20,6 +20,7 @@ #include "includes.h" #include "lib/socket/interfaces.h" +#include "librpc/gen_ndr/ioctl.h" static struct iface_struct *probed_ifaces; static int total_probed; @@ -350,6 +351,45 @@ static void add_interface(const struct iface_struct *ifs) &iface->netmask) )); } + +static void parse_extra_info(char *key, uint64_t *speed, uint32_t *cap, + uint32_t *if_index) +{ + while (key != NULL && *key != '\0') { + char *next_key; + char *val; + + next_key = strchr_m(key, ','); + if (next_key != NULL) { + *next_key++ = 0; + } + + val = strchr_m(key, '='); + if (val != NULL) { + *val++ = 0; + + if (strequal_m(key, "speed")) { + *speed = (uint64_t)strtoull(val, NULL, 0); + } else if (strequal_m(key, "capability")) { + if (strequal_m(val, "RSS")) { + *cap |= FSCTL_NET_IFACE_RSS_CAPABLE; + } else if (strequal(val, "RDMA")) { + *cap |= FSCTL_NET_IFACE_RDMA_CAPABLE; + } else { + DBG_WARNING("Capability unknown: " + "'%s'\n", val); + } + } else if (strequal_m(key, "if_index")) { + *if_index = (uint32_t)strtoul(val, NULL, 0); + } else { + DBG_DEBUG("Key unknown: '%s'\n", key); + } + } + + key = next_key; + } +} + /**************************************************************************** Interpret a single element from a interfaces= config line. @@ -360,6 +400,20 @@ static void add_interface(const struct iface_struct *ifs) 3) IP/masklen 4) ip/mask 5) bcast/mask + + Additional information for an interface can be specified with + this extended syntax: + + interface[;key1=value1[,key2=value2[...]]] + + where + - keys known: 'speed', 'capability', 'if_index' + - speed is in bits per second + - capabilites known: 'RSS', 'RDMA' + - if_index should be used with care, because + these indexes should not conicide with indexes + the kernel sets... + ****************************************************************************/ static void interpret_interface(char *token) @@ -373,6 +427,12 @@ static void interpret_interface(char *token) int i; bool added=false; bool goodaddr = false; + uint64_t speed = 0; + uint32_t cap = FSCTL_NET_IFACE_NONE_CAPABLE; + uint32_t if_index = 0; + bool speed_set = false; + bool cap_set = false; + bool if_index_set = false; /* first check if it is an interface name */ for (i=0;i