1 /*- 2 * Copyright (c) 2014, Bryan Venteicher <bryanv@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice unmodified, this list of conditions, and the following 10 * disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27 #include <sys/cdefs.h> 28 __FBSDID("$FreeBSD$"); 29 30 #include <sys/param.h> 31 #include <sys/ioctl.h> 32 #include <sys/socket.h> 33 #include <sys/sockio.h> 34 35 #include <stdlib.h> 36 #include <stdint.h> 37 #include <unistd.h> 38 #include <netdb.h> 39 40 #include <net/ethernet.h> 41 #include <net/if.h> 42 #include <net/if_vxlan.h> 43 #include <net/route.h> 44 #include <netinet/in.h> 45 46 #include <ctype.h> 47 #include <stdio.h> 48 #include <string.h> 49 #include <stdlib.h> 50 #include <unistd.h> 51 #include <err.h> 52 #include <errno.h> 53 54 #include "ifconfig.h" 55 56 static struct ifvxlanparam params = { 57 .vxlp_vni = VXLAN_VNI_MAX, 58 }; 59 60 static int 61 get_val(const char *cp, u_long *valp) 62 { 63 char *endptr; 64 u_long val; 65 66 errno = 0; 67 val = strtoul(cp, &endptr, 0); 68 if (cp[0] == '\0' || endptr[0] != '\0' || errno == ERANGE) 69 return (-1); 70 71 *valp = val; 72 return (0); 73 } 74 75 static int 76 do_cmd(if_ctx *ctx, u_long op, void *arg, size_t argsize, int set) 77 { 78 struct ifdrv ifd = {}; 79 80 strlcpy(ifd.ifd_name, ctx->ifname, sizeof(ifd.ifd_name)); 81 ifd.ifd_cmd = op; 82 ifd.ifd_len = argsize; 83 ifd.ifd_data = arg; 84 85 return (ioctl_ctx(ctx, set ? SIOCSDRVSPEC : SIOCGDRVSPEC, &ifd)); 86 } 87 88 static int 89 vxlan_exists(if_ctx *ctx) 90 { 91 struct ifvxlancfg cfg; 92 93 bzero(&cfg, sizeof(cfg)); 94 95 return (do_cmd(ctx, VXLAN_CMD_GET_CONFIG, &cfg, sizeof(cfg), 0) != -1); 96 } 97 98 static void 99 vxlan_status(if_ctx *ctx) 100 { 101 struct ifvxlancfg cfg; 102 char src[NI_MAXHOST], dst[NI_MAXHOST]; 103 char srcport[NI_MAXSERV], dstport[NI_MAXSERV]; 104 struct sockaddr *lsa, *rsa; 105 int vni, mc, ipv6; 106 107 bzero(&cfg, sizeof(cfg)); 108 109 if (do_cmd(ctx, VXLAN_CMD_GET_CONFIG, &cfg, sizeof(cfg), 0) < 0) 110 return; 111 112 vni = cfg.vxlc_vni; 113 lsa = &cfg.vxlc_local_sa.sa; 114 rsa = &cfg.vxlc_remote_sa.sa; 115 ipv6 = rsa->sa_family == AF_INET6; 116 117 /* Just report nothing if the network identity isn't set yet. */ 118 if (vni >= VXLAN_VNI_MAX) 119 return; 120 121 if (getnameinfo(lsa, lsa->sa_len, src, sizeof(src), 122 srcport, sizeof(srcport), NI_NUMERICHOST | NI_NUMERICSERV) != 0) 123 src[0] = srcport[0] = '\0'; 124 if (getnameinfo(rsa, rsa->sa_len, dst, sizeof(dst), 125 dstport, sizeof(dstport), NI_NUMERICHOST | NI_NUMERICSERV) != 0) 126 dst[0] = dstport[0] = '\0'; 127 128 if (!ipv6) { 129 struct sockaddr_in *sin = satosin(rsa); 130 mc = IN_MULTICAST(ntohl(sin->sin_addr.s_addr)); 131 } else { 132 struct sockaddr_in6 *sin6 = satosin6(rsa); 133 mc = IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr); 134 } 135 136 printf("\tvxlan vni %d", vni); 137 printf(" local %s%s%s:%s", ipv6 ? "[" : "", src, ipv6 ? "]" : "", 138 srcport); 139 printf(" %s %s%s%s:%s", mc ? "group" : "remote", ipv6 ? "[" : "", 140 dst, ipv6 ? "]" : "", dstport); 141 142 if (ctx->args->verbose) { 143 printf("\n\t\tconfig: "); 144 printf("%slearning portrange %d-%d ttl %d", 145 cfg.vxlc_learn ? "" : "no", cfg.vxlc_port_min, 146 cfg.vxlc_port_max, cfg.vxlc_ttl); 147 printf("\n\t\tftable: "); 148 printf("cnt %d max %d timeout %d", 149 cfg.vxlc_ftable_cnt, cfg.vxlc_ftable_max, 150 cfg.vxlc_ftable_timeout); 151 } 152 153 putchar('\n'); 154 } 155 156 #define _LOCAL_ADDR46 \ 157 (VXLAN_PARAM_WITH_LOCAL_ADDR4 | VXLAN_PARAM_WITH_LOCAL_ADDR6) 158 #define _REMOTE_ADDR46 \ 159 (VXLAN_PARAM_WITH_REMOTE_ADDR4 | VXLAN_PARAM_WITH_REMOTE_ADDR6) 160 161 static void 162 vxlan_check_params(void) 163 { 164 165 if ((params.vxlp_with & _LOCAL_ADDR46) == _LOCAL_ADDR46) 166 errx(1, "cannot specify both local IPv4 and IPv6 addresses"); 167 if ((params.vxlp_with & _REMOTE_ADDR46) == _REMOTE_ADDR46) 168 errx(1, "cannot specify both remote IPv4 and IPv6 addresses"); 169 if ((params.vxlp_with & VXLAN_PARAM_WITH_LOCAL_ADDR4 && 170 params.vxlp_with & VXLAN_PARAM_WITH_REMOTE_ADDR6) || 171 (params.vxlp_with & VXLAN_PARAM_WITH_LOCAL_ADDR6 && 172 params.vxlp_with & VXLAN_PARAM_WITH_REMOTE_ADDR4)) 173 errx(1, "cannot mix IPv4 and IPv6 addresses"); 174 } 175 176 #undef _LOCAL_ADDR46 177 #undef _REMOTE_ADDR46 178 179 static void 180 vxlan_create(if_ctx *ctx, struct ifreq *ifr) 181 { 182 183 vxlan_check_params(); 184 185 ifr->ifr_data = (caddr_t) ¶ms; 186 ifcreate_ioctl(ctx, ifr); 187 } 188 189 static void 190 setvxlan_vni(if_ctx *ctx, const char *arg, int dummy __unused) 191 { 192 struct ifvxlancmd cmd; 193 u_long val; 194 195 if (get_val(arg, &val) < 0 || val >= VXLAN_VNI_MAX) 196 errx(1, "invalid network identifier: %s", arg); 197 198 if (!vxlan_exists(ctx)) { 199 params.vxlp_with |= VXLAN_PARAM_WITH_VNI; 200 params.vxlp_vni = val; 201 return; 202 } 203 204 bzero(&cmd, sizeof(cmd)); 205 cmd.vxlcmd_vni = val; 206 207 if (do_cmd(ctx, VXLAN_CMD_SET_VNI, &cmd, sizeof(cmd), 1) < 0) 208 err(1, "VXLAN_CMD_SET_VNI"); 209 } 210 211 static void 212 setvxlan_local(if_ctx *ctx, const char *addr, int dummy __unused) 213 { 214 struct ifvxlancmd cmd; 215 struct addrinfo *ai; 216 struct sockaddr *sa; 217 int error; 218 219 bzero(&cmd, sizeof(cmd)); 220 221 if ((error = getaddrinfo(addr, NULL, NULL, &ai)) != 0) 222 errx(1, "error in parsing local address string: %s", 223 gai_strerror(error)); 224 225 sa = ai->ai_addr; 226 227 switch (ai->ai_family) { 228 #ifdef INET 229 case AF_INET: { 230 struct sockaddr_in *sin = satosin(sa); 231 232 if (IN_MULTICAST(ntohl(sin->sin_addr.s_addr))) 233 errx(1, "local address cannot be multicast"); 234 235 cmd.vxlcmd_sa.in4 = *sin; 236 break; 237 } 238 #endif 239 #ifdef INET6 240 case AF_INET6: { 241 struct sockaddr_in6 *sin6 = satosin6(sa); 242 243 if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) 244 errx(1, "local address cannot be multicast"); 245 246 cmd.vxlcmd_sa.in6 = *sin6; 247 break; 248 } 249 #endif 250 default: 251 errx(1, "local address %s not supported", addr); 252 } 253 254 freeaddrinfo(ai); 255 256 if (!vxlan_exists(ctx)) { 257 if (cmd.vxlcmd_sa.sa.sa_family == AF_INET) { 258 params.vxlp_with |= VXLAN_PARAM_WITH_LOCAL_ADDR4; 259 params.vxlp_local_sa.in4 = cmd.vxlcmd_sa.in4; 260 } else { 261 params.vxlp_with |= VXLAN_PARAM_WITH_LOCAL_ADDR6; 262 params.vxlp_local_sa.in6 = cmd.vxlcmd_sa.in6; 263 } 264 return; 265 } 266 267 if (do_cmd(ctx, VXLAN_CMD_SET_LOCAL_ADDR, &cmd, sizeof(cmd), 1) < 0) 268 err(1, "VXLAN_CMD_SET_LOCAL_ADDR"); 269 } 270 271 static void 272 setvxlan_remote(if_ctx *ctx, const char *addr, int dummy __unused) 273 { 274 struct ifvxlancmd cmd; 275 struct addrinfo *ai; 276 struct sockaddr *sa; 277 int error; 278 279 bzero(&cmd, sizeof(cmd)); 280 281 if ((error = getaddrinfo(addr, NULL, NULL, &ai)) != 0) 282 errx(1, "error in parsing remote address string: %s", 283 gai_strerror(error)); 284 285 sa = ai->ai_addr; 286 287 switch (ai->ai_family) { 288 #ifdef INET 289 case AF_INET: { 290 struct sockaddr_in *sin = satosin(sa); 291 292 if (IN_MULTICAST(ntohl(sin->sin_addr.s_addr))) 293 errx(1, "remote address cannot be multicast"); 294 295 cmd.vxlcmd_sa.in4 = *sin; 296 break; 297 } 298 #endif 299 #ifdef INET6 300 case AF_INET6: { 301 struct sockaddr_in6 *sin6 = satosin6(sa); 302 303 if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) 304 errx(1, "remote address cannot be multicast"); 305 306 cmd.vxlcmd_sa.in6 = *sin6; 307 break; 308 } 309 #endif 310 default: 311 errx(1, "remote address %s not supported", addr); 312 } 313 314 freeaddrinfo(ai); 315 316 if (!vxlan_exists(ctx)) { 317 if (cmd.vxlcmd_sa.sa.sa_family == AF_INET) { 318 params.vxlp_with |= VXLAN_PARAM_WITH_REMOTE_ADDR4; 319 params.vxlp_remote_sa.in4 = cmd.vxlcmd_sa.in4; 320 } else { 321 params.vxlp_with |= VXLAN_PARAM_WITH_REMOTE_ADDR6; 322 params.vxlp_remote_sa.in6 = cmd.vxlcmd_sa.in6; 323 } 324 return; 325 } 326 327 if (do_cmd(ctx, VXLAN_CMD_SET_REMOTE_ADDR, &cmd, sizeof(cmd), 1) < 0) 328 err(1, "VXLAN_CMD_SET_REMOTE_ADDR"); 329 } 330 331 static void 332 setvxlan_group(if_ctx *ctx, const char *addr, int dummy __unused) 333 { 334 struct ifvxlancmd cmd; 335 struct addrinfo *ai; 336 struct sockaddr *sa; 337 int error; 338 339 bzero(&cmd, sizeof(cmd)); 340 341 if ((error = getaddrinfo(addr, NULL, NULL, &ai)) != 0) 342 errx(1, "error in parsing group address string: %s", 343 gai_strerror(error)); 344 345 sa = ai->ai_addr; 346 347 switch (ai->ai_family) { 348 #ifdef INET 349 case AF_INET: { 350 struct sockaddr_in *sin = satosin(sa); 351 352 if (!IN_MULTICAST(ntohl(sin->sin_addr.s_addr))) 353 errx(1, "group address must be multicast"); 354 355 cmd.vxlcmd_sa.in4 = *sin; 356 break; 357 } 358 #endif 359 #ifdef INET6 360 case AF_INET6: { 361 struct sockaddr_in6 *sin6 = satosin6(sa); 362 363 if (!IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) 364 errx(1, "group address must be multicast"); 365 366 cmd.vxlcmd_sa.in6 = *sin6; 367 break; 368 } 369 #endif 370 default: 371 errx(1, "group address %s not supported", addr); 372 } 373 374 freeaddrinfo(ai); 375 376 if (!vxlan_exists(ctx)) { 377 if (cmd.vxlcmd_sa.sa.sa_family == AF_INET) { 378 params.vxlp_with |= VXLAN_PARAM_WITH_REMOTE_ADDR4; 379 params.vxlp_remote_sa.in4 = cmd.vxlcmd_sa.in4; 380 } else { 381 params.vxlp_with |= VXLAN_PARAM_WITH_REMOTE_ADDR6; 382 params.vxlp_remote_sa.in6 = cmd.vxlcmd_sa.in6; 383 } 384 return; 385 } 386 387 if (do_cmd(ctx, VXLAN_CMD_SET_REMOTE_ADDR, &cmd, sizeof(cmd), 1) < 0) 388 err(1, "VXLAN_CMD_SET_REMOTE_ADDR"); 389 } 390 391 static void 392 setvxlan_local_port(if_ctx *ctx, const char *arg, int dummy __unused) 393 { 394 struct ifvxlancmd cmd; 395 u_long val; 396 397 if (get_val(arg, &val) < 0 || val >= UINT16_MAX) 398 errx(1, "invalid local port: %s", arg); 399 400 if (!vxlan_exists(ctx)) { 401 params.vxlp_with |= VXLAN_PARAM_WITH_LOCAL_PORT; 402 params.vxlp_local_port = val; 403 return; 404 } 405 406 bzero(&cmd, sizeof(cmd)); 407 cmd.vxlcmd_port = val; 408 409 if (do_cmd(ctx, VXLAN_CMD_SET_LOCAL_PORT, &cmd, sizeof(cmd), 1) < 0) 410 err(1, "VXLAN_CMD_SET_LOCAL_PORT"); 411 } 412 413 static void 414 setvxlan_remote_port(if_ctx *ctx, const char *arg, int dummy __unused) 415 { 416 struct ifvxlancmd cmd; 417 u_long val; 418 419 if (get_val(arg, &val) < 0 || val >= UINT16_MAX) 420 errx(1, "invalid remote port: %s", arg); 421 422 if (!vxlan_exists(ctx)) { 423 params.vxlp_with |= VXLAN_PARAM_WITH_REMOTE_PORT; 424 params.vxlp_remote_port = val; 425 return; 426 } 427 428 bzero(&cmd, sizeof(cmd)); 429 cmd.vxlcmd_port = val; 430 431 if (do_cmd(ctx, VXLAN_CMD_SET_REMOTE_PORT, &cmd, sizeof(cmd), 1) < 0) 432 err(1, "VXLAN_CMD_SET_REMOTE_PORT"); 433 } 434 435 static void 436 setvxlan_port_range(if_ctx *ctx, const char *arg1, const char *arg2) 437 { 438 struct ifvxlancmd cmd; 439 u_long min, max; 440 441 if (get_val(arg1, &min) < 0 || min >= UINT16_MAX) 442 errx(1, "invalid port range minimum: %s", arg1); 443 if (get_val(arg2, &max) < 0 || max >= UINT16_MAX) 444 errx(1, "invalid port range maximum: %s", arg2); 445 if (max < min) 446 errx(1, "invalid port range"); 447 448 if (!vxlan_exists(ctx)) { 449 params.vxlp_with |= VXLAN_PARAM_WITH_PORT_RANGE; 450 params.vxlp_min_port = min; 451 params.vxlp_max_port = max; 452 return; 453 } 454 455 bzero(&cmd, sizeof(cmd)); 456 cmd.vxlcmd_port_min = min; 457 cmd.vxlcmd_port_max = max; 458 459 if (do_cmd(ctx, VXLAN_CMD_SET_PORT_RANGE, &cmd, sizeof(cmd), 1) < 0) 460 err(1, "VXLAN_CMD_SET_PORT_RANGE"); 461 } 462 463 static void 464 setvxlan_timeout(if_ctx *ctx, const char *arg, int dummy __unused) 465 { 466 struct ifvxlancmd cmd; 467 u_long val; 468 469 if (get_val(arg, &val) < 0 || (val & ~0xFFFFFFFF) != 0) 470 errx(1, "invalid timeout value: %s", arg); 471 472 if (!vxlan_exists(ctx)) { 473 params.vxlp_with |= VXLAN_PARAM_WITH_FTABLE_TIMEOUT; 474 params.vxlp_ftable_timeout = val & 0xFFFFFFFF; 475 return; 476 } 477 478 bzero(&cmd, sizeof(cmd)); 479 cmd.vxlcmd_ftable_timeout = val & 0xFFFFFFFF; 480 481 if (do_cmd(ctx, VXLAN_CMD_SET_FTABLE_TIMEOUT, &cmd, sizeof(cmd), 1) < 0) 482 err(1, "VXLAN_CMD_SET_FTABLE_TIMEOUT"); 483 } 484 485 static void 486 setvxlan_maxaddr(if_ctx *ctx, const char *arg, int dummy __unused) 487 { 488 struct ifvxlancmd cmd; 489 u_long val; 490 491 if (get_val(arg, &val) < 0 || (val & ~0xFFFFFFFF) != 0) 492 errx(1, "invalid maxaddr value: %s", arg); 493 494 if (!vxlan_exists(ctx)) { 495 params.vxlp_with |= VXLAN_PARAM_WITH_FTABLE_MAX; 496 params.vxlp_ftable_max = val & 0xFFFFFFFF; 497 return; 498 } 499 500 bzero(&cmd, sizeof(cmd)); 501 cmd.vxlcmd_ftable_max = val & 0xFFFFFFFF; 502 503 if (do_cmd(ctx, VXLAN_CMD_SET_FTABLE_MAX, &cmd, sizeof(cmd), 1) < 0) 504 err(1, "VXLAN_CMD_SET_FTABLE_MAX"); 505 } 506 507 static void 508 setvxlan_dev(if_ctx *ctx, const char *arg, int dummy __unused) 509 { 510 struct ifvxlancmd cmd; 511 512 if (!vxlan_exists(ctx)) { 513 params.vxlp_with |= VXLAN_PARAM_WITH_MULTICAST_IF; 514 strlcpy(params.vxlp_mc_ifname, arg, 515 sizeof(params.vxlp_mc_ifname)); 516 return; 517 } 518 519 bzero(&cmd, sizeof(cmd)); 520 strlcpy(cmd.vxlcmd_ifname, arg, sizeof(cmd.vxlcmd_ifname)); 521 522 if (do_cmd(ctx, VXLAN_CMD_SET_MULTICAST_IF, &cmd, sizeof(cmd), 1) < 0) 523 err(1, "VXLAN_CMD_SET_MULTICAST_IF"); 524 } 525 526 static void 527 setvxlan_ttl(if_ctx *ctx, const char *arg, int dummy __unused) 528 { 529 struct ifvxlancmd cmd; 530 u_long val; 531 532 if (get_val(arg, &val) < 0 || val > 256) 533 errx(1, "invalid TTL value: %s", arg); 534 535 if (!vxlan_exists(ctx)) { 536 params.vxlp_with |= VXLAN_PARAM_WITH_TTL; 537 params.vxlp_ttl = val; 538 return; 539 } 540 541 bzero(&cmd, sizeof(cmd)); 542 cmd.vxlcmd_ttl = val; 543 544 if (do_cmd(ctx, VXLAN_CMD_SET_TTL, &cmd, sizeof(cmd), 1) < 0) 545 err(1, "VXLAN_CMD_SET_TTL"); 546 } 547 548 static void 549 setvxlan_learn(if_ctx *ctx, const char *arg __unused, int d) 550 { 551 struct ifvxlancmd cmd; 552 553 if (!vxlan_exists(ctx)) { 554 params.vxlp_with |= VXLAN_PARAM_WITH_LEARN; 555 params.vxlp_learn = d; 556 return; 557 } 558 559 bzero(&cmd, sizeof(cmd)); 560 if (d != 0) 561 cmd.vxlcmd_flags |= VXLAN_CMD_FLAG_LEARN; 562 563 if (do_cmd(ctx, VXLAN_CMD_SET_LEARN, &cmd, sizeof(cmd), 1) < 0) 564 err(1, "VXLAN_CMD_SET_LEARN"); 565 } 566 567 static void 568 setvxlan_flush(if_ctx *ctx, const char *val __unused, int d) 569 { 570 struct ifvxlancmd cmd; 571 572 bzero(&cmd, sizeof(cmd)); 573 if (d != 0) 574 cmd.vxlcmd_flags |= VXLAN_CMD_FLAG_FLUSH_ALL; 575 576 if (do_cmd(ctx, VXLAN_CMD_FLUSH, &cmd, sizeof(cmd), 1) < 0) 577 err(1, "VXLAN_CMD_FLUSH"); 578 } 579 580 static struct cmd vxlan_cmds[] = { 581 582 DEF_CLONE_CMD_ARG("vni", setvxlan_vni), 583 DEF_CLONE_CMD_ARG("vxlanid", setvxlan_vni), 584 DEF_CLONE_CMD_ARG("vxlanlocal", setvxlan_local), 585 DEF_CLONE_CMD_ARG("vxlanremote", setvxlan_remote), 586 DEF_CLONE_CMD_ARG("vxlangroup", setvxlan_group), 587 DEF_CLONE_CMD_ARG("vxlanlocalport", setvxlan_local_port), 588 DEF_CLONE_CMD_ARG("vxlanremoteport", setvxlan_remote_port), 589 DEF_CLONE_CMD_ARG2("vxlanportrange", setvxlan_port_range), 590 DEF_CLONE_CMD_ARG("vxlantimeout", setvxlan_timeout), 591 DEF_CLONE_CMD_ARG("vxlanmaxaddr", setvxlan_maxaddr), 592 DEF_CLONE_CMD_ARG("vxlandev", setvxlan_dev), 593 DEF_CLONE_CMD_ARG("vxlanttl", setvxlan_ttl), 594 DEF_CLONE_CMD("vxlanlearn", 1, setvxlan_learn), 595 DEF_CLONE_CMD("-vxlanlearn", 0, setvxlan_learn), 596 597 DEF_CMD_ARG("vni", setvxlan_vni), 598 DEF_CMD_ARG("vxlanid", setvxlan_vni), 599 DEF_CMD_ARG("vxlanlocal", setvxlan_local), 600 DEF_CMD_ARG("vxlanremote", setvxlan_remote), 601 DEF_CMD_ARG("vxlangroup", setvxlan_group), 602 DEF_CMD_ARG("vxlanlocalport", setvxlan_local_port), 603 DEF_CMD_ARG("vxlanremoteport", setvxlan_remote_port), 604 DEF_CMD_ARG2("vxlanportrange", setvxlan_port_range), 605 DEF_CMD_ARG("vxlantimeout", setvxlan_timeout), 606 DEF_CMD_ARG("vxlanmaxaddr", setvxlan_maxaddr), 607 DEF_CMD_ARG("vxlandev", setvxlan_dev), 608 DEF_CMD_ARG("vxlanttl", setvxlan_ttl), 609 DEF_CMD("vxlanlearn", 1, setvxlan_learn), 610 DEF_CMD("-vxlanlearn", 0, setvxlan_learn), 611 612 DEF_CMD("vxlanflush", 0, setvxlan_flush), 613 DEF_CMD("vxlanflushall", 1, setvxlan_flush), 614 615 DEF_CMD("vxlanhwcsum", IFCAP_VXLAN_HWCSUM, setifcap), 616 DEF_CMD("-vxlanhwcsum", IFCAP_VXLAN_HWCSUM, clearifcap), 617 DEF_CMD("vxlanhwtso", IFCAP_VXLAN_HWTSO, setifcap), 618 DEF_CMD("-vxlanhwtso", IFCAP_VXLAN_HWTSO, clearifcap), 619 }; 620 621 static struct afswtch af_vxlan = { 622 .af_name = "af_vxlan", 623 .af_af = AF_UNSPEC, 624 .af_other_status = vxlan_status, 625 }; 626 627 static __constructor void 628 vxlan_ctor(void) 629 { 630 size_t i; 631 632 for (i = 0; i < nitems(vxlan_cmds); i++) 633 cmd_register(&vxlan_cmds[i]); 634 af_register(&af_vxlan); 635 clone_setdefcallback_prefix("vxlan", vxlan_create); 636 } 637