Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/lib/interface.c

    r740 r988  
    2020
    2121#include "includes.h"
    22 #include "interfaces.h"
     22#include "lib/socket/interfaces.h"
     23#include "librpc/gen_ndr/ioctl.h"
    2324
    2425static struct iface_struct *probed_ifaces;
     
    306307        struct interface *iface;
    307308
    308         if (iface_find((struct sockaddr *)&ifs->ip, False)) {
     309        if (iface_find((const struct sockaddr *)&ifs->ip, False)) {
    309310                DEBUG(3,("add_interface: not adding duplicate interface %s\n",
    310311                        print_sockaddr(addr, sizeof(addr), &ifs->ip) ));
     
    334335        iface->netmask = ifs->netmask;
    335336        iface->bcast = ifs->bcast;
     337        iface->linkspeed = ifs->linkspeed;
     338        iface->capability = ifs->capability;
     339        iface->if_index = ifs->if_index;
    336340
    337341        DLIST_ADD(local_interfaces, iface);
     
    348352}
    349353
     354
     355static void parse_extra_info(char *key, uint64_t *speed, uint32_t *cap,
     356                             uint32_t *if_index)
     357{
     358        while (key != NULL && *key != '\0') {
     359                char *next_key;
     360                char *val;
     361
     362                next_key = strchr_m(key, ',');
     363                if (next_key != NULL) {
     364                        *next_key++ = 0;
     365                }
     366
     367                val = strchr_m(key, '=');
     368                if (val != NULL) {
     369                        *val++ = 0;
     370
     371                        if (strequal_m(key, "speed")) {
     372                                *speed = (uint64_t)strtoull(val, NULL, 0);
     373                        } else if (strequal_m(key, "capability")) {
     374                                if (strequal_m(val, "RSS")) {
     375                                        *cap |= FSCTL_NET_IFACE_RSS_CAPABLE;
     376                                } else if (strequal(val, "RDMA")) {
     377                                        *cap |= FSCTL_NET_IFACE_RDMA_CAPABLE;
     378                                } else {
     379                                        DBG_WARNING("Capability unknown: "
     380                                                    "'%s'\n", val);
     381                                }
     382                        } else if (strequal_m(key, "if_index")) {
     383                                *if_index = (uint32_t)strtoul(val, NULL, 0);
     384                        } else {
     385                                DBG_DEBUG("Key unknown: '%s'\n", key);
     386                        }
     387                }
     388
     389                key = next_key;
     390        }
     391}
     392
    350393/****************************************************************************
    351394 Interpret a single element from a interfaces= config line.
     
    358401 4) ip/mask
    359402 5) bcast/mask
     403
     404 Additional information for an interface can be specified with
     405 this extended syntax:
     406
     407    interface[;key1=value1[,key2=value2[...]]]
     408
     409 where
     410 - keys known: 'speed', 'capability', 'if_index'
     411 - speed is in bits per second
     412 - capabilites known: 'RSS', 'RDMA'
     413 - if_index should be used with care, because
     414   these indexes should not conicide with indexes
     415   the kernel sets...
     416
    360417****************************************************************************/
    361418
     
    371428        bool added=false;
    372429        bool goodaddr = false;
     430        uint64_t speed = 0;
     431        uint32_t cap = FSCTL_NET_IFACE_NONE_CAPABLE;
     432        uint32_t if_index = 0;
     433        bool speed_set = false;
     434        bool cap_set = false;
     435        bool if_index_set = false;
    373436
    374437        /* first check if it is an interface name */
     
    383446        }
    384447
    385         /* maybe it is a DNS name */
     448        /*
     449         * extract speed / capability information if present
     450         */
     451        p = strchr_m(token, ';');
     452        if (p != NULL) {
     453                *p++ = 0;
     454                parse_extra_info(p, &speed, &cap, &if_index);
     455                if (speed != 0) {
     456                        speed_set = true;
     457                }
     458                if (cap != FSCTL_NET_IFACE_NONE_CAPABLE) {
     459                        cap_set = true;
     460                }
     461                if (if_index != 0) {
     462                        if_index_set = true;
     463                }
     464        }
     465
    386466        p = strchr_m(token,'/');
    387467        if (p == NULL) {
     
    393473
    394474                for (i=0;i<total_probed;i++) {
    395                         if (sockaddr_equal((struct sockaddr *)&ss, (struct sockaddr *)&probed_ifaces[i].ip)) {
     475                        if (sockaddr_equal((struct sockaddr *)&ss,
     476                                (struct sockaddr *)&probed_ifaces[i].ip))
     477                        {
     478                                if (speed_set) {
     479                                        probed_ifaces[i].linkspeed = speed;
     480                                }
     481                                if (cap_set) {
     482                                        probed_ifaces[i].capability = cap;
     483                                }
     484                                if (if_index_set) {
     485                                        probed_ifaces[i].if_index = if_index;
     486                                }
    396487                                add_interface(&probed_ifaces[i]);
    397488                                return;
     
    463554                                        p,
    464555                                        probed_ifaces[i].name));
     556                                if (speed_set) {
     557                                        probed_ifaces[i].linkspeed = speed;
     558                                }
     559                                if (cap_set) {
     560                                        probed_ifaces[i].capability = cap;
     561                                }
     562                                if (if_index_set) {
     563                                        probed_ifaces[i].if_index = if_index;
     564                                }
    465565                                add_interface(&probed_ifaces[i]);
    466566                                probed_ifaces[i].netmask = saved_mask;
     
    485585        ifs.netmask = ss_mask;
    486586        ifs.bcast = ss_bcast;
     587        if (if_index_set) {
     588                probed_ifaces[i].if_index = if_index;
     589        }
     590        if (speed_set) {
     591                ifs.linkspeed = speed;
     592        } else {
     593                ifs.linkspeed = 1000 * 1000 * 1000;
     594        }
     595        ifs.capability = cap;
    487596        add_interface(&ifs);
    488597}
     
    504613
    505614        if (total_probed > 0) {
    506                 probed_ifaces = (struct iface_struct *)memdup(ifaces,
     615                probed_ifaces = (struct iface_struct *)smb_memdup(ifaces,
    507616                                sizeof(ifaces[0])*total_probed);
    508617                if (!probed_ifaces) {
    509                         DEBUG(0,("ERROR: memdup failed\n"));
     618                        DEBUG(0,("ERROR: smb_memdup failed\n"));
    510619                        exit(1);
    511620                }
Note: See TracChangeset for help on using the changeset viewer.