Mercurial > hg > dhcpcd
annotate 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 |
| rev | line source |
|---|---|
|
4548
c7df03794de3
Add SPDX identifiers to all dhcpcd source files.
Yegor Yefremov <yegorslists@googlemail.com>
parents:
4522
diff
changeset
|
1 /* SPDX-License-Identifier: BSD-2-Clause */ |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2 /* |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3 * dhcpcd - DHCP client daemon |
| 4922 | 4 * Copyright (c) 2006-2020 Roy Marples <roy@marples.name> |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
5 * All rights reserved |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
6 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
7 * Redistribution and use in source and binary forms, with or without |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
8 * modification, are permitted provided that the following conditions |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
9 * are met: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
10 * 1. Redistributions of source code must retain the above copyright |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
11 * notice, this list of conditions and the following disclaimer. |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
12 * 2. Redistributions in binary form must reproduce the above copyright |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
13 * notice, this list of conditions and the following disclaimer in the |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
14 * documentation and/or other materials provided with the distribution. |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
15 * |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
26 * SUCH DAMAGE. |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
27 */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
28 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
29 #include <arpa/inet.h> |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
30 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
31 #include <assert.h> |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
32 #include <errno.h> |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
33 #include <stdbool.h> |
|
4535
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4522
diff
changeset
|
34 #include <stdio.h> |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
35 #include <stdlib.h> |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
36 #include <string.h> |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
37 #include <unistd.h> |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
38 |
|
5038
1e35e845790a
eloop: define eloop queue numbers in common.h
Roy Marples <roy@marples.name>
parents:
4922
diff
changeset
|
39 #define ELOOP_QUEUE IPV4LL |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
40 #include "config.h" |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
41 #include "arp.h" |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
42 #include "common.h" |
|
4555
93b4eb29d297
DHCP: Set address vltime and pltime to the length of the lease
Roy Marples <roy@marples.name>
parents:
4549
diff
changeset
|
43 #include "dhcp.h" |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
44 #include "eloop.h" |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
45 #include "if.h" |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
46 #include "if-options.h" |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
47 #include "ipv4.h" |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
48 #include "ipv4ll.h" |
| 4010 | 49 #include "logerr.h" |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
50 #include "sa.h" |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
51 #include "script.h" |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
52 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
53 static const struct in_addr inaddr_llmask = { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
54 .s_addr = HTONL(LINKLOCAL_MASK) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
55 }; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
56 static const struct in_addr inaddr_llbcast = { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
57 .s_addr = HTONL(LINKLOCAL_BCAST) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
58 }; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
59 |
| 5239 | 60 static void |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
61 ipv4ll_pickaddr(struct interface *ifp) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
62 { |
| 5239 | 63 struct in_addr addr = { .s_addr = 0 }; |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
64 struct ipv4ll_state *state; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
65 |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
66 state = IPV4LL_STATE(ifp); |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
67 setstate(state->randomstate); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
68 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
69 do { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
70 long r; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
71 |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
72 again: |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
73 /* RFC 3927 Section 2.1 states that the first 256 and |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
74 * last 256 addresses are reserved for future use. |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
75 * See ipv4ll_start for why we don't use arc4random. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
76 /* coverity[dont_call] */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
77 r = random(); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
78 addr.s_addr = ntohl(LINKLOCAL_ADDR | |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
79 ((uint32_t)(r % 0xFD00) + 0x0100)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
80 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
81 /* No point using a failed address */ |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
82 if (IN_ARE_ADDR_EQUAL(&addr, &state->pickedaddr)) |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
83 goto again; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
84 /* Ensure we don't have the address on another interface */ |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
85 } while (ipv4_findaddr(ifp->ctx, &addr) != NULL); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
86 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
87 /* Restore the original random state */ |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
88 setstate(ifp->ctx->randomstate); |
| 5239 | 89 state->pickedaddr = addr; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
90 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
91 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
92 int |
|
4380
2dd0bc4f135b
IPv4LL: Fix compile with rbtree
Roy Marples <roy@marples.name>
parents:
4341
diff
changeset
|
93 ipv4ll_subnetroute(rb_tree_t *routes, struct interface *ifp) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
94 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
95 struct ipv4ll_state *state; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
96 struct rt *rt; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
97 struct in_addr in; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
98 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
99 assert(ifp != NULL); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
100 if ((state = IPV4LL_STATE(ifp)) == NULL || |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
101 state->addr == NULL) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
102 return 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
103 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
104 if ((rt = rt_new(ifp)) == NULL) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
105 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
106 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
107 in.s_addr = state->addr->addr.s_addr & state->addr->mask.s_addr; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
108 sa_in_init(&rt->rt_dest, &in); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
109 in.s_addr = state->addr->mask.s_addr; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
110 sa_in_init(&rt->rt_netmask, &in); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
111 in.s_addr = INADDR_ANY; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
112 sa_in_init(&rt->rt_gateway, &in); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
113 sa_in_init(&rt->rt_ifa, &state->addr->addr); |
| 5407 | 114 rt->rt_dflags |= RTDF_IPV4LL; |
|
4522
e2582c7c7e1d
route: Use order from message / config
Roy Marples <roy@marples.name>
parents:
4512
diff
changeset
|
115 return rt_proto_add(routes, rt) ? 1 : 0; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
116 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
117 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
118 int |
|
4380
2dd0bc4f135b
IPv4LL: Fix compile with rbtree
Roy Marples <roy@marples.name>
parents:
4341
diff
changeset
|
119 ipv4ll_defaultroute(rb_tree_t *routes, struct interface *ifp) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
120 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
121 struct ipv4ll_state *state; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
122 struct rt *rt; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
123 struct in_addr in; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
124 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
125 assert(ifp != NULL); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
126 if ((state = IPV4LL_STATE(ifp)) == NULL || |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
127 state->addr == NULL) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
128 return 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
129 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
130 if ((rt = rt_new(ifp)) == NULL) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
131 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
132 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
133 in.s_addr = INADDR_ANY; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
134 sa_in_init(&rt->rt_dest, &in); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
135 sa_in_init(&rt->rt_netmask, &in); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
136 sa_in_init(&rt->rt_gateway, &in); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
137 sa_in_init(&rt->rt_ifa, &state->addr->addr); |
| 5407 | 138 rt->rt_dflags |= RTDF_IPV4LL; |
|
5406
c03103d18249
route: Ensure IPv4LL routes always come last in priority
Roy Marples <roy@marples.name>
parents:
5352
diff
changeset
|
139 #ifdef HAVE_ROUTE_METRIC |
|
c03103d18249
route: Ensure IPv4LL routes always come last in priority
Roy Marples <roy@marples.name>
parents:
5352
diff
changeset
|
140 rt->rt_metric += 10000; |
|
c03103d18249
route: Ensure IPv4LL routes always come last in priority
Roy Marples <roy@marples.name>
parents:
5352
diff
changeset
|
141 #endif |
|
4522
e2582c7c7e1d
route: Use order from message / config
Roy Marples <roy@marples.name>
parents:
4512
diff
changeset
|
142 return rt_proto_add(routes, rt) ? 1 : 0; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
143 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
144 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
145 ssize_t |
|
4535
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4522
diff
changeset
|
146 ipv4ll_env(FILE *fp, const char *prefix, const struct interface *ifp) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
147 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
148 const struct ipv4ll_state *state; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
149 const char *pf = prefix == NULL ? "" : "_"; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
150 struct in_addr netnum; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
151 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
152 assert(ifp != NULL); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
153 if ((state = IPV4LL_CSTATE(ifp)) == NULL || state->addr == NULL) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
154 return 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
155 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
156 /* Emulate a DHCP environment */ |
|
4535
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4522
diff
changeset
|
157 if (efprintf(fp, "%s%sip_address=%s", |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
158 prefix, pf, inet_ntoa(state->addr->addr)) == -1) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
159 return -1; |
|
4535
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4522
diff
changeset
|
160 if (efprintf(fp, "%s%ssubnet_mask=%s", |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
161 prefix, pf, inet_ntoa(state->addr->mask)) == -1) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
162 return -1; |
|
4535
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4522
diff
changeset
|
163 if (efprintf(fp, "%s%ssubnet_cidr=%d", |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
164 prefix, pf, inet_ntocidr(state->addr->mask)) == -1) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
165 return -1; |
|
4535
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4522
diff
changeset
|
166 if (efprintf(fp, "%s%sbroadcast_address=%s", |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
167 prefix, pf, inet_ntoa(state->addr->brd)) == -1) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
168 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
169 netnum.s_addr = state->addr->addr.s_addr & state->addr->mask.s_addr; |
|
4535
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4522
diff
changeset
|
170 if (efprintf(fp, "%s%snetwork_number=%s", |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
171 prefix, pf, inet_ntoa(netnum)) == -1) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
172 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
173 return 5; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
174 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
175 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
176 static void |
| 4457 | 177 ipv4ll_announced_arp(struct arp_state *astate) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
178 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
179 struct ipv4ll_state *state = IPV4LL_STATE(astate->iface); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
180 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
181 state->conflicts = 0; |
|
5352
599c75a0ac56
IPv4LL: free the arp state once announced for RFC 5227 kernels
Roy Marples <roy@marples.name>
parents:
5239
diff
changeset
|
182 #ifdef KERNEL_RFC5227 |
|
599c75a0ac56
IPv4LL: free the arp state once announced for RFC 5227 kernels
Roy Marples <roy@marples.name>
parents:
5239
diff
changeset
|
183 arp_free(astate); |
|
599c75a0ac56
IPv4LL: free the arp state once announced for RFC 5227 kernels
Roy Marples <roy@marples.name>
parents:
5239
diff
changeset
|
184 #endif |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
185 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
186 |
| 5239 | 187 #ifndef KERNEL_RFC5227 |
|
5237
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
188 /* This is the callback by ARP freeing */ |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
189 static void |
| 5239 | 190 ipv4ll_free_arp(struct arp_state *astate) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
191 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
192 struct ipv4ll_state *state; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
193 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
194 state = IPV4LL_STATE(astate->iface); |
|
4341
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
195 if (state != NULL && state->arp == astate) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
196 state->arp = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
197 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
198 |
|
5237
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
199 /* This is us freeing any ARP state */ |
|
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
200 static void |
|
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
201 ipv4ll_freearp(struct interface *ifp) |
|
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
202 { |
|
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
203 struct ipv4ll_state *state; |
|
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
204 |
|
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
205 state = IPV4LL_STATE(ifp); |
|
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
206 if (state == NULL || state->arp == NULL) |
|
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
207 return; |
|
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
208 |
|
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
209 eloop_timeout_delete(ifp->ctx->eloop, NULL, state->arp); |
|
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
210 arp_free(state->arp); |
|
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
211 state->arp = NULL; |
|
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
212 } |
|
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
213 #else |
|
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
214 #define ipv4ll_freearp(ifp) |
|
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
215 #endif |
|
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
216 |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
217 static void |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
218 ipv4ll_not_found(struct interface *ifp) |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
219 { |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
220 struct ipv4ll_state *state; |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
221 struct ipv4_addr *ia; |
| 5239 | 222 struct arp_state *astate; |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
223 |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
224 state = IPV4LL_STATE(ifp); |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
225 ia = ipv4_iffindaddr(ifp, &state->pickedaddr, &inaddr_llmask); |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
226 #ifdef IN_IFF_NOTREADY |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
227 if (ia == NULL || ia->addr_flags & IN_IFF_NOTREADY) |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
228 #endif |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
229 loginfox("%s: using IPv4LL address %s", |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
230 ifp->name, inet_ntoa(state->pickedaddr)); |
| 5535 | 231 if (!(ifp->options->options & DHCPCD_CONFIGURE)) |
| 232 goto run; | |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
233 if (ia == NULL) { |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
234 if (ifp->ctx->options & DHCPCD_TEST) |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
235 goto test; |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
236 ia = ipv4_addaddr(ifp, &state->pickedaddr, |
|
4555
93b4eb29d297
DHCP: Set address vltime and pltime to the length of the lease
Roy Marples <roy@marples.name>
parents:
4549
diff
changeset
|
237 &inaddr_llmask, &inaddr_llbcast, |
|
93b4eb29d297
DHCP: Set address vltime and pltime to the length of the lease
Roy Marples <roy@marples.name>
parents:
4549
diff
changeset
|
238 DHCP_INFINITE_LIFETIME, DHCP_INFINITE_LIFETIME); |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
239 } |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
240 if (ia == NULL) |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
241 return; |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
242 #ifdef IN_IFF_NOTREADY |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
243 if (ia->addr_flags & IN_IFF_NOTREADY) |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
244 return; |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
245 logdebugx("%s: DAD completed for %s", ifp->name, ia->saddr); |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
246 #endif |
|
5237
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
247 |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
248 test: |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
249 state->addr = ia; |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
250 state->down = false; |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
251 if (ifp->ctx->options & DHCPCD_TEST) { |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
252 script_runreason(ifp, "TEST"); |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
253 eloop_exit(ifp->ctx->eloop, EXIT_SUCCESS); |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
254 return; |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
255 } |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
256 rt_build(ifp->ctx, AF_INET); |
| 5535 | 257 run: |
| 5239 | 258 astate = arp_announceaddr(ifp->ctx, &ia->addr); |
| 259 if (astate != NULL) | |
| 260 astate->announced_cb = ipv4ll_announced_arp; | |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
261 script_runreason(ifp, "IPV4LL"); |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
262 dhcpcd_daemonise(ifp->ctx); |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
263 } |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
264 |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
265 static void |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
266 ipv4ll_found(struct interface *ifp) |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
267 { |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
268 struct ipv4ll_state *state = IPV4LL_STATE(ifp); |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
269 |
|
5237
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
270 ipv4ll_freearp(ifp); |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
271 if (++state->conflicts == MAX_CONFLICTS) |
|
4733
8faf08ef0f93
IPv4LL: Ensure we pick another address on DAD conflict via ARP
Roy Marples <roy@marples.name>
parents:
4579
diff
changeset
|
272 logerrx("%s: failed to acquire an IPv4LL address", |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
273 ifp->name); |
| 5239 | 274 ipv4ll_pickaddr(ifp); |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
275 eloop_timeout_add_sec(ifp->ctx->eloop, |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
276 state->conflicts >= MAX_CONFLICTS ? |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
277 RATE_LIMIT_INTERVAL : PROBE_WAIT, |
|
5237
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
278 ipv4ll_start, ifp); |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
279 } |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
280 |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
281 static void |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
282 ipv4ll_defend_failed(struct interface *ifp) |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
283 { |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
284 struct ipv4ll_state *state = IPV4LL_STATE(ifp); |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
285 |
|
5237
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
286 ipv4ll_freearp(ifp); |
| 5535 | 287 if (ifp->options->options & DHCPCD_CONFIGURE) |
| 288 ipv4_deladdr(state->addr, 1); | |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
289 state->addr = NULL; |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
290 rt_build(ifp->ctx, AF_INET); |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
291 script_runreason(ifp, "IPV4LL"); |
| 5239 | 292 ipv4ll_pickaddr(ifp); |
|
5237
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
293 ipv4ll_start(ifp); |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
294 } |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
295 |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
296 #ifndef KERNEL_RFC5227 |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
297 static void |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
298 ipv4ll_not_found_arp(struct arp_state *astate) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
299 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
300 |
|
5237
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
301 ipv4ll_not_found(astate->iface); |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
302 } |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
303 |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
304 static void |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
305 ipv4ll_found_arp(struct arp_state *astate, __unused const struct arp_msg *amsg) |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
306 { |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
307 |
|
5237
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
308 ipv4ll_found(astate->iface); |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
309 } |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
310 |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
311 static void |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
312 ipv4ll_defend_failed_arp(struct arp_state *astate) |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
313 { |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
314 |
| 4457 | 315 ipv4ll_defend_failed(astate->iface); |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
316 } |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
317 #endif |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
318 |
|
5237
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
319 void |
|
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
320 ipv4ll_start(void *arg) |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
321 { |
|
5237
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
322 struct interface *ifp = arg; |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
323 struct ipv4ll_state *state; |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
324 struct ipv4_addr *ia; |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
325 bool repick; |
|
5237
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
326 #ifndef KERNEL_RFC5227 |
|
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
327 struct arp_state *astate; |
|
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
328 #endif |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
329 |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
330 if ((state = IPV4LL_STATE(ifp)) == NULL) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
331 ifp->if_data[IF_DATA_IPV4LL] = calloc(1, sizeof(*state)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
332 if ((state = IPV4LL_STATE(ifp)) == NULL) { |
| 4010 | 333 logerr(__func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
334 return; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
335 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
336 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
337 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
338 /* RFC 3927 Section 2.1 states that the random number generator |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
339 * SHOULD be seeded with a value derived from persistent information |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
340 * such as the IEEE 802 MAC address so that it usually picks |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
341 * the same address without persistent storage. */ |
|
4341
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
342 if (!state->seeded) { |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
343 unsigned int seed; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
344 char *orig; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
345 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
346 if (sizeof(seed) > ifp->hwlen) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
347 seed = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
348 memcpy(&seed, ifp->hwaddr, ifp->hwlen); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
349 } else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
350 memcpy(&seed, ifp->hwaddr + ifp->hwlen - sizeof(seed), |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
351 sizeof(seed)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
352 /* coverity[dont_call] */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
353 orig = initstate(seed, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
354 state->randomstate, sizeof(state->randomstate)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
355 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
356 /* Save the original state. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
357 if (ifp->ctx->randomstate == NULL) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
358 ifp->ctx->randomstate = orig; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
359 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
360 /* Set back the original state until we need the seeded one. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
361 setstate(ifp->ctx->randomstate); |
|
4341
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
362 state->seeded = true; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
363 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
364 |
|
4341
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
365 /* Find the previosuly used address. */ |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
366 if (state->pickedaddr.s_addr != INADDR_ANY) |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
367 ia = ipv4_iffindaddr(ifp, &state->pickedaddr, NULL); |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
368 else |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
369 ia = NULL; |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
370 |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
371 /* Find an existing IPv4LL address and ensure we can work with it. */ |
|
4341
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
372 if (ia == NULL) |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
373 ia = ipv4_iffindlladdr(ifp); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
374 |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
375 repick = false; |
|
4481
7848309c100c
sun: Don't define IN_IFF_TENTATIVE or IN_IFF_DETACHED
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
376 #ifdef IN_IFF_DUPLICATED |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
377 if (ia != NULL && ia->addr_flags & IN_IFF_DUPLICATED) { |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
378 state->pickedaddr = ia->addr; /* So it's not picked again. */ |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
379 repick = true; |
| 5535 | 380 if (ifp->options->options & DHCPCD_CONFIGURE) |
| 381 ipv4_deladdr(ia, 0); | |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
382 ia = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
383 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
384 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
385 |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
386 state->addr = ia; |
|
5237
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
387 state->down = true; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
388 if (ia != NULL) { |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
389 state->pickedaddr = ia->addr; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
390 #ifdef IN_IFF_TENTATIVE |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
391 if (ia->addr_flags & (IN_IFF_TENTATIVE | IN_IFF_DETACHED)) { |
|
4024
0984f93d896e
To be consitent, do the same to loginfo as we just did for logdebug.
Roy Marples <roy@marples.name>
parents:
4023
diff
changeset
|
392 loginfox("%s: waiting for DAD to complete on %s", |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
393 ifp->name, inet_ntoa(ia->addr)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
394 return; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
395 } |
|
4481
7848309c100c
sun: Don't define IN_IFF_TENTATIVE or IN_IFF_DETACHED
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
396 #endif |
|
7848309c100c
sun: Don't define IN_IFF_TENTATIVE or IN_IFF_DETACHED
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
397 #ifdef IN_IFF_DUPLICATED |
|
4024
0984f93d896e
To be consitent, do the same to loginfo as we just did for logdebug.
Roy Marples <roy@marples.name>
parents:
4023
diff
changeset
|
398 loginfox("%s: using IPv4LL address %s", ifp->name, ia->saddr); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
399 #endif |
| 5239 | 400 } else { |
| 401 loginfox("%s: probing for an IPv4LL address", ifp->name); | |
| 402 if (repick || state->pickedaddr.s_addr == INADDR_ANY) | |
| 403 ipv4ll_pickaddr(ifp); | |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
404 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
405 |
| 5239 | 406 #ifdef KERNEL_RFC5227 |
| 407 ipv4ll_not_found(ifp); | |
| 408 #else | |
|
5237
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
409 ipv4ll_freearp(ifp); |
| 5239 | 410 state->arp = astate = arp_new(ifp, &state->pickedaddr); |
|
5237
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
411 if (state->arp == NULL) |
|
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
412 return; |
|
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
413 |
|
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
414 astate->found_cb = ipv4ll_found_arp; |
|
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
415 astate->not_found_cb = ipv4ll_not_found_arp; |
|
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
416 astate->announced_cb = ipv4ll_announced_arp; |
|
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
417 astate->defend_failed_cb = ipv4ll_defend_failed_arp; |
| 5239 | 418 astate->free_cb = ipv4ll_free_arp; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
419 arp_probe(astate); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
420 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
421 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
422 |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
423 void |
|
4341
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
424 ipv4ll_drop(struct interface *ifp) |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
425 { |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
426 struct ipv4ll_state *state; |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
427 bool dropped = false; |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
428 struct ipv4_state *istate; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
429 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
430 assert(ifp != NULL); |
|
4341
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
431 |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
432 ipv4ll_freearp(ifp); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
433 |
|
4341
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
434 if ((ifp->options->options & DHCPCD_NODROP) == DHCPCD_NODROP) |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
435 return; |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
436 |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
437 state = IPV4LL_STATE(ifp); |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
438 if (state && state->addr != NULL) { |
| 5535 | 439 if (ifp->options->options & DHCPCD_CONFIGURE) |
| 440 ipv4_deladdr(state->addr, 1); | |
|
4341
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
441 state->addr = NULL; |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
442 dropped = true; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
443 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
444 |
|
4341
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
445 /* Free any other link local addresses that might exist. */ |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
446 if ((istate = IPV4_STATE(ifp)) != NULL) { |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
447 struct ipv4_addr *ia, *ian; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
448 |
|
4341
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
449 TAILQ_FOREACH_SAFE(ia, &istate->addrs, next, ian) { |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
450 if (IN_LINKLOCAL(ntohl(ia->addr.s_addr))) { |
| 5535 | 451 if (ifp->options->options & DHCPCD_CONFIGURE) |
| 452 ipv4_deladdr(ia, 0); | |
|
4341
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
453 dropped = true; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
454 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
455 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
456 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
457 |
|
4341
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
458 if (dropped) { |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
459 rt_build(ifp->ctx, AF_INET); |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
460 script_runreason(ifp, "IPV4LL"); |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
461 } |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
462 } |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
463 |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
464 void |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
465 ipv4ll_reset(struct interface *ifp) |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
466 { |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
467 struct ipv4ll_state *state = IPV4LL_STATE(ifp); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
468 |
|
4341
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
469 if (state == NULL) |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
470 return; |
|
5237
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
471 ipv4ll_freearp(ifp); |
|
4341
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
472 state->pickedaddr.s_addr = INADDR_ANY; |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
473 state->seeded = false; |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
474 } |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
475 |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
476 void |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
477 ipv4ll_free(struct interface *ifp) |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
478 { |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
479 |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
480 assert(ifp != NULL); |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
481 |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
482 ipv4ll_freearp(ifp); |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
483 free(IPV4LL_STATE(ifp)); |
|
990fde22c376
IPv4LL: Preserve address when carrier drops
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
484 ifp->if_data[IF_DATA_IPV4LL] = NULL; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
485 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
486 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
487 /* This may cause issues in BSD systems, where running as a single dhcpcd |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
488 * daemon would solve this issue easily. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
489 #ifdef HAVE_ROUTE_METRIC |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
490 int |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
491 ipv4ll_recvrt(__unused int cmd, const struct rt *rt) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
492 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
493 struct dhcpcd_ctx *ctx; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
494 struct interface *ifp; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
495 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
496 /* Only interested in default route changes. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
497 if (sa_is_unspecified(&rt->rt_dest)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
498 return 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
499 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
500 /* If any interface is running IPv4LL, rebuild our routing table. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
501 ctx = rt->rt_ifp->ctx; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
502 TAILQ_FOREACH(ifp, ctx->ifaces, next) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
503 if (IPV4LL_STATE_RUNNING(ifp)) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
504 rt_build(ctx, AF_INET); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
505 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
506 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
507 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
508 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
509 return 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
510 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
511 #endif |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
512 |
|
4737
65679ce5c370
inet: Rework prior incase DHCP uses an IPv4LL address
Roy Marples <roy@marples.name>
parents:
4735
diff
changeset
|
513 struct ipv4_addr * |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
514 ipv4ll_handleifa(int cmd, struct ipv4_addr *ia, pid_t pid) |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
515 { |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
516 struct interface *ifp; |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
517 struct ipv4ll_state *state; |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
518 |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
519 ifp = ia->iface; |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
520 state = IPV4LL_STATE(ifp); |
|
4579
e48ad224ab66
IPv4LL: Work once more on NetBSD
Roy Marples <roy@marples.name>
parents:
4555
diff
changeset
|
521 if (state == NULL) |
|
4737
65679ce5c370
inet: Rework prior incase DHCP uses an IPv4LL address
Roy Marples <roy@marples.name>
parents:
4735
diff
changeset
|
522 return ia; |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
523 |
|
4579
e48ad224ab66
IPv4LL: Work once more on NetBSD
Roy Marples <roy@marples.name>
parents:
4555
diff
changeset
|
524 if (cmd == RTM_DELADDR && |
|
e48ad224ab66
IPv4LL: Work once more on NetBSD
Roy Marples <roy@marples.name>
parents:
4555
diff
changeset
|
525 state->addr != NULL && |
|
e48ad224ab66
IPv4LL: Work once more on NetBSD
Roy Marples <roy@marples.name>
parents:
4555
diff
changeset
|
526 IN_ARE_ADDR_EQUAL(&state->addr->addr, &ia->addr)) |
|
e48ad224ab66
IPv4LL: Work once more on NetBSD
Roy Marples <roy@marples.name>
parents:
4555
diff
changeset
|
527 { |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
528 loginfox("%s: pid %d deleted IP address %s", |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
529 ifp->name, pid, ia->saddr); |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
530 ipv4ll_defend_failed(ifp); |
|
4737
65679ce5c370
inet: Rework prior incase DHCP uses an IPv4LL address
Roy Marples <roy@marples.name>
parents:
4735
diff
changeset
|
531 return ia; |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
532 } |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
533 |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
534 #ifdef IN_IFF_DUPLICATED |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
535 if (cmd != RTM_NEWADDR) |
|
4737
65679ce5c370
inet: Rework prior incase DHCP uses an IPv4LL address
Roy Marples <roy@marples.name>
parents:
4735
diff
changeset
|
536 return ia; |
|
4579
e48ad224ab66
IPv4LL: Work once more on NetBSD
Roy Marples <roy@marples.name>
parents:
4555
diff
changeset
|
537 if (!IN_ARE_ADDR_EQUAL(&state->pickedaddr, &ia->addr)) |
|
4737
65679ce5c370
inet: Rework prior incase DHCP uses an IPv4LL address
Roy Marples <roy@marples.name>
parents:
4735
diff
changeset
|
538 return ia; |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
539 if (!(ia->addr_flags & IN_IFF_NOTUSEABLE)) |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
540 ipv4ll_not_found(ifp); |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
541 else if (ia->addr_flags & IN_IFF_DUPLICATED) { |
|
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
542 logerrx("%s: DAD detected %s", ifp->name, ia->saddr); |
|
5237
65cef5f96919
IPv4LL: Fix for prior on NetBSD at least.
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
543 ipv4ll_freearp(ifp); |
| 5535 | 544 if (ifp->options->options & DHCPCD_CONFIGURE) |
| 545 ipv4_deladdr(ia, 1); | |
|
4739
92183be56652
IPv4LL: Pick a different address at conflict
Roy Marples <roy@marples.name>
parents:
4737
diff
changeset
|
546 state->addr = NULL; |
|
92183be56652
IPv4LL: Pick a different address at conflict
Roy Marples <roy@marples.name>
parents:
4737
diff
changeset
|
547 rt_build(ifp->ctx, AF_INET); |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
548 ipv4ll_found(ifp); |
|
4737
65679ce5c370
inet: Rework prior incase DHCP uses an IPv4LL address
Roy Marples <roy@marples.name>
parents:
4735
diff
changeset
|
549 return NULL; |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
550 } |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
551 #endif |
|
4737
65679ce5c370
inet: Rework prior incase DHCP uses an IPv4LL address
Roy Marples <roy@marples.name>
parents:
4735
diff
changeset
|
552 |
|
65679ce5c370
inet: Rework prior incase DHCP uses an IPv4LL address
Roy Marples <roy@marples.name>
parents:
4735
diff
changeset
|
553 return ia; |
|
4453
00fb50fd1a45
ARP: Refactor so that ACD is available for all inet addresses
Roy Marples <roy@marples.name>
parents:
4403
diff
changeset
|
554 } |
