Mercurial > hg > dhcpcd
comparison src/ipv4ll.c @ 5535:a0d828e25482 draft
Add --noconfigure option
With this set dhcpcd will not configure anything on the host.
The expectation is that a 3rd party script will instead.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Wed, 04 Nov 2020 14:18:48 +0000 |
| parents | 30603cb789ea |
| children | 4fe5c2a71254 |
comparison
equal
deleted
inserted
replaced
| 5534:605f7f9a20c0 | 5535:a0d828e25482 |
|---|---|
| 226 #ifdef IN_IFF_NOTREADY | 226 #ifdef IN_IFF_NOTREADY |
| 227 if (ia == NULL || ia->addr_flags & IN_IFF_NOTREADY) | 227 if (ia == NULL || ia->addr_flags & IN_IFF_NOTREADY) |
| 228 #endif | 228 #endif |
| 229 loginfox("%s: using IPv4LL address %s", | 229 loginfox("%s: using IPv4LL address %s", |
| 230 ifp->name, inet_ntoa(state->pickedaddr)); | 230 ifp->name, inet_ntoa(state->pickedaddr)); |
| 231 if (!(ifp->options->options & DHCPCD_CONFIGURE)) | |
| 232 goto run; | |
| 231 if (ia == NULL) { | 233 if (ia == NULL) { |
| 232 if (ifp->ctx->options & DHCPCD_TEST) | 234 if (ifp->ctx->options & DHCPCD_TEST) |
| 233 goto test; | 235 goto test; |
| 234 ia = ipv4_addaddr(ifp, &state->pickedaddr, | 236 ia = ipv4_addaddr(ifp, &state->pickedaddr, |
| 235 &inaddr_llmask, &inaddr_llbcast, | 237 &inaddr_llmask, &inaddr_llbcast, |
| 250 script_runreason(ifp, "TEST"); | 252 script_runreason(ifp, "TEST"); |
| 251 eloop_exit(ifp->ctx->eloop, EXIT_SUCCESS); | 253 eloop_exit(ifp->ctx->eloop, EXIT_SUCCESS); |
| 252 return; | 254 return; |
| 253 } | 255 } |
| 254 rt_build(ifp->ctx, AF_INET); | 256 rt_build(ifp->ctx, AF_INET); |
| 257 run: | |
| 255 astate = arp_announceaddr(ifp->ctx, &ia->addr); | 258 astate = arp_announceaddr(ifp->ctx, &ia->addr); |
| 256 if (astate != NULL) | 259 if (astate != NULL) |
| 257 astate->announced_cb = ipv4ll_announced_arp; | 260 astate->announced_cb = ipv4ll_announced_arp; |
| 258 script_runreason(ifp, "IPV4LL"); | 261 script_runreason(ifp, "IPV4LL"); |
| 259 dhcpcd_daemonise(ifp->ctx); | 262 dhcpcd_daemonise(ifp->ctx); |
| 279 ipv4ll_defend_failed(struct interface *ifp) | 282 ipv4ll_defend_failed(struct interface *ifp) |
| 280 { | 283 { |
| 281 struct ipv4ll_state *state = IPV4LL_STATE(ifp); | 284 struct ipv4ll_state *state = IPV4LL_STATE(ifp); |
| 282 | 285 |
| 283 ipv4ll_freearp(ifp); | 286 ipv4ll_freearp(ifp); |
| 284 ipv4_deladdr(state->addr, 1); | 287 if (ifp->options->options & DHCPCD_CONFIGURE) |
| 288 ipv4_deladdr(state->addr, 1); | |
| 285 state->addr = NULL; | 289 state->addr = NULL; |
| 286 rt_build(ifp->ctx, AF_INET); | 290 rt_build(ifp->ctx, AF_INET); |
| 287 script_runreason(ifp, "IPV4LL"); | 291 script_runreason(ifp, "IPV4LL"); |
| 288 ipv4ll_pickaddr(ifp); | 292 ipv4ll_pickaddr(ifp); |
| 289 ipv4ll_start(ifp); | 293 ipv4ll_start(ifp); |
| 371 repick = false; | 375 repick = false; |
| 372 #ifdef IN_IFF_DUPLICATED | 376 #ifdef IN_IFF_DUPLICATED |
| 373 if (ia != NULL && ia->addr_flags & IN_IFF_DUPLICATED) { | 377 if (ia != NULL && ia->addr_flags & IN_IFF_DUPLICATED) { |
| 374 state->pickedaddr = ia->addr; /* So it's not picked again. */ | 378 state->pickedaddr = ia->addr; /* So it's not picked again. */ |
| 375 repick = true; | 379 repick = true; |
| 376 ipv4_deladdr(ia, 0); | 380 if (ifp->options->options & DHCPCD_CONFIGURE) |
| 381 ipv4_deladdr(ia, 0); | |
| 377 ia = NULL; | 382 ia = NULL; |
| 378 } | 383 } |
| 379 #endif | 384 #endif |
| 380 | 385 |
| 381 state->addr = ia; | 386 state->addr = ia; |
| 429 if ((ifp->options->options & DHCPCD_NODROP) == DHCPCD_NODROP) | 434 if ((ifp->options->options & DHCPCD_NODROP) == DHCPCD_NODROP) |
| 430 return; | 435 return; |
| 431 | 436 |
| 432 state = IPV4LL_STATE(ifp); | 437 state = IPV4LL_STATE(ifp); |
| 433 if (state && state->addr != NULL) { | 438 if (state && state->addr != NULL) { |
| 434 ipv4_deladdr(state->addr, 1); | 439 if (ifp->options->options & DHCPCD_CONFIGURE) |
| 440 ipv4_deladdr(state->addr, 1); | |
| 435 state->addr = NULL; | 441 state->addr = NULL; |
| 436 dropped = true; | 442 dropped = true; |
| 437 } | 443 } |
| 438 | 444 |
| 439 /* Free any other link local addresses that might exist. */ | 445 /* Free any other link local addresses that might exist. */ |
| 440 if ((istate = IPV4_STATE(ifp)) != NULL) { | 446 if ((istate = IPV4_STATE(ifp)) != NULL) { |
| 441 struct ipv4_addr *ia, *ian; | 447 struct ipv4_addr *ia, *ian; |
| 442 | 448 |
| 443 TAILQ_FOREACH_SAFE(ia, &istate->addrs, next, ian) { | 449 TAILQ_FOREACH_SAFE(ia, &istate->addrs, next, ian) { |
| 444 if (IN_LINKLOCAL(ntohl(ia->addr.s_addr))) { | 450 if (IN_LINKLOCAL(ntohl(ia->addr.s_addr))) { |
| 445 ipv4_deladdr(ia, 0); | 451 if (ifp->options->options & DHCPCD_CONFIGURE) |
| 452 ipv4_deladdr(ia, 0); | |
| 446 dropped = true; | 453 dropped = true; |
| 447 } | 454 } |
| 448 } | 455 } |
| 449 } | 456 } |
| 450 | 457 |
| 532 if (!(ia->addr_flags & IN_IFF_NOTUSEABLE)) | 539 if (!(ia->addr_flags & IN_IFF_NOTUSEABLE)) |
| 533 ipv4ll_not_found(ifp); | 540 ipv4ll_not_found(ifp); |
| 534 else if (ia->addr_flags & IN_IFF_DUPLICATED) { | 541 else if (ia->addr_flags & IN_IFF_DUPLICATED) { |
| 535 logerrx("%s: DAD detected %s", ifp->name, ia->saddr); | 542 logerrx("%s: DAD detected %s", ifp->name, ia->saddr); |
| 536 ipv4ll_freearp(ifp); | 543 ipv4ll_freearp(ifp); |
| 537 ipv4_deladdr(ia, 1); | 544 if (ifp->options->options & DHCPCD_CONFIGURE) |
| 545 ipv4_deladdr(ia, 1); | |
| 538 state->addr = NULL; | 546 state->addr = NULL; |
| 539 rt_build(ifp->ctx, AF_INET); | 547 rt_build(ifp->ctx, AF_INET); |
| 540 ipv4ll_found(ifp); | 548 ipv4ll_found(ifp); |
| 541 return NULL; | 549 return NULL; |
| 542 } | 550 } |
