2 * Copyright (C) 2010 Felix Fietkau <nbd@openwrt.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License v2 as published by
6 * the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18 #include <sys/ioctl.h>
19 #include <sys/socket.h>
34 static LIST_HEAD(pending_routes
);
35 LIST_HEAD(interfaces
);
38 static int host_timeout
;
40 static int forward_bcast
;
41 static int forward_dhcp
;
43 uint8_t local_addr
[4];
44 int local_route_table
;
46 struct relayd_pending_route
{
47 struct relayd_route rt
;
48 struct uloop_timeout timeout
;
52 static struct relayd_host
*find_host_by_ipaddr(struct relayd_interface
*rif
, const uint8_t *ipaddr
)
54 struct relayd_host
*host
;
57 list_for_each_entry(rif
, &interfaces
, list
) {
58 host
= find_host_by_ipaddr(rif
, ipaddr
);
67 list_for_each_entry(host
, &rif
->hosts
, list
) {
68 if (memcmp(ipaddr
, host
->ipaddr
, sizeof(host
->ipaddr
)) != 0)
76 static void add_arp(struct relayd_host
*host
)
78 struct sockaddr_in
*sin
;
81 strncpy(arp
.arp_dev
, host
->rif
->ifname
, sizeof(arp
.arp_dev
));
82 arp
.arp_flags
= ATF_COM
;
84 arp
.arp_ha
.sa_family
= ARPHRD_ETHER
;
85 memcpy(arp
.arp_ha
.sa_data
, host
->lladdr
, ETH_ALEN
);
87 sin
= (struct sockaddr_in
*) &arp
.arp_pa
;
88 sin
->sin_family
= AF_INET
;
89 memcpy(&sin
->sin_addr
, host
->ipaddr
, sizeof(host
->ipaddr
));
91 ioctl(inet_sock
, SIOCSARP
, &arp
);
94 static void timeout_host_route(struct uloop_timeout
*timeout
)
96 struct relayd_pending_route
*rt
;
98 rt
= container_of(timeout
, struct relayd_pending_route
, timeout
);
99 list_del(&rt
->rt
.list
);
103 void relayd_add_host_route(struct relayd_host
*host
, const uint8_t *dest
, uint8_t mask
)
105 struct relayd_route
*rt
;
107 list_for_each_entry(rt
, &host
->routes
, list
) {
108 if (!memcmp(rt
->dest
, dest
, sizeof(rt
->dest
)) && rt
->mask
== mask
)
112 rt
= calloc(1, sizeof(*rt
));
116 list_add(&rt
->list
, &host
->routes
);
117 memcpy(rt
->dest
, dest
, sizeof(rt
->dest
));
119 relayd_add_route(host
, rt
);
122 static void del_host(struct relayd_host
*host
)
124 struct relayd_route
*route
, *tmp
;
126 DPRINTF(1, "%s: deleting host "IP_FMT
" ("MAC_FMT
")\n", host
->rif
->ifname
,
127 IP_BUF(host
->ipaddr
), MAC_BUF(host
->lladdr
));
129 list_for_each_entry_safe(route
, tmp
, &host
->routes
, list
) {
130 relayd_del_route(host
, route
);
131 list_del(&route
->list
);
134 if (host
->rif
->managed
)
135 relayd_del_route(host
, NULL
);
136 uloop_timeout_cancel(&host
->timeout
);
137 list_del(&host
->list
);
141 static void fill_arp_packet(struct arp_packet
*pkt
, struct relayd_interface
*rif
,
142 const uint8_t spa
[4], const uint8_t tpa
[4])
144 memset(pkt
, 0, sizeof(*pkt
));
146 pkt
->eth
.ether_type
= htons(ETHERTYPE_ARP
);
147 memcpy(pkt
->eth
.ether_shost
, rif
->sll
.sll_addr
, ETH_ALEN
);
149 memcpy(pkt
->arp
.arp_sha
, rif
->sll
.sll_addr
, ETH_ALEN
);
150 memcpy(pkt
->arp
.arp_spa
, spa
, 4);
151 memcpy(pkt
->arp
.arp_tpa
, tpa
, 4);
153 pkt
->arp
.arp_hrd
= htons(ARPHRD_ETHER
);
154 pkt
->arp
.arp_pro
= htons(ETH_P_IP
);
155 pkt
->arp
.arp_hln
= ETH_ALEN
;
156 pkt
->arp
.arp_pln
= 4;
159 static void send_arp_request(struct relayd_interface
*rif
, const uint8_t *ipaddr
)
161 struct arp_packet pkt
;
163 fill_arp_packet(&pkt
, rif
, rif
->src_ip
, ipaddr
);
165 pkt
.arp
.arp_op
= htons(ARPOP_REQUEST
);
166 memcpy(pkt
.arp
.arp_spa
, rif
->src_ip
, ETH_ALEN
);
167 memset(pkt
.arp
.arp_tha
, 0, ETH_ALEN
);
168 memset(pkt
.eth
.ether_dhost
, 0xff, ETH_ALEN
);
170 DPRINTF(2, "%s: sending ARP who-has "IP_FMT
", tell "IP_FMT
" ("MAC_FMT
")\n",
171 rif
->ifname
, IP_BUF(pkt
.arp
.arp_tpa
),
172 IP_BUF(pkt
.arp
.arp_spa
), MAC_BUF(pkt
.eth
.ether_shost
));
174 sendto(rif
->fd
.fd
, &pkt
, sizeof(pkt
), 0,
175 (struct sockaddr
*) &rif
->sll
, sizeof(rif
->sll
));
178 void relayd_add_pending_route(const uint8_t *gateway
, const uint8_t *dest
, uint8_t mask
, int timeout
)
180 struct relayd_pending_route
*rt
;
181 struct relayd_interface
*rif
;
182 struct relayd_host
*host
;
184 host
= find_host_by_ipaddr(NULL
, gateway
);
186 relayd_add_host_route(host
, dest
, mask
);
190 rt
= calloc(1, sizeof(*rt
));
194 memcpy(rt
->gateway
, gateway
, sizeof(rt
->gateway
));
195 memcpy(rt
->rt
.dest
, dest
, sizeof(rt
->rt
.dest
));
197 list_add(&rt
->rt
.list
, &pending_routes
);
201 rt
->timeout
.cb
= timeout_host_route
;
202 uloop_timeout_set(&rt
->timeout
, 10000);
203 list_for_each_entry(rif
, &interfaces
, list
) {
204 send_arp_request(rif
, gateway
);
208 static void send_arp_reply(struct relayd_interface
*rif
, uint8_t spa
[4],
209 uint8_t tha
[ETH_ALEN
], uint8_t tpa
[4])
211 struct arp_packet pkt
;
213 fill_arp_packet(&pkt
, rif
, spa
, tpa
);
215 pkt
.arp
.arp_op
= htons(ARPOP_REPLY
);
217 memcpy(pkt
.eth
.ether_dhost
, tha
, ETH_ALEN
);
218 memcpy(pkt
.arp
.arp_tha
, tha
, ETH_ALEN
);
220 DPRINTF(2, "%s: sending ARP reply to "IP_FMT
", "IP_FMT
" is at ("MAC_FMT
")\n",
221 rif
->ifname
, IP_BUF(pkt
.arp
.arp_tpa
),
222 IP_BUF(pkt
.arp
.arp_spa
), MAC_BUF(pkt
.eth
.ether_shost
));
224 memset(pkt
.eth
.ether_dhost
, 0xff, ETH_ALEN
);
225 memset(pkt
.arp
.arp_tha
, 0, ETH_ALEN
);
227 DPRINTF(2, "%s: sending gratuitous ARP: "IP_FMT
" is at ("MAC_FMT
")\n",
228 rif
->ifname
, IP_BUF(pkt
.arp
.arp_tpa
),
229 MAC_BUF(pkt
.eth
.ether_shost
));
232 sendto(rif
->fd
.fd
, &pkt
, sizeof(pkt
), 0,
233 (struct sockaddr
*) &rif
->sll
, sizeof(rif
->sll
));
236 static void host_entry_timeout(struct uloop_timeout
*timeout
)
238 struct relayd_host
*host
= container_of(timeout
, struct relayd_host
, timeout
);
241 * When a host is behind a managed interface, we must not expire its host
242 * entry prematurely, as this will cause routes to the node to expire,
243 * leading to loss of connectivity from the other side.
244 * When the timeout is reached, try pinging the host a few times before
247 if (host
->rif
->managed
&& host
->cleanup_pending
< 2) {
248 send_arp_request(host
->rif
, host
->ipaddr
);
249 host
->cleanup_pending
++;
250 uloop_timeout_set(&host
->timeout
, 1000);
256 static struct relayd_host
*add_host(struct relayd_interface
*rif
, const uint8_t *lladdr
, const uint8_t *ipaddr
)
258 struct relayd_host
*host
;
259 struct relayd_pending_route
*route
, *rtmp
;
261 DPRINTF(1, "%s: adding host "IP_FMT
" ("MAC_FMT
")\n", rif
->ifname
,
262 IP_BUF(ipaddr
), MAC_BUF(lladdr
));
264 host
= calloc(1, sizeof(*host
));
265 INIT_LIST_HEAD(&host
->routes
);
267 memcpy(host
->ipaddr
, ipaddr
, sizeof(host
->ipaddr
));
268 memcpy(host
->lladdr
, lladdr
, sizeof(host
->lladdr
));
269 list_add(&host
->list
, &rif
->hosts
);
270 host
->timeout
.cb
= host_entry_timeout
;
271 uloop_timeout_set(&host
->timeout
, host_timeout
* 1000);
275 relayd_add_route(host
, NULL
);
277 list_for_each_entry_safe(route
, rtmp
, &pending_routes
, rt
.list
) {
278 if (memcmp(route
->gateway
, ipaddr
, 4) != 0)
281 relayd_add_host_route(host
, route
->rt
.dest
, route
->rt
.mask
);
282 if (!route
->timeout
.pending
)
285 uloop_timeout_cancel(&route
->timeout
);
286 list_del(&route
->rt
.list
);
293 struct relayd_host
*relayd_refresh_host(struct relayd_interface
*rif
, const uint8_t *lladdr
, const uint8_t *ipaddr
)
295 struct relayd_host
*host
;
297 host
= find_host_by_ipaddr(rif
, ipaddr
);
299 host
= find_host_by_ipaddr(NULL
, ipaddr
);
302 * When we suddenly see the host appearing on a different interface,
303 * reduce the timeout to make the old entry expire faster, in case the
305 * If the old entry is behind a managed interface, it will be pinged
306 * before we expire it
308 if (host
&& !host
->cleanup_pending
) {
309 uloop_timeout_set(&host
->timeout
, 1);
313 host
= add_host(rif
, lladdr
, ipaddr
);
315 host
->cleanup_pending
= false;
316 uloop_timeout_set(&host
->timeout
, host_timeout
* 1000);
322 static void relay_arp_request(struct relayd_interface
*from_rif
, struct arp_packet
*pkt
)
324 struct relayd_interface
*rif
;
325 struct arp_packet reqpkt
;
327 memcpy(&reqpkt
, pkt
, sizeof(reqpkt
));
328 list_for_each_entry(rif
, &interfaces
, list
) {
332 memcpy(reqpkt
.eth
.ether_shost
, rif
->sll
.sll_addr
, ETH_ALEN
);
333 memcpy(reqpkt
.arp
.arp_sha
, rif
->sll
.sll_addr
, ETH_ALEN
);
335 DPRINTF(2, "%s: sending ARP who-has "IP_FMT
", tell "IP_FMT
" ("MAC_FMT
")\n",
336 rif
->ifname
, IP_BUF(reqpkt
.arp
.arp_tpa
),
337 IP_BUF(reqpkt
.arp
.arp_spa
), MAC_BUF(reqpkt
.eth
.ether_shost
));
339 sendto(rif
->fd
.fd
, &reqpkt
, sizeof(reqpkt
), 0,
340 (struct sockaddr
*) &rif
->sll
, sizeof(rif
->sll
));
344 static void recv_arp_request(struct relayd_interface
*rif
, struct arp_packet
*pkt
)
346 struct relayd_host
*host
;
348 DPRINTF(2, "%s: ARP who-has "IP_FMT
", tell "IP_FMT
" ("MAC_FMT
")\n",
350 IP_BUF(pkt
->arp
.arp_tpa
),
351 IP_BUF(pkt
->arp
.arp_spa
),
352 MAC_BUF(pkt
->eth
.ether_shost
));
354 if (!memcmp(pkt
->arp
.arp_spa
, "\x00\x00\x00\x00", 4))
357 if (local_route_table
&& !memcmp(pkt
->arp
.arp_tpa
, local_addr
, sizeof(local_addr
))) {
358 send_arp_reply(rif
, local_addr
, pkt
->arp
.arp_sha
, pkt
->arp
.arp_spa
);
362 relayd_refresh_host(rif
, pkt
->eth
.ether_shost
, pkt
->arp
.arp_spa
);
364 host
= find_host_by_ipaddr(NULL
, pkt
->arp
.arp_tpa
);
367 * If a host is being pinged because of a timeout, do not use the cached
368 * entry here. That way we can avoid giving out stale data in case the node
369 * has moved. We shouldn't relay requests here either, as we might miss our
370 * chance to create a host route.
372 if (host
&& host
->cleanup_pending
)
375 relay_arp_request(rif
, pkt
);
379 static void recv_arp_reply(struct relayd_interface
*rif
, struct arp_packet
*pkt
)
381 struct relayd_interface
*to_rif
;
382 struct relayd_host
*host
;
384 DPRINTF(2, "%s: received ARP reply for "IP_FMT
" from "MAC_FMT
", deliver to "IP_FMT
"\n",
386 IP_BUF(pkt
->arp
.arp_spa
),
387 MAC_BUF(pkt
->eth
.ether_shost
),
388 IP_BUF(pkt
->arp
.arp_tpa
));
390 if (memcmp(pkt
->arp
.arp_sha
, rif
->sll
.sll_addr
, ETH_ALEN
) != 0)
391 relayd_refresh_host(rif
, pkt
->arp
.arp_sha
, pkt
->arp
.arp_spa
);
393 if (!memcmp(pkt
->arp
.arp_tpa
, rif
->src_ip
, 4)) {
395 * locally initiated lookup, relay as gratuitous ARP
396 * to all other interfaces
398 list_for_each_entry(to_rif
, &interfaces
, list
) {
402 send_arp_reply(to_rif
, pkt
->arp
.arp_spa
, NULL
, pkt
->arp
.arp_spa
);
407 host
= find_host_by_ipaddr(NULL
, pkt
->arp
.arp_tpa
);
411 if (host
->rif
== rif
)
414 send_arp_reply(host
->rif
, pkt
->arp
.arp_spa
, host
->lladdr
, host
->ipaddr
);
417 static void recv_packet(struct uloop_fd
*fd
, unsigned int events
)
419 struct relayd_interface
*rif
= container_of(fd
, struct relayd_interface
, fd
);
420 struct arp_packet
*pkt
;
421 static char pktbuf
[4096];
428 pktlen
= recv(rif
->fd
.fd
, pktbuf
, sizeof(pktbuf
), 0);
439 pkt
= (void *)pktbuf
;
440 if (pkt
->arp
.arp_op
== htons(ARPOP_REPLY
))
441 recv_arp_reply(rif
, pkt
);
442 else if (pkt
->arp
.arp_op
== htons(ARPOP_REQUEST
))
443 recv_arp_request(rif
, pkt
);
445 DPRINTF(1, "received unknown packet type: %04x\n", ntohs(pkt
->arp
.arp_op
));
450 void relayd_forward_bcast_packet(struct relayd_interface
*from_rif
, void *packet
, int len
)
452 struct relayd_interface
*rif
;
453 struct ether_header
*eth
= packet
;
455 list_for_each_entry(rif
, &interfaces
, list
) {
459 DPRINTF(3, "%s: forwarding broadcast packet to %s\n", from_rif
->ifname
, rif
->ifname
);
460 memcpy(eth
->ether_shost
, rif
->sll
.sll_addr
, ETH_ALEN
);
461 send(rif
->bcast_fd
.fd
, packet
, len
, 0);
465 static void recv_bcast_packet(struct uloop_fd
*fd
, unsigned int events
)
467 struct relayd_interface
*rif
= container_of(fd
, struct relayd_interface
, bcast_fd
);
468 static char pktbuf
[4096];
475 pktlen
= recv(rif
->bcast_fd
.fd
, pktbuf
, sizeof(pktbuf
), 0);
486 if (!forward_bcast
&& !forward_dhcp
)
489 if (relayd_handle_dhcp_packet(rif
, pktbuf
, pktlen
, forward_dhcp
))
493 relayd_forward_bcast_packet(rif
, pktbuf
, pktlen
);
498 static int init_interface(struct relayd_interface
*rif
)
500 struct sockaddr_ll
*sll
= &rif
->sll
;
501 struct sockaddr_in
*sin
;
504 #ifdef PACKET_RECV_TYPE
505 unsigned int pkt_type
;
508 fd
= socket(AF_PACKET
, SOCK_RAW
, htons(ETH_P_ARP
));
514 memset(&ifr
, 0, sizeof(ifr
));
515 strcpy(ifr
.ifr_name
, rif
->ifname
);
517 if (ioctl(fd
, SIOCGIFHWADDR
, &ifr
) < 0) {
518 perror("ioctl(SIOCGIFHWADDR)");
522 memcpy(sll
->sll_addr
, ifr
.ifr_hwaddr
.sa_data
, ETH_ALEN
);
523 sll
->sll_family
= AF_PACKET
;
524 sll
->sll_protocol
= htons(ETH_P_ARP
);
525 sll
->sll_pkttype
= PACKET_BROADCAST
;
526 sll
->sll_hatype
= ARPHRD_ETHER
;
527 sll
->sll_halen
= ETH_ALEN
;
529 if (ioctl(fd
, SIOCGIFINDEX
, &ifr
) < 0) {
530 perror("ioctl(SIOCGIFINDEX)");
534 sll
->sll_ifindex
= ifr
.ifr_ifindex
;
536 if (ioctl(fd
, SIOCGIFADDR
, &ifr
) < 0) {
537 memcpy(rif
->src_ip
, DUMMY_IP
, sizeof(rif
->src_ip
));
539 sin
= (struct sockaddr_in
*) &ifr
.ifr_addr
;
540 memcpy(rif
->src_ip
, &sin
->sin_addr
.s_addr
, sizeof(rif
->src_ip
));
543 if (bind(fd
, (struct sockaddr
*)sll
, sizeof(struct sockaddr_ll
)) < 0) {
544 perror("bind(ETH_P_ARP)");
548 rif
->fd
.cb
= recv_packet
;
549 uloop_fd_add(&rif
->fd
, ULOOP_READ
| ULOOP_EDGE_TRIGGER
);
551 if (!forward_bcast
&& !forward_dhcp
)
554 fd
= socket(AF_PACKET
, SOCK_RAW
, htons(ETH_P_IP
));
558 rif
->bcast_fd
.fd
= fd
;
559 rif
->bcast_fd
.cb
= recv_bcast_packet
;
561 memcpy(&rif
->bcast_sll
, &rif
->sll
, sizeof(rif
->bcast_sll
));
562 sll
= &rif
->bcast_sll
;
563 sll
->sll_protocol
= htons(ETH_P_IP
);
565 if (bind(fd
, (struct sockaddr
*)sll
, sizeof(struct sockaddr_ll
)) < 0) {
566 perror("bind(ETH_P_IP)");
570 #ifdef PACKET_RECV_TYPE
571 pkt_type
= (1 << PACKET_BROADCAST
);
572 setsockopt(fd
, SOL_PACKET
, PACKET_RECV_TYPE
, &pkt_type
, sizeof(pkt_type
));
575 uloop_fd_add(&rif
->bcast_fd
, ULOOP_READ
| ULOOP_EDGE_TRIGGER
);
576 relayd_add_interface_routes(rif
);
580 static void ping_static_routes(void)
582 struct relayd_pending_route
*rt
;
583 struct relayd_interface
*rif
;
585 list_for_each_entry(rt
, &pending_routes
, rt
.list
)
586 list_for_each_entry(rif
, &interfaces
, list
)
587 send_arp_request(rif
, rt
->gateway
);
590 static int init_interfaces(void)
592 struct relayd_interface
*rif
;
595 list_for_each_entry(rif
, &interfaces
, list
) {
596 ret
= init_interface(rif
);
604 static void cleanup_hosts(void)
606 struct relayd_interface
*rif
;
607 struct relayd_host
*host
, *tmp
;
609 list_for_each_entry(rif
, &interfaces
, list
) {
610 list_for_each_entry_safe(host
, tmp
, &rif
->hosts
, list
) {
616 static void free_interfaces(void)
618 struct relayd_interface
*rif
, *rtmp
;
620 list_for_each_entry_safe(rif
, rtmp
, &interfaces
, list
) {
621 relayd_del_interface_routes(rif
);
622 list_del(&rif
->list
);
627 static struct relayd_interface
*alloc_interface(const char *ifname
, bool managed
)
629 struct relayd_interface
*rif
;
631 if (strlen(ifname
) >= IFNAMSIZ
)
634 rif
= calloc(1, sizeof(*rif
));
638 INIT_LIST_HEAD(&rif
->hosts
);
639 strcpy(rif
->ifname
, ifname
);
640 list_add(&rif
->list
, &interfaces
);
641 rif
->managed
= managed
;
646 static void die(int signo
)
649 * When we hit SIGTERM, clean up interfaces directly, so that we
650 * won't leave our routing in an invalid state.
657 static int usage(const char *progname
)
659 fprintf(stderr
, "Usage: %s <options>\n"
662 " -d Enable debug messages\n"
663 " -i <ifname> Add an interface for relaying\n"
664 " -I <ifname> Same as -i, except with ARP cache and host route management\n"
665 " You need to specify at least two interfaces\n"
666 " -G <ip> Set a gateway IP for clients\n"
667 " -R <gateway>:<net>/<mask>\n"
668 " Add a static route for <net>/<mask> via <gateway>\n"
669 " -t <timeout> Host entry expiry timeout\n"
670 " -T <table> Set routing table number for automatically added routes\n"
671 " -B Enable broadcast forwarding\n"
672 " -D Enable DHCP forwarding\n"
673 " -L <ipaddr> Enable local access using <ipaddr> as source address\n"
679 int main(int argc
, char **argv
)
681 struct relayd_interface
*rif
= NULL
;
682 struct in_addr addr
, addr2
;
683 bool local_addr_valid
= false;
691 inet_sock
= socket(AF_INET
, SOCK_DGRAM
, 0);
693 perror("socket(AF_INET)");
699 local_route_table
= 0;
702 while ((ch
= getopt(argc
, argv
, "I:i:t:BDdT:G:R:L:")) != -1) {
709 rif
= alloc_interface(optarg
, managed
);
716 host_timeout
= atoi(optarg
);
717 if (host_timeout
<= 0)
718 return usage(argv
[0]);
730 route_table
= atoi(optarg
);
731 if (route_table
<= 0)
732 return usage(argv
[0]);
735 if (!inet_aton(optarg
, &addr
)) {
736 fprintf(stderr
, "Address '%s' not found\n", optarg
);
739 relayd_add_pending_route((uint8_t *) &addr
.s_addr
, (const uint8_t *) "\x00\x00\x00\x00", 0, 0);
742 if (!inet_aton(optarg
, &addr
)) {
743 fprintf(stderr
, "Address '%s' not found\n", optarg
);
746 memcpy(&local_addr
, &addr
.s_addr
, sizeof(local_addr
));
747 local_addr_valid
= true;
750 s
= strchr(optarg
, ':');
752 return usage(argv
[0]);
755 if (!inet_aton(optarg
, &addr
)) {
756 fprintf(stderr
, "Address '%s' not found\n", optarg
);
762 return usage(argv
[0]);
765 if (!inet_aton(s
, &addr2
)) {
766 fprintf(stderr
, "Address '%s' not found\n", s
);
771 if (mask
< 0 || mask
> 32)
772 return usage(argv
[0]);
774 relayd_add_pending_route((uint8_t *) &addr
.s_addr
, (uint8_t *) &addr2
.s_addr
, mask
, 0);
778 return usage(argv
[0]);
782 if (list_empty(&interfaces
))
783 return usage(argv
[0]);
786 fprintf(stderr
, "ERROR: Need at least 2 interfaces for relaying\n");
793 signal(SIGTERM
, die
);
795 signal(SIGUSR1
, die
);
796 signal(SIGUSR2
, die
);
798 if (local_addr_valid
)
799 local_route_table
= route_table
++;
801 if (relayd_rtnl_init() < 0)
804 if (init_interfaces() < 0)
807 ping_static_routes();