diff options
-rw-r--r-- | include/usage.h | 9 | ||||
-rw-r--r-- | networking/Config.in | 4 | ||||
-rw-r--r-- | networking/libiproute/iproute.c | 116 | ||||
-rw-r--r-- | networking/udhcp/dhcpc.c | 4 |
4 files changed, 128 insertions, 5 deletions
diff --git a/include/usage.h b/include/usage.h index 55693c61e..9616906d2 100644 --- a/include/usage.h +++ b/include/usage.h | |||
@@ -2084,6 +2084,14 @@ | |||
2084 | "Telnet is used to establish interactive communication with another\n"\ | 2084 | "Telnet is used to establish interactive communication with another\n"\ |
2085 | "computer over a network using the TELNET protocol." | 2085 | "computer over a network using the TELNET protocol." |
2086 | 2086 | ||
2087 | #ifdef CONFIG_FEATURE_TELNETD_INETD | ||
2088 | #define telnetd_trivial_usage \ | ||
2089 | "(inetd mode) [OPTION]" | ||
2090 | #define telnetd_full_usage \ | ||
2091 | "Telnetd uses incoming TELNET connections via inetd.\n"\ | ||
2092 | "Options:\n" \ | ||
2093 | "\t-l LOGIN\texec LOGIN on connect (default /bin/sh)" | ||
2094 | #else | ||
2087 | #define telnetd_trivial_usage \ | 2095 | #define telnetd_trivial_usage \ |
2088 | "[OPTION]" | 2096 | "[OPTION]" |
2089 | #define telnetd_full_usage \ | 2097 | #define telnetd_full_usage \ |
@@ -2091,6 +2099,7 @@ | |||
2091 | "Options:\n" \ | 2099 | "Options:\n" \ |
2092 | "\t-p PORT\tlisten for connections on PORT (default 23)\n"\ | 2100 | "\t-p PORT\tlisten for connections on PORT (default 23)\n"\ |
2093 | "\t-l LOGIN\texec LOGIN on connect (default /bin/sh)" | 2101 | "\t-l LOGIN\texec LOGIN on connect (default /bin/sh)" |
2102 | #endif | ||
2094 | 2103 | ||
2095 | #define test_trivial_usage \ | 2104 | #define test_trivial_usage \ |
2096 | "EXPRESSION\n or [ EXPRESSION ]" | 2105 | "EXPRESSION\n or [ EXPRESSION ]" |
diff --git a/networking/Config.in b/networking/Config.in index 12deb55b8..cd38a7074 100644 --- a/networking/Config.in +++ b/networking/Config.in | |||
@@ -257,7 +257,7 @@ endif | |||
257 | if ! (CONFIG_IP && CONFIG_IPADDR) | 257 | if ! (CONFIG_IP && CONFIG_IPADDR) |
258 | config CONFIG_FEATURE_IP_ADDRESS | 258 | config CONFIG_FEATURE_IP_ADDRESS |
259 | bool " address" | 259 | bool " address" |
260 | default n | 260 | default y |
261 | depends on CONFIG_IP | 261 | depends on CONFIG_IP |
262 | help | 262 | help |
263 | Please submit a patch to add help text for this item. | 263 | Please submit a patch to add help text for this item. |
@@ -299,7 +299,7 @@ endif | |||
299 | if !(CONFIG_IP && CONFIG_IPTUNNEL) | 299 | if !(CONFIG_IP && CONFIG_IPTUNNEL) |
300 | config CONFIG_FEATURE_IP_TUNNEL | 300 | config CONFIG_FEATURE_IP_TUNNEL |
301 | bool " tunnel" | 301 | bool " tunnel" |
302 | default y | 302 | default n |
303 | depends on CONFIG_IP | 303 | depends on CONFIG_IP |
304 | help | 304 | help |
305 | Please submit a patch to add help text for this item. | 305 | Please submit a patch to add help text for this item. |
diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c index 114fb6c90..be4435f66 100644 --- a/networking/libiproute/iproute.c +++ b/networking/libiproute/iproute.c | |||
@@ -19,6 +19,8 @@ | |||
19 | 19 | ||
20 | #include <stdlib.h> | 20 | #include <stdlib.h> |
21 | #include <string.h> | 21 | #include <string.h> |
22 | #include <fcntl.h> | ||
23 | #include <unistd.h> | ||
22 | 24 | ||
23 | #include "rt_names.h" | 25 | #include "rt_names.h" |
24 | #include "utils.h" | 26 | #include "utils.h" |
@@ -33,6 +35,8 @@ | |||
33 | static struct | 35 | static struct |
34 | { | 36 | { |
35 | int tb; | 37 | int tb; |
38 | int flushed; | ||
39 | char *flushb; | ||
36 | int flushp; | 40 | int flushp; |
37 | int flushe; | 41 | int flushe; |
38 | struct rtnl_handle *rth; | 42 | struct rtnl_handle *rth; |
@@ -51,6 +55,16 @@ static struct | |||
51 | inet_prefix msrc; | 55 | inet_prefix msrc; |
52 | } filter; | 56 | } filter; |
53 | 57 | ||
58 | static int flush_update(void) | ||
59 | { | ||
60 | if (rtnl_send(filter.rth, filter.flushb, filter.flushp) < 0) { | ||
61 | perror("Failed to send flush request\n"); | ||
62 | return -1; | ||
63 | } | ||
64 | filter.flushp = 0; | ||
65 | return 0; | ||
66 | } | ||
67 | |||
54 | static int print_route(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) | 68 | static int print_route(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) |
55 | { | 69 | { |
56 | FILE *fp = (FILE*)arg; | 70 | FILE *fp = (FILE*)arg; |
@@ -67,6 +81,8 @@ static int print_route(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) | |||
67 | n->nlmsg_len, n->nlmsg_type, n->nlmsg_flags); | 81 | n->nlmsg_len, n->nlmsg_type, n->nlmsg_flags); |
68 | return 0; | 82 | return 0; |
69 | } | 83 | } |
84 | if (filter.flushb && n->nlmsg_type != RTM_NEWROUTE) | ||
85 | return 0; | ||
70 | len -= NLMSG_LENGTH(sizeof(*r)); | 86 | len -= NLMSG_LENGTH(sizeof(*r)); |
71 | if (len < 0) { | 87 | if (len < 0) { |
72 | error_msg("wrong nlmsg len %d", len); | 88 | error_msg("wrong nlmsg len %d", len); |
@@ -128,6 +144,30 @@ static int print_route(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) | |||
128 | memset(tb, 0, sizeof(tb)); | 144 | memset(tb, 0, sizeof(tb)); |
129 | parse_rtattr(tb, RTA_MAX, RTM_RTA(r), len); | 145 | parse_rtattr(tb, RTA_MAX, RTM_RTA(r), len); |
130 | 146 | ||
147 | if (filter.flushb && | ||
148 | r->rtm_family == AF_INET6 && | ||
149 | r->rtm_dst_len == 0 && | ||
150 | r->rtm_type == RTN_UNREACHABLE && | ||
151 | tb[RTA_PRIORITY] && | ||
152 | *(int*)RTA_DATA(tb[RTA_PRIORITY]) == -1) | ||
153 | return 0; | ||
154 | |||
155 | if (filter.flushb) { | ||
156 | struct nlmsghdr *fn; | ||
157 | if (NLMSG_ALIGN(filter.flushp) + n->nlmsg_len > filter.flushe) { | ||
158 | if (flush_update()) | ||
159 | return -1; | ||
160 | } | ||
161 | fn = (struct nlmsghdr*)(filter.flushb + NLMSG_ALIGN(filter.flushp)); | ||
162 | memcpy(fn, n, n->nlmsg_len); | ||
163 | fn->nlmsg_type = RTM_DELROUTE; | ||
164 | fn->nlmsg_flags = NLM_F_REQUEST; | ||
165 | fn->nlmsg_seq = ++filter.rth->seq; | ||
166 | filter.flushp = (((char*)fn) + n->nlmsg_len) - filter.flushb; | ||
167 | filter.flushed++; | ||
168 | return 0; | ||
169 | } | ||
170 | |||
131 | if (n->nlmsg_type == RTM_DELROUTE) { | 171 | if (n->nlmsg_type == RTM_DELROUTE) { |
132 | fprintf(fp, "Deleted "); | 172 | fprintf(fp, "Deleted "); |
133 | } | 173 | } |
@@ -393,6 +433,29 @@ static int rtnl_rtcache_request(struct rtnl_handle *rth, int family) | |||
393 | return sendto(rth->fd, (void*)&req, sizeof(req), 0, (struct sockaddr*)&nladdr, sizeof(nladdr)); | 433 | return sendto(rth->fd, (void*)&req, sizeof(req), 0, (struct sockaddr*)&nladdr, sizeof(nladdr)); |
394 | } | 434 | } |
395 | 435 | ||
436 | static int iproute_flush_cache(void) | ||
437 | { | ||
438 | #define ROUTE_FLUSH_PATH "/proc/sys/net/ipv4/route/flush" | ||
439 | |||
440 | int len; | ||
441 | int flush_fd = open (ROUTE_FLUSH_PATH, O_WRONLY); | ||
442 | char *buffer = "-1"; | ||
443 | |||
444 | if (flush_fd < 0) { | ||
445 | fprintf (stderr, "Cannot open \"%s\"\n", ROUTE_FLUSH_PATH); | ||
446 | return -1; | ||
447 | } | ||
448 | |||
449 | len = strlen (buffer); | ||
450 | |||
451 | if ((write (flush_fd, (void *)buffer, len)) < len) { | ||
452 | fprintf (stderr, "Cannot flush routing cache\n"); | ||
453 | return -1; | ||
454 | } | ||
455 | close(flush_fd); | ||
456 | return 0; | ||
457 | } | ||
458 | |||
396 | static void iproute_reset_filter(void) | 459 | static void iproute_reset_filter(void) |
397 | { | 460 | { |
398 | memset(&filter, 0, sizeof(filter)); | 461 | memset(&filter, 0, sizeof(filter)); |
@@ -400,7 +463,7 @@ static void iproute_reset_filter(void) | |||
400 | filter.msrc.bitlen = -1; | 463 | filter.msrc.bitlen = -1; |
401 | } | 464 | } |
402 | 465 | ||
403 | static int iproute_list(int argc, char **argv) | 466 | static int iproute_list_or_flush(int argc, char **argv, int flush) |
404 | { | 467 | { |
405 | int do_ipv6 = preferred_family; | 468 | int do_ipv6 = preferred_family; |
406 | struct rtnl_handle rth; | 469 | struct rtnl_handle rth; |
@@ -410,6 +473,11 @@ static int iproute_list(int argc, char **argv) | |||
410 | iproute_reset_filter(); | 473 | iproute_reset_filter(); |
411 | filter.tb = RT_TABLE_MAIN; | 474 | filter.tb = RT_TABLE_MAIN; |
412 | 475 | ||
476 | if (flush && argc <= 0) { | ||
477 | fprintf(stderr, "\"ip route flush\" requires arguments.\n"); | ||
478 | return -1; | ||
479 | } | ||
480 | |||
413 | while (argc > 0) { | 481 | while (argc > 0) { |
414 | if (matches(*argv, "protocol") == 0) { | 482 | if (matches(*argv, "protocol") == 0) { |
415 | int prot = 0; | 483 | int prot = 0; |
@@ -496,6 +564,46 @@ static int iproute_list(int argc, char **argv) | |||
496 | } | 564 | } |
497 | } | 565 | } |
498 | 566 | ||
567 | if (flush) { | ||
568 | int round = 0; | ||
569 | char flushb[4096-512]; | ||
570 | |||
571 | if (filter.tb == -1) { | ||
572 | if (do_ipv6 != AF_INET6) | ||
573 | iproute_flush_cache(); | ||
574 | if (do_ipv6 == AF_INET) | ||
575 | return 0; | ||
576 | } | ||
577 | |||
578 | filter.flushb = flushb; | ||
579 | filter.flushp = 0; | ||
580 | filter.flushe = sizeof(flushb); | ||
581 | filter.rth = &rth; | ||
582 | |||
583 | for (;;) { | ||
584 | if (rtnl_wilddump_request(&rth, do_ipv6, RTM_GETROUTE) < 0) { | ||
585 | perror("Cannot send dump request"); | ||
586 | return -1; | ||
587 | } | ||
588 | filter.flushed = 0; | ||
589 | if (rtnl_dump_filter(&rth, print_route, stdout, NULL, NULL) < 0) { | ||
590 | error_msg("Flush terminated\n"); | ||
591 | return -1; | ||
592 | } | ||
593 | if (filter.flushed == 0) { | ||
594 | if (round == 0) { | ||
595 | if (filter.tb != -1 || do_ipv6 == AF_INET6) | ||
596 | fprintf(stderr, "Nothing to flush.\n"); | ||
597 | } | ||
598 | fflush(stdout); | ||
599 | return 0; | ||
600 | } | ||
601 | round++; | ||
602 | if (flush_update() < 0) | ||
603 | exit(1); | ||
604 | } | ||
605 | } | ||
606 | |||
499 | if (filter.tb != -1) { | 607 | if (filter.tb != -1) { |
500 | if (rtnl_wilddump_request(&rth, do_ipv6, RTM_GETROUTE) < 0) { | 608 | if (rtnl_wilddump_request(&rth, do_ipv6, RTM_GETROUTE) < 0) { |
501 | perror_msg_and_die("Cannot send dump request"); | 609 | perror_msg_and_die("Cannot send dump request"); |
@@ -686,7 +794,7 @@ static int iproute_get(int argc, char **argv) | |||
686 | int do_iproute(int argc, char **argv) | 794 | int do_iproute(int argc, char **argv) |
687 | { | 795 | { |
688 | const char *ip_route_commands[] = { "add", "append", "change", "chg", | 796 | const char *ip_route_commands[] = { "add", "append", "change", "chg", |
689 | "delete", "get", "list", "show", "prepend", "replace", "test", 0 }; | 797 | "delete", "get", "list", "show", "prepend", "replace", "test", "flush", 0 }; |
690 | unsigned short command_num = 6; | 798 | unsigned short command_num = 6; |
691 | unsigned int flags = 0; | 799 | unsigned int flags = 0; |
692 | int cmd = RTM_NEWROUTE; | 800 | int cmd = RTM_NEWROUTE; |
@@ -712,13 +820,15 @@ int do_iproute(int argc, char **argv) | |||
712 | return iproute_get(argc-1, argv+1); | 820 | return iproute_get(argc-1, argv+1); |
713 | case 6: /* list */ | 821 | case 6: /* list */ |
714 | case 7: /* show */ | 822 | case 7: /* show */ |
715 | return iproute_list(argc-1, argv+1); | 823 | return iproute_list_or_flush(argc-1, argv+1, 0); |
716 | case 8: /* prepend */ | 824 | case 8: /* prepend */ |
717 | flags = NLM_F_CREATE; | 825 | flags = NLM_F_CREATE; |
718 | case 9: /* replace */ | 826 | case 9: /* replace */ |
719 | flags = NLM_F_CREATE|NLM_F_REPLACE; | 827 | flags = NLM_F_CREATE|NLM_F_REPLACE; |
720 | case 10: /* test */ | 828 | case 10: /* test */ |
721 | flags = NLM_F_EXCL; | 829 | flags = NLM_F_EXCL; |
830 | case 11: /* flush */ | ||
831 | return iproute_list_or_flush(argc-1, argv+1, 1); | ||
722 | default: | 832 | default: |
723 | error_msg_and_die("Unknown command %s", *argv); | 833 | error_msg_and_die("Unknown command %s", *argv); |
724 | } | 834 | } |
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index 6abca6d1c..fdcd17f79 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
@@ -59,7 +59,11 @@ static int signal_pipe[2]; | |||
59 | #define LISTEN_RAW 2 | 59 | #define LISTEN_RAW 2 |
60 | static int listen_mode; | 60 | static int listen_mode; |
61 | 61 | ||
62 | #ifdef CONFIG_INSTALL_NO_USR | ||
63 | #define DEFAULT_SCRIPT "/share/udhcpc/default.script" | ||
64 | #else | ||
62 | #define DEFAULT_SCRIPT "/usr/share/udhcpc/default.script" | 65 | #define DEFAULT_SCRIPT "/usr/share/udhcpc/default.script" |
66 | #endif | ||
63 | 67 | ||
64 | struct client_config_t client_config = { | 68 | struct client_config_t client_config = { |
65 | /* Default options. */ | 69 | /* Default options. */ |