]>
Commit | Line | Data |
---|---|---|
444c1184 MT |
1 | diff -up dhcp-4.2.4/client/dhclient.c.lpf-ib dhcp-4.2.4/client/dhclient.c |
2 | --- dhcp-4.2.4/client/dhclient.c.lpf-ib 2012-07-18 21:08:48.100835005 +0200 | |
3 | +++ dhcp-4.2.4/client/dhclient.c 2012-07-18 21:08:48.111834856 +0200 | |
4 | @@ -113,6 +113,8 @@ static int check_domain_name_list(const | |
6df985df SS |
5 | static int check_option_values(struct universe *universe, unsigned int opt, |
6 | const char *ptr, size_t len); | |
7 | ||
8 | +static void setup_ib_interface(struct interface_info *ip); | |
9 | + | |
10 | int | |
11 | main(int argc, char **argv) { | |
12 | int fd; | |
444c1184 | 13 | @@ -909,6 +911,14 @@ main(int argc, char **argv) { |
6df985df SS |
14 | } |
15 | srandom(seed + cur_time + (unsigned)getpid()); | |
16 | ||
17 | + /* Setup specific Infiniband options */ | |
18 | + for (ip = interfaces; ip; ip = ip->next) { | |
19 | + if (ip->client && | |
20 | + (ip->hw_address.hbuf[0] == HTYPE_INFINIBAND)) { | |
21 | + setup_ib_interface(ip); | |
22 | + } | |
23 | + } | |
24 | + | |
25 | /* Start a configuration state machine for each interface. */ | |
26 | #ifdef DHCPv6 | |
27 | if (local_family == AF_INET6) { | |
444c1184 | 28 | @@ -1185,6 +1195,29 @@ int find_subnet (struct subnet **sp, |
6df985df SS |
29 | return 0; |
30 | } | |
31 | ||
32 | +static void setup_ib_interface(struct interface_info *ip) | |
33 | +{ | |
34 | + struct group *g; | |
35 | + | |
36 | + /* Set the broadcast flag */ | |
37 | + ip->client->config->bootp_broadcast_always = 1; | |
38 | + | |
39 | + /* | |
40 | + * Find out if a dhcp-client-identifier option was specified either | |
41 | + * in the config file or on the command line | |
42 | + */ | |
43 | + for (g = ip->client->config->on_transmission; g != NULL; g = g->next) { | |
44 | + if ((g->statements != NULL) && | |
45 | + (strcmp(g->statements->data.option->option->name, | |
46 | + "dhcp-client-identifier") == 0)) { | |
47 | + return; | |
48 | + } | |
49 | + } | |
50 | + | |
51 | + /* No client ID specified */ | |
52 | + log_fatal("dhcp-client-identifier must be specified for InfiniBand"); | |
53 | +} | |
54 | + | |
55 | /* Individual States: | |
56 | * | |
57 | * Each routine is called from the dhclient_state_machine() in one of | |
444c1184 MT |
58 | diff -up dhcp-4.2.4/common/bpf.c.lpf-ib dhcp-4.2.4/common/bpf.c |
59 | --- dhcp-4.2.4/common/bpf.c.lpf-ib 2012-07-18 21:08:48.101834991 +0200 | |
60 | +++ dhcp-4.2.4/common/bpf.c 2012-07-18 21:08:48.111834856 +0200 | |
6df985df SS |
61 | @@ -198,11 +198,44 @@ struct bpf_insn dhcp_bpf_filter [] = { |
62 | BPF_STMT(BPF_RET+BPF_K, 0), | |
63 | }; | |
64 | ||
65 | +/* Packet filter program for DHCP over Infiniband. | |
66 | + * | |
67 | + * XXX | |
68 | + * Changes to the filter program may require changes to the constant offsets | |
69 | + * used in lpf_gen_filter_setup to patch the port in the BPF program! | |
70 | + * XXX | |
71 | + */ | |
72 | +struct bpf_insn dhcp_ib_bpf_filter [] = { | |
73 | + /* Packet filter for Infiniband */ | |
74 | + /* Make sure it's a UDP packet... */ | |
75 | + BPF_STMT(BPF_LD + BPF_B + BPF_ABS, 9), | |
76 | + BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, IPPROTO_UDP, 0, 6), | |
77 | + | |
78 | + /* Make sure this isn't a fragment... */ | |
79 | + BPF_STMT(BPF_LD + BPF_H + BPF_ABS, 6), | |
80 | + BPF_JUMP(BPF_JMP + BPF_JSET + BPF_K, 0x1fff, 4, 0), | |
81 | + | |
82 | + /* Get the IP header length... */ | |
83 | + BPF_STMT(BPF_LDX + BPF_B + BPF_MSH, 0), | |
84 | + | |
85 | + /* Make sure it's to the right port... */ | |
86 | + BPF_STMT(BPF_LD + BPF_H + BPF_IND, 2), | |
87 | + BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, 67, 0, 1), | |
88 | + | |
89 | + /* If we passed all the tests, ask for the whole packet. */ | |
90 | + BPF_STMT(BPF_RET + BPF_K, (u_int)-1), | |
91 | + | |
92 | + /* Otherwise, drop it. */ | |
93 | + BPF_STMT(BPF_RET + BPF_K, 0), | |
94 | +}; | |
95 | + | |
96 | #if defined (DEC_FDDI) | |
97 | struct bpf_insn *bpf_fddi_filter; | |
98 | #endif | |
99 | ||
100 | int dhcp_bpf_filter_len = sizeof dhcp_bpf_filter / sizeof (struct bpf_insn); | |
101 | +int dhcp_ib_bpf_filter_len = sizeof dhcp_ib_bpf_filter / sizeof (struct bpf_insn); | |
102 | + | |
103 | #if defined (HAVE_TR_SUPPORT) | |
104 | struct bpf_insn dhcp_bpf_tr_filter [] = { | |
105 | /* accept all token ring packets due to variable length header */ | |
444c1184 MT |
106 | diff -up dhcp-4.2.4/common/lpf.c.lpf-ib dhcp-4.2.4/common/lpf.c |
107 | --- dhcp-4.2.4/common/lpf.c.lpf-ib 2012-07-18 21:08:48.101834991 +0200 | |
108 | +++ dhcp-4.2.4/common/lpf.c 2012-07-18 21:10:47.367210799 +0200 | |
6df985df SS |
109 | @@ -42,6 +42,7 @@ |
110 | #include "includes/netinet/udp.h" | |
111 | #include "includes/netinet/if_ether.h" | |
112 | #include <net/if.h> | |
113 | +#include <ifaddrs.h> | |
114 | ||
115 | #ifndef PACKET_AUXDATA | |
116 | #define PACKET_AUXDATA 8 | |
117 | @@ -59,6 +60,15 @@ struct tpacket_auxdata | |
118 | /* Reinitializes the specified interface after an address change. This | |
119 | is not required for packet-filter APIs. */ | |
120 | ||
121 | +/* Default broadcast address for IPoIB */ | |
122 | +static unsigned char default_ib_bcast_addr[20] = { | |
123 | + 0x00, 0xff, 0xff, 0xff, | |
124 | + 0xff, 0x12, 0x40, 0x1b, | |
125 | + 0x00, 0x00, 0x00, 0x00, | |
126 | + 0x00, 0x00, 0x00, 0x00, | |
127 | + 0xff, 0xff, 0xff, 0xff | |
128 | +}; | |
129 | + | |
130 | #ifdef USE_LPF_SEND | |
131 | void if_reinitialize_send (info) | |
132 | struct interface_info *info; | |
133 | @@ -86,10 +96,21 @@ int if_register_lpf (info) | |
134 | struct sockaddr common; | |
135 | } sa; | |
136 | struct ifreq ifr; | |
137 | + int type; | |
138 | + int protocol; | |
139 | ||
140 | /* Make an LPF socket. */ | |
141 | - if ((sock = socket(PF_PACKET, SOCK_RAW, | |
142 | - htons((short)ETH_P_ALL))) < 0) { | |
143 | + get_hw_addr(info); | |
144 | + | |
145 | + if (info->hw_address.hbuf[0] == HTYPE_INFINIBAND) { | |
146 | + type = SOCK_DGRAM; | |
147 | + protocol = ETHERTYPE_IP; | |
148 | + } else { | |
149 | + type = SOCK_RAW; | |
150 | + protocol = ETH_P_ALL; | |
151 | + } | |
152 | + | |
153 | + if ((sock = socket(PF_PACKET, type, htons((short)protocol))) < 0) { | |
154 | if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT || | |
155 | errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT || | |
156 | errno == EAFNOSUPPORT || errno == EINVAL) { | |
157 | @@ -112,6 +133,7 @@ int if_register_lpf (info) | |
158 | /* Bind to the interface name */ | |
159 | memset (&sa, 0, sizeof sa); | |
160 | sa.ll.sll_family = AF_PACKET; | |
161 | + sa.ll.sll_protocol = htons(protocol); | |
162 | sa.ll.sll_ifindex = ifr.ifr_ifindex; | |
163 | if (bind (sock, &sa.common, sizeof sa)) { | |
164 | if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT || | |
165 | @@ -127,8 +149,6 @@ int if_register_lpf (info) | |
166 | log_fatal ("Bind socket to interface: %m"); | |
167 | } | |
168 | ||
169 | - get_hw_addr(info->name, &info->hw_address); | |
170 | - | |
171 | return sock; | |
172 | } | |
173 | #endif /* USE_LPF_SEND || USE_LPF_RECEIVE */ | |
174 | @@ -183,6 +203,8 @@ void if_deregister_send (info) | |
175 | in bpf includes... */ | |
176 | extern struct sock_filter dhcp_bpf_filter []; | |
177 | extern int dhcp_bpf_filter_len; | |
178 | +extern struct sock_filter dhcp_ib_bpf_filter []; | |
179 | +extern int dhcp_ib_bpf_filter_len; | |
180 | ||
181 | #if defined (HAVE_TR_SUPPORT) | |
182 | extern struct sock_filter dhcp_bpf_tr_filter []; | |
183 | @@ -200,11 +222,13 @@ void if_register_receive (info) | |
184 | /* Open a LPF device and hang it on this interface... */ | |
185 | info -> rfdesc = if_register_lpf (info); | |
186 | ||
187 | - val = 1; | |
188 | - if (setsockopt (info -> rfdesc, SOL_PACKET, PACKET_AUXDATA, &val, | |
189 | - sizeof val) < 0) { | |
190 | - if (errno != ENOPROTOOPT) | |
191 | - log_fatal ("Failed to set auxiliary packet data: %m"); | |
192 | + if (info->hw_address.hbuf[0] != HTYPE_INFINIBAND) { | |
193 | + val = 1; | |
194 | + if (setsockopt (info -> rfdesc, SOL_PACKET, PACKET_AUXDATA, | |
195 | + &val, sizeof val) < 0) { | |
196 | + if (errno != ENOPROTOOPT) | |
197 | + log_fatal ("Failed to set auxiliary packet data: %m"); | |
198 | + } | |
199 | } | |
200 | ||
201 | #if defined (HAVE_TR_SUPPORT) | |
202 | @@ -250,15 +274,28 @@ static void lpf_gen_filter_setup (info) | |
203 | ||
204 | memset(&p, 0, sizeof(p)); | |
205 | ||
206 | - /* Set up the bpf filter program structure. This is defined in | |
207 | - bpf.c */ | |
208 | - p.len = dhcp_bpf_filter_len; | |
209 | - p.filter = dhcp_bpf_filter; | |
210 | - | |
211 | - /* Patch the server port into the LPF program... | |
212 | - XXX changes to filter program may require changes | |
213 | - to the insn number(s) used below! XXX */ | |
214 | - dhcp_bpf_filter [8].k = ntohs ((short)local_port); | |
215 | + if (info->hw_address.hbuf[0] == HTYPE_INFINIBAND) { | |
216 | + /* Set up the bpf filter program structure. */ | |
217 | + p.len = dhcp_ib_bpf_filter_len; | |
218 | + p.filter = dhcp_ib_bpf_filter; | |
219 | + | |
220 | + /* Patch the server port into the LPF program... | |
221 | + XXX | |
222 | + changes to filter program may require changes | |
223 | + to the insn number(s) used below! | |
224 | + XXX */ | |
225 | + dhcp_ib_bpf_filter[6].k = ntohs ((short)local_port); | |
226 | + } else { | |
227 | + /* Set up the bpf filter program structure. | |
228 | + This is defined in bpf.c */ | |
229 | + p.len = dhcp_bpf_filter_len; | |
230 | + p.filter = dhcp_bpf_filter; | |
231 | + | |
232 | + /* Patch the server port into the LPF program... | |
233 | + XXX changes to filter program may require changes | |
234 | + to the insn number(s) used below! XXX */ | |
235 | + dhcp_bpf_filter [8].k = ntohs ((short)local_port); | |
236 | + } | |
237 | ||
238 | if (setsockopt (info -> rfdesc, SOL_SOCKET, SO_ATTACH_FILTER, &p, | |
239 | sizeof p) < 0) { | |
240 | @@ -315,6 +352,54 @@ static void lpf_tr_filter_setup (info) | |
241 | #endif /* USE_LPF_RECEIVE */ | |
242 | ||
243 | #ifdef USE_LPF_SEND | |
244 | +ssize_t send_packet_ib(interface, packet, raw, len, from, to, hto) | |
245 | + struct interface_info *interface; | |
246 | + struct packet *packet; | |
247 | + struct dhcp_packet *raw; | |
248 | + size_t len; | |
249 | + struct in_addr from; | |
250 | + struct sockaddr_in *to; | |
251 | + struct hardware *hto; | |
252 | +{ | |
253 | + unsigned ibufp = 0; | |
254 | + double ih [1536 / sizeof (double)]; | |
255 | + unsigned char *buf = (unsigned char *)ih; | |
256 | + ssize_t result; | |
257 | + | |
258 | + union sockunion { | |
259 | + struct sockaddr sa; | |
260 | + struct sockaddr_ll sll; | |
261 | + struct sockaddr_storage ss; | |
262 | + } su; | |
263 | + | |
264 | + assemble_udp_ip_header (interface, buf, &ibufp, from.s_addr, | |
265 | + to->sin_addr.s_addr, to->sin_port, | |
266 | + (unsigned char *)raw, len); | |
267 | + memcpy (buf + ibufp, raw, len); | |
268 | + | |
269 | + memset(&su, 0, sizeof(su)); | |
270 | + su.sll.sll_family = AF_PACKET; | |
271 | + su.sll.sll_protocol = htons(ETHERTYPE_IP); | |
272 | + | |
273 | + if (!(su.sll.sll_ifindex = if_nametoindex(interface->name))) { | |
274 | + errno = ENOENT; | |
275 | + log_error ("send_packet_ib: %m - failed to get if index"); | |
276 | + return -1; | |
277 | + } | |
278 | + | |
279 | + su.sll.sll_hatype = htons(HTYPE_INFINIBAND); | |
280 | + su.sll.sll_halen = sizeof(interface->bcast_addr); | |
281 | + memcpy(&su.sll.sll_addr, interface->bcast_addr, 20); | |
282 | + | |
283 | + result = sendto(interface->wfdesc, buf, ibufp + len, 0, | |
284 | + &su.sa, sizeof(su)); | |
285 | + | |
286 | + if (result < 0) | |
287 | + log_error ("send_packet_ib: %m"); | |
288 | + | |
289 | + return result; | |
290 | +} | |
291 | + | |
292 | ssize_t send_packet (interface, packet, raw, len, from, to, hto) | |
293 | struct interface_info *interface; | |
294 | struct packet *packet; | |
444c1184 | 295 | @@ -335,6 +420,11 @@ ssize_t send_packet (interface, packet, |
6df985df SS |
296 | return send_fallback (interface, packet, raw, |
297 | len, from, to, hto); | |
298 | ||
299 | + if (interface->hw_address.hbuf[0] == HTYPE_INFINIBAND) { | |
300 | + return send_packet_ib(interface, packet, raw, len, from, | |
301 | + to, hto); | |
302 | + } | |
303 | + | |
304 | if (hto == NULL && interface->anycast_mac_addr.hlen) | |
305 | hto = &interface->anycast_mac_addr; | |
306 | ||
444c1184 | 307 | @@ -356,6 +446,42 @@ ssize_t send_packet (interface, packet, |
6df985df SS |
308 | #endif /* USE_LPF_SEND */ |
309 | ||
310 | #ifdef USE_LPF_RECEIVE | |
311 | +ssize_t receive_packet_ib (interface, buf, len, from, hfrom) | |
312 | + struct interface_info *interface; | |
313 | + unsigned char *buf; | |
314 | + size_t len; | |
315 | + struct sockaddr_in *from; | |
316 | + struct hardware *hfrom; | |
317 | +{ | |
318 | + int length = 0; | |
319 | + int offset = 0; | |
320 | + unsigned char ibuf [1536]; | |
321 | + unsigned bufix = 0; | |
322 | + unsigned paylen; | |
323 | + | |
324 | + length = read(interface->rfdesc, ibuf, sizeof(ibuf)); | |
325 | + | |
326 | + if (length <= 0) | |
327 | + return length; | |
328 | + | |
329 | + offset = decode_udp_ip_header(interface, ibuf, bufix, from, | |
330 | + (unsigned)length, &paylen, 0); | |
331 | + | |
332 | + if (offset < 0) | |
333 | + return 0; | |
334 | + | |
335 | + bufix += offset; | |
336 | + length -= offset; | |
337 | + | |
338 | + if (length < paylen) | |
339 | + log_fatal("Internal inconsistency at %s:%d.", MDL); | |
340 | + | |
341 | + /* Copy out the data in the packet... */ | |
342 | + memcpy(buf, &ibuf[bufix], paylen); | |
343 | + | |
344 | + return (ssize_t)paylen; | |
345 | +} | |
346 | + | |
347 | ssize_t receive_packet (interface, buf, len, from, hfrom) | |
348 | struct interface_info *interface; | |
349 | unsigned char *buf; | |
444c1184 | 350 | @@ -382,6 +508,10 @@ ssize_t receive_packet (interface, buf, |
6df985df SS |
351 | }; |
352 | struct cmsghdr *cmsg; | |
353 | ||
354 | + if (interface->hw_address.hbuf[0] == HTYPE_INFINIBAND) { | |
355 | + return receive_packet_ib(interface, buf, len, from, hfrom); | |
356 | + } | |
357 | + | |
358 | length = recvmsg (interface -> rfdesc, &msg, 0); | |
359 | if (length <= 0) | |
360 | return length; | |
444c1184 MT |
361 | @@ -461,11 +591,32 @@ void maybe_setup_fallback () |
362 | } | |
6df985df SS |
363 | } |
364 | ||
444c1184 | 365 | -void |
6df985df | 366 | -get_hw_addr(const char *name, struct hardware *hw) { |
444c1184 MT |
367 | +struct sockaddr_ll * |
368 | +get_ll (struct ifaddrs *ifaddrs, struct ifaddrs **ifa, char *name) | |
6df985df | 369 | +{ |
444c1184 MT |
370 | + for (*ifa = ifaddrs; *ifa != NULL; *ifa = (*ifa)->ifa_next) { |
371 | + if ((*ifa)->ifa_addr == NULL) | |
6df985df SS |
372 | + continue; |
373 | + | |
444c1184 | 374 | + if ((*ifa)->ifa_addr->sa_family != AF_PACKET) |
6df985df SS |
375 | + continue; |
376 | + | |
444c1184 | 377 | + if ((*ifa)->ifa_flags & IFF_LOOPBACK) |
6df985df SS |
378 | + continue; |
379 | + | |
444c1184 MT |
380 | + if (strcmp((*ifa)->ifa_name, name) == 0) |
381 | + return (struct sockaddr_ll *)(void *)(*ifa)->ifa_addr; | |
382 | + } | |
383 | + return NULL; | |
384 | +} | |
385 | + | |
386 | +struct sockaddr_ll * | |
387 | +ioctl_get_ll(char *name) | |
388 | +{ | |
389 | int sock; | |
390 | struct ifreq tmp; | |
391 | - struct sockaddr *sa; | |
392 | + struct sockaddr *sa = NULL; | |
393 | + struct sockaddr_ll *sll = NULL; | |
6df985df | 394 | |
444c1184 MT |
395 | if (strlen(name) >= sizeof(tmp.ifr_name)) { |
396 | log_fatal("Device name too long: \"%s\"", name); | |
397 | @@ -479,16 +630,44 @@ get_hw_addr(const char *name, struct har | |
398 | memset(&tmp, 0, sizeof(tmp)); | |
399 | strcpy(tmp.ifr_name, name); | |
400 | if (ioctl(sock, SIOCGIFHWADDR, &tmp) < 0) { | |
6df985df | 401 | - log_fatal("Error getting hardware address for \"%s\": %m", |
444c1184 MT |
402 | + log_fatal("Error getting hardware address for \"%s\": %m", |
403 | name); | |
6df985df SS |
404 | } |
405 | ||
444c1184 | 406 | sa = &tmp.ifr_hwaddr; |
6df985df | 407 | - switch (sa->sa_family) { |
444c1184 MT |
408 | + sll = dmalloc (sizeof (struct sockaddr_ll), MDL); |
409 | + if (!sll) | |
410 | + log_fatal("Unable to allocate memory for link layer address"); | |
411 | + memcpy(&sll->sll_hatype, &sa->sa_family, sizeof (sll->sll_hatype)); | |
412 | + memcpy(sll->sll_addr, sa->sa_data, sizeof (sll->sll_addr)); | |
413 | + return sll; | |
414 | +} | |
415 | + | |
416 | +void | |
417 | +get_hw_addr(struct interface_info *info) | |
418 | +{ | |
419 | + struct hardware *hw = &info->hw_address; | |
420 | + char *name = info->name; | |
421 | + struct ifaddrs *ifaddrs = NULL; | |
422 | + struct ifaddrs *ifa = NULL; | |
423 | + struct sockaddr_ll *sll = NULL; | |
424 | + | |
425 | + if (getifaddrs(&ifaddrs) == -1) | |
426 | + log_fatal("Failed to get interfaces"); | |
427 | + | |
428 | + if ((sll = get_ll(ifaddrs, &ifa, name)) == NULL) { | |
429 | + /* | |
430 | + * We were unable to get link-layer address for name. | |
431 | + * Fall back to ioctl(SIOCGIFHWADDR). | |
432 | + */ | |
433 | + sll = ioctl_get_ll(name); | |
434 | + } | |
435 | + | |
6df985df SS |
436 | + switch (sll->sll_hatype) { |
437 | case ARPHRD_ETHER: | |
438 | hw->hlen = 7; | |
439 | hw->hbuf[0] = HTYPE_ETHER; | |
440 | - memcpy(&hw->hbuf[1], sa->sa_data, 6); | |
441 | + memcpy(&hw->hbuf[1], sll->sll_addr, 6); | |
442 | break; | |
443 | case ARPHRD_IEEE802: | |
444 | #ifdef ARPHRD_IEEE802_TR | |
444c1184 | 445 | @@ -496,18 +675,35 @@ get_hw_addr(const char *name, struct har |
6df985df SS |
446 | #endif /* ARPHRD_IEEE802_TR */ |
447 | hw->hlen = 7; | |
448 | hw->hbuf[0] = HTYPE_IEEE802; | |
449 | - memcpy(&hw->hbuf[1], sa->sa_data, 6); | |
450 | + memcpy(&hw->hbuf[1], sll->sll_addr, 6); | |
451 | break; | |
452 | case ARPHRD_FDDI: | |
453 | hw->hlen = 17; | |
454 | hw->hbuf[0] = HTYPE_FDDI; | |
455 | - memcpy(&hw->hbuf[1], sa->sa_data, 16); | |
456 | + memcpy(&hw->hbuf[1], sll->sll_addr, 16); | |
457 | + break; | |
458 | + case ARPHRD_INFINIBAND: | |
459 | + /* For Infiniband, save the broadcast address and store | |
460 | + * the port GUID into the hardware address. | |
461 | + */ | |
462 | + if (ifa->ifa_flags & IFF_BROADCAST) { | |
463 | + struct sockaddr_ll *bll; | |
464 | + | |
465 | + bll = (struct sockaddr_ll *)ifa->ifa_broadaddr; | |
466 | + memcpy(&info->bcast_addr, bll->sll_addr, 20); | |
467 | + } else { | |
468 | + memcpy(&info->bcast_addr, default_ib_bcast_addr, | |
469 | + 20); | |
470 | + } | |
471 | + | |
472 | + hw->hlen = 1; | |
473 | + hw->hbuf[0] = HTYPE_INFINIBAND; | |
474 | break; | |
475 | #if defined(ARPHRD_PPP) | |
476 | case ARPHRD_PPP: | |
477 | if (local_family != AF_INET6) | |
478 | - log_fatal("Unsupported device type %d for \"%s\"", | |
479 | - sa->sa_family, name); | |
444c1184 MT |
480 | + log_fatal("local_family != AF_INET6 for \"%s\"", |
481 | + name); | |
6df985df SS |
482 | hw->hlen = 0; |
483 | hw->hbuf[0] = HTYPE_RESERVED; | |
484 | /* 0xdeadbeef should never occur on the wire, | |
444c1184 | 485 | @@ -520,10 +716,11 @@ get_hw_addr(const char *name, struct har |
6df985df SS |
486 | break; |
487 | #endif | |
488 | default: | |
444c1184 | 489 | - log_fatal("Unsupported device type %ld for \"%s\"", |
6df985df | 490 | - (long int)sa->sa_family, name); |
444c1184 MT |
491 | + freeifaddrs(ifaddrs); |
492 | + log_fatal("Unsupported device type %h for \"%s\"", | |
493 | + sll->sll_hatype, name); | |
6df985df SS |
494 | } |
495 | ||
496 | - close(sock); | |
497 | + freeifaddrs(ifaddrs); | |
498 | } | |
499 | #endif | |
444c1184 MT |
500 | diff -up dhcp-4.2.4/common/socket.c.lpf-ib dhcp-4.2.4/common/socket.c |
501 | --- dhcp-4.2.4/common/socket.c.lpf-ib 2012-03-09 12:28:11.000000000 +0100 | |
502 | +++ dhcp-4.2.4/common/socket.c 2012-07-18 21:08:48.112834843 +0200 | |
503 | @@ -325,7 +325,7 @@ void if_register_send (info) | |
6df985df SS |
504 | info->wfdesc = if_register_socket(info, AF_INET, 0); |
505 | /* If this is a normal IPv4 address, get the hardware address. */ | |
506 | if (strcmp(info->name, "fallback") != 0) | |
507 | - get_hw_addr(info->name, &info->hw_address); | |
508 | + get_hw_addr(info); | |
509 | #if defined (USE_SOCKET_FALLBACK) | |
510 | /* Fallback only registers for send, but may need to receive as | |
511 | well. */ | |
444c1184 | 512 | @@ -388,7 +388,7 @@ void if_register_receive (info) |
6df985df SS |
513 | #endif /* IP_PKTINFO... */ |
514 | /* If this is a normal IPv4 address, get the hardware address. */ | |
515 | if (strcmp(info->name, "fallback") != 0) | |
516 | - get_hw_addr(info->name, &info->hw_address); | |
517 | + get_hw_addr(info); | |
518 | ||
519 | if (!quiet_interface_discovery) | |
520 | log_info ("Listening on Socket/%s%s%s", | |
444c1184 | 521 | @@ -498,7 +498,7 @@ if_register6(struct interface_info *info |
6df985df SS |
522 | if (req_multi) |
523 | if_register_multicast(info); | |
524 | ||
525 | - get_hw_addr(info->name, &info->hw_address); | |
526 | + get_hw_addr(info); | |
527 | ||
528 | if (!quiet_interface_discovery) { | |
529 | if (info->shared_network != NULL) { | |
444c1184 MT |
530 | diff -up dhcp-4.2.4/includes/dhcpd.h.lpf-ib dhcp-4.2.4/includes/dhcpd.h |
531 | --- dhcp-4.2.4/includes/dhcpd.h.lpf-ib 2012-07-18 21:08:48.102834978 +0200 | |
532 | +++ dhcp-4.2.4/includes/dhcpd.h 2012-07-18 21:08:48.114834815 +0200 | |
6df985df SS |
533 | @@ -1243,6 +1243,7 @@ struct interface_info { |
534 | struct shared_network *shared_network; | |
535 | /* Networks connected to this interface. */ | |
536 | struct hardware hw_address; /* Its physical address. */ | |
537 | + u_int8_t bcast_addr[20]; /* Infiniband broadcast address */ | |
538 | struct in_addr *addresses; /* Addresses associated with this | |
539 | * interface. | |
540 | */ | |
444c1184 | 541 | @@ -2360,7 +2361,7 @@ void print_dns_status (int, struct dhcp_ |
6df985df SS |
542 | #endif |
543 | const char *print_time(TIME); | |
544 | ||
545 | -void get_hw_addr(const char *name, struct hardware *hw); | |
546 | +void get_hw_addr(struct interface_info *info); | |
547 | ||
548 | /* socket.c */ | |
549 | #if defined (USE_SOCKET_SEND) || defined (USE_SOCKET_RECEIVE) \ |