aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrepo sync <isheriff@google.com>2011-08-10 15:44:47 -0700
committerrepo sync <isheriff@google.com>2011-08-14 17:20:21 -0700
commit0d3a47d979ac35a49b2a2da9e80e16bd37aab877 (patch)
tree24b8afc13c1915a0636cce5c3308c362738d266c
parent98bf139a07f34b42c5b5f935f48c981a103d965d (diff)
downloadexternal_dhcpcd-0d3a47d979ac35a49b2a2da9e80e16bd37aab877.zip
external_dhcpcd-0d3a47d979ac35a49b2a2da9e80e16bd37aab877.tar.gz
external_dhcpcd-0d3a47d979ac35a49b2a2da9e80e16bd37aab877.tar.bz2
Provide an option to disable route setup with dhcp
Framework manages route setup for p2p. Bug: 5002384 Change-Id: I7489ebed1c268744a3bf8ea13bf5c55d200fe3e7
-rw-r--r--configure.c23
-rw-r--r--dhcpcd.c7
-rw-r--r--dhcpcd.h1
-rw-r--r--if-options.c1
-rw-r--r--if-options.h2
5 files changed, 23 insertions, 11 deletions
diff --git a/configure.c b/configure.c
index fb28669..e64dd4e 100644
--- a/configure.c
+++ b/configure.c
@@ -640,6 +640,8 @@ build_routes(void)
struct rt *nrs = NULL, *dnr, *or, *rt, *rtn, *rtl, *lrt = NULL;
const struct interface *ifp;
+ if (avoid_routes) return;
+
for (ifp = ifaces; ifp; ifp = ifp->next) {
if (ifp->state->new == NULL)
continue;
@@ -758,17 +760,20 @@ configure(struct interface *iface)
iface->addr.s_addr = lease->addr.s_addr;
iface->net.s_addr = lease->net.s_addr;
- /* We need to delete the subnet route to have our metric or
- * prefer the interface. */
- rt = get_subnet_route(dhcp);
- if (rt != NULL) {
- rt->iface = iface;
- if (!find_route(routes, rt, NULL, NULL))
- del_route(iface, &rt->dest, &rt->net, &rt->gate, 0);
- free(rt);
+ if (!avoid_routes) {
+ /* We need to delete the subnet route to have our metric or
+ * prefer the interface. */
+ rt = get_subnet_route(dhcp);
+ if (rt != NULL) {
+ rt->iface = iface;
+ if (!find_route(routes, rt, NULL, NULL))
+ del_route(iface, &rt->dest, &rt->net, &rt->gate, 0);
+ free(rt);
+ }
+
+ build_routes();
}
- build_routes();
if (!iface->state->lease.frominfo &&
!(ifo->options & (DHCPCD_INFORM | DHCPCD_STATIC)))
if (write_lease(iface, dhcp) == -1)
diff --git a/dhcpcd.c b/dhcpcd.c
index df3e790..15c087b 100644
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -92,6 +92,8 @@ int ifac = 0;
char **ifav = NULL;
int ifdc = 0;
char **ifdv = NULL;
+/* If set, avoid routes after a DHCP success */
+int avoid_routes = 0;
static char **margv;
static int margc;
@@ -151,7 +153,7 @@ read_pid(void)
static void
usage(void)
{
- printf("usage: "PACKAGE" [-dgknpqwxyADEGHJKLOTV] [-c script] [-f file]"
+ printf("usage: "PACKAGE" [-adgknpqwxyADEGHJKLOTV] [-c script] [-f file]"
" [-e var=val]\n"
" [-h hostname] [-i classID ] [-l leasetime]"
" [-m metric] [-o option]\n"
@@ -1791,6 +1793,9 @@ main(int argc, char **argv)
case 'U':
i = 2;
break;
+ case 'a':
+ avoid_routes = 1;
+ break;
case 'V':
print_options();
exit(EXIT_SUCCESS);
diff --git a/dhcpcd.h b/dhcpcd.h
index ec32474..85cef7c 100644
--- a/dhcpcd.h
+++ b/dhcpcd.h
@@ -119,6 +119,7 @@ extern char **ifav;
extern int ifdc;
extern char **ifdv;
extern struct interface *ifaces;
+extern int avoid_routes;
struct interface *find_interface(const char *);
int handle_args(struct fd_list *, int, char **);
diff --git a/if-options.c b/if-options.c
index 88b43d7..4dd907b 100644
--- a/if-options.c
+++ b/if-options.c
@@ -333,6 +333,7 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
struct rt *rt;
switch(opt) {
+ case 'a': /* FALLTHROUGH */
case 'f': /* FALLTHROUGH */
case 'g': /* FALLTHROUGH */
case 'n': /* FALLTHROUGH */
diff --git a/if-options.h b/if-options.h
index 241cb4d..98950ef 100644
--- a/if-options.h
+++ b/if-options.h
@@ -37,7 +37,7 @@
/* Don't set any optional arguments here so we retain POSIX
* compatibility with getopt */
-#define IF_OPTS "bc:de:f:gh:i:kl:m:no:pqr:s:t:u:v:wxy:z:ABC:DEF:GHI:JKLO:Q:S:TUVW:X:Z:"
+#define IF_OPTS "abc:de:f:gh:i:kl:m:no:pqr:s:t:u:v:wxy:z:ABC:DEF:GHI:JKLO:Q:S:TUVW:X:Z:"
#define DEFAULT_TIMEOUT 30
#define DEFAULT_REBOOT 10