From dcd142d5d3afac395fcc167f01e9c2b20e9da913 Mon Sep 17 00:00:00 2001 From: joerg Date: Sun, 30 Dec 2001 20:42:29 +0000 Subject: Implement an option to administratively disable the negotiation of IPv6 on an sppp interface. In an IPv6-enabled kernel, every IPv6 interface automatically gets an IPv6 address assigned (and IPv6 multicast packets sent at initialization time). For sppp links where we know our remote peer wouldn't support IPv6 at all, there's no point in attempting to negotiate IPV6CP (or to even dial out for an IPv6 packet at all for dial-on-demand interfaces). I wish there were a more generic way to administratively disable IPv6 on an interface instead. ume told me there isn't. While i was at it, converted both, enable_vj and enable_ipv6 into flag bits in struct sppp (enable_vj used to be an int of its own). MFC after: 1 month --- sys/net/if_spppsubr.c | 57 ++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 7 deletions(-) (limited to 'sys/net/if_spppsubr.c') diff --git a/sys/net/if_spppsubr.c b/sys/net/if_spppsubr.c index d54cfb8..600179e 100644 --- a/sys/net/if_spppsubr.c +++ b/sys/net/if_spppsubr.c @@ -782,12 +782,28 @@ sppp_output(struct ifnet *ifp, struct mbuf *m, if ((ifp->if_flags & IFF_UP) == 0 || (ifp->if_flags & (IFF_RUNNING | IFF_AUTO)) == 0) { +#ifdef INET6 + drop: +#endif m_freem (m); splx (s); return (ENETDOWN); } if ((ifp->if_flags & (IFF_RUNNING | IFF_AUTO)) == IFF_AUTO) { +#ifdef INET6 + /* + * XXX + * + * Hack to prevent the initialization-time generated + * IPv6 multicast packet to erroneously cause a + * dialout event in case IPv6 has been + * administratively disabled on that interface. + */ + if (dst->sa_family == AF_INET6 && + !(sp->confflags & CONF_ENABLE_IPV6)) + goto drop; +#endif /* * Interface is not yet running, but auto-dial. Need * to start LCP for it. @@ -1011,7 +1027,13 @@ sppp_attach(struct ifnet *ifp) if(!mtx_initialized(&sp->pp_fastq.ifq_mtx)) mtx_init(&sp->pp_fastq.ifq_mtx, "sppp_fastq", MTX_DEF); sp->pp_last_recv = sp->pp_last_sent = time_second; - sp->enable_vj = 1; + sp->confflags = 0; +#ifdef INET + sp->confflags |= CONF_ENABLE_VJ; +#endif +#ifdef INET6 + sp->confflags |= CONF_ENABLE_IPV6; +#endif sp->pp_comp = malloc(sizeof(struct slcompress), M_TEMP, M_WAIT); sl_compress_init(sp->pp_comp, -1); sppp_lcp_init(sp); @@ -2616,7 +2638,16 @@ sppp_lcp_tlu(struct sppp *sp) if (sp->pp_phase == PHASE_NETWORK) { /* Notify all NCPs. */ for (i = 0; i < IDX_COUNT; i++) - if ((cps[i])->flags & CP_NCP) + if (((cps[i])->flags & CP_NCP) && + /* + * XXX + * Hack to administratively disable IPv6 if + * not desired. Perhaps we should have another + * flag for this, but right now, we can make + * all struct cp's read/only. + */ + (cps[i] != &ipv6cp || + (sp->confflags & CONF_ENABLE_IPV6))) (cps[i])->Open(sp); } @@ -2837,7 +2868,7 @@ sppp_ipcp_open(struct sppp *sp) sp->ipcp.opts |= (1 << IPCP_OPT_ADDRESS); } else sp->ipcp.flags |= IPCP_MYADDR_SEEN; - if (sp->enable_vj) { + if (sp->confflags & CONF_ENABLE_VJ) { sp->ipcp.opts |= (1 << IPCP_OPT_COMPRESSION); sp->ipcp.max_state = MAX_STATES - 1; sp->ipcp.compress_cid = 1; @@ -2898,7 +2929,7 @@ sppp_ipcp_RCR(struct sppp *sp, struct lcp_header *h, int len) log(-1, " %s ", sppp_ipcp_opt_name(*p)); switch (*p) { case IPCP_OPT_COMPRESSION: - if (!sp->enable_vj) { + if (!(sp->confflags & CONF_ENABLE_VJ)) { /* VJ compression administratively disabled */ if (debug) log(-1, "[locally disabled] "); @@ -5011,7 +5042,8 @@ sppp_params(struct sppp *sp, u_long cmd, void *data) * CHAP secrets back to userland anyway. */ spr->defs.pp_phase = sp->pp_phase; - spr->defs.enable_vj = sp->enable_vj; + spr->defs.enable_vj = (sp->confflags & CONF_ENABLE_VJ) != 0; + spr->defs.enable_ipv6 = (sp->confflags & CONF_ENABLE_IPV6) != 0; spr->defs.lcp = sp->lcp; spr->defs.ipcp = sp->ipcp; spr->defs.ipv6cp = sp->ipv6cp; @@ -5101,9 +5133,20 @@ sppp_params(struct sppp *sp, u_long cmd, void *data) /* set LCP restart timer timeout */ if (spr->defs.lcp.timeout != 0) sp->lcp.timeout = spr->defs.lcp.timeout * hz / 1000; - /* set VJ enable flag */ - sp->enable_vj = spr->defs.enable_vj; + /* set VJ enable and IPv6 disable flags */ +#ifdef INET + if (spr->defs.enable_vj) + sp->confflags |= CONF_ENABLE_VJ; + else + sp->confflags &= ~CONF_ENABLE_VJ; +#endif +#ifdef INET6 + if (spr->defs.enable_ipv6) + sp->confflags |= CONF_ENABLE_IPV6; + else + sp->confflags &= ~CONF_ENABLE_IPV6; break; +#endif default: rv = EINVAL; -- cgit v1.1