Changeset 988 for vendor/current/source3/lib/interface.c
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/lib/interface.c
r740 r988 20 20 21 21 #include "includes.h" 22 #include "interfaces.h" 22 #include "lib/socket/interfaces.h" 23 #include "librpc/gen_ndr/ioctl.h" 23 24 24 25 static struct iface_struct *probed_ifaces; … … 306 307 struct interface *iface; 307 308 308 if (iface_find(( struct sockaddr *)&ifs->ip, False)) {309 if (iface_find((const struct sockaddr *)&ifs->ip, False)) { 309 310 DEBUG(3,("add_interface: not adding duplicate interface %s\n", 310 311 print_sockaddr(addr, sizeof(addr), &ifs->ip) )); … … 334 335 iface->netmask = ifs->netmask; 335 336 iface->bcast = ifs->bcast; 337 iface->linkspeed = ifs->linkspeed; 338 iface->capability = ifs->capability; 339 iface->if_index = ifs->if_index; 336 340 337 341 DLIST_ADD(local_interfaces, iface); … … 348 352 } 349 353 354 355 static 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 350 393 /**************************************************************************** 351 394 Interpret a single element from a interfaces= config line. … … 358 401 4) ip/mask 359 402 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 360 417 ****************************************************************************/ 361 418 … … 371 428 bool added=false; 372 429 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; 373 436 374 437 /* first check if it is an interface name */ … … 383 446 } 384 447 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 386 466 p = strchr_m(token,'/'); 387 467 if (p == NULL) { … … 393 473 394 474 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 } 396 487 add_interface(&probed_ifaces[i]); 397 488 return; … … 463 554 p, 464 555 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 } 465 565 add_interface(&probed_ifaces[i]); 466 566 probed_ifaces[i].netmask = saved_mask; … … 485 585 ifs.netmask = ss_mask; 486 586 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; 487 596 add_interface(&ifs); 488 597 } … … 504 613 505 614 if (total_probed > 0) { 506 probed_ifaces = (struct iface_struct *) memdup(ifaces,615 probed_ifaces = (struct iface_struct *)smb_memdup(ifaces, 507 616 sizeof(ifaces[0])*total_probed); 508 617 if (!probed_ifaces) { 509 DEBUG(0,("ERROR: memdup failed\n"));618 DEBUG(0,("ERROR: smb_memdup failed\n")); 510 619 exit(1); 511 620 }
Note:
See TracChangeset
for help on using the changeset viewer.