On 2012-02-29, Grant Edwards <grant.b.edwa...@gmail.com> wrote: > On 2012-02-16, Grant Edwards <grant.b.edwa...@gmail.com> wrote: > >> What's the simplest/best way to "disable" IPv6 at runtime? > > Here's my first try at disabling ipv6 at runtime. > > It seems to work well enough, but it's not as clean as I had hoped. > Could a patch using this approach be accepted? > > Of course I'd clean up the formatting, add a changelog entry and so > on. I'd also be happy to make this something that has to be enabled > via CDL -- though with the changes shown below, the stack behaves > exactly as before by default. I'm not keen on the "add a globally > visible flag" approach, but it seemed like the only simple solution. > > The three things I'm trying to disable are all called via init-table > entries, and AFAICT there's no practical way to remove/skip a table > entry at runtime. > > The declaration and definition of the globally visible > cyg_ipv6_runtime_disable flag probably belong somewhere else, but I > haven't figured out where.
OK, I've come up with something I like a little better. The only change it requires to the network stack is that ip6_init2() needs to be globally visible (ip6_init already is, so I don't see the harm in making ip6_init2 visible). If ip6_init2 is visible, then you can disable ipv6 support with this code: static void init_noop(void* dummy) { } static void disable_ipv6(void) { extern void cyg_net_add_domain(void *); extern void ip6_init2(void *); extern char inet6domain[]; extern struct init_tab_entry __NET_INIT_TAB__[], __NET_INIT_TAB_END__; struct init_tab_entry *init_entry; for (init_entry = __NET_INIT_TAB__; init_entry != &__NET_INIT_TAB_END__; init_entry++) if ((init_entry->fun == cyg_net_add_domain && init_entry->data == (void*)inet6domain) || (init_entry->fun == ip6_init2)) init_entry->fun = init_noop; } -- Grant Edwards grant.b.edwards Yow! I want a WESSON OIL at lease!! gmail.com -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss