From: denis Date: Wed, 28 Feb 2024 16:08:34 +0000 (+0000) Subject: Enable IPv6 AF for ppp(4) X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=803b30d25a1a4f001fb6082a2a139e4c2b59ba36;p=openbsd Enable IPv6 AF for ppp(4) OK claudio@ --- diff --git a/share/man/man4/ppp.4 b/share/man/man4/ppp.4 index 37d31dcf67f..a74a8706b04 100644 --- a/share/man/man4/ppp.4 +++ b/share/man/man4/ppp.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ppp.4,v 1.16 2015/07/28 14:31:50 sthen Exp $ +.\" $OpenBSD: ppp.4,v 1.17 2024/02/28 16:08:34 denis Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" From: @(#)lo.4 8.1 (Berkeley) 6/5/93 .\" -.Dd $Mdocdate: July 28 2015 $ +.Dd $Mdocdate: February 28 2024 $ .Dt PPP 4 .Os .Sh NAME @@ -80,11 +80,3 @@ The .Nm device appeared in .Ox 1.2 . -.Sh BUGS -Currently, only the -.Xr ip 4 -protocol is supported by this device. -Note that the -.Xr pppoe 4 -device does support -.Xr ip6 4 . diff --git a/sys/net/if_ppp.c b/sys/net/if_ppp.c index fb32d9ea9ef..180229b0f4b 100644 --- a/sys/net/if_ppp.c +++ b/sys/net/if_ppp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ppp.c,v 1.117 2020/08/21 22:59:27 kn Exp $ */ +/* $OpenBSD: if_ppp.c,v 1.118 2024/02/28 16:08:34 denis Exp $ */ /* $NetBSD: if_ppp.c,v 1.39 1997/05/17 21:11:59 christos Exp $ */ /* @@ -494,6 +494,11 @@ pppioctl(struct ppp_softc *sc, u_long cmd, caddr_t data, int flag, case PPP_IP: npx = NP_IP; break; +#ifdef INET6 + case PPP_IPV6: + npx = NP_IPV6; + break; +#endif default: return EINVAL; } @@ -579,15 +584,19 @@ pppsioctl(struct ifnet *ifp, u_long cmd, caddr_t data) break; case SIOCSIFADDR: - if (ifa->ifa_addr->sa_family != AF_INET) - error = EAFNOSUPPORT; - break; - case SIOCSIFDSTADDR: - if (ifa->ifa_addr->sa_family != AF_INET) + switch (ifa->ifa_addr->sa_family) { + case AF_INET: + break; +#ifdef INET6 + case AF_INET6: + break; +#endif + default: error = EAFNOSUPPORT; + break; + } break; - case SIOCSIFMTU: sc->sc_if.if_mtu = ifr->ifr_mtu; break; @@ -674,6 +683,14 @@ pppoutput(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst, protocol = PPP_IP; mode = sc->sc_npmode[NP_IP]; break; +#ifdef INET6 + case AF_INET6: + address = PPP_ALLSTATIONS; + control = PPP_UI; + protocol = PPP_IPV6; + mode = sc->sc_npmode[NP_IPV6]; + break; +#endif case AF_UNSPEC: address = PPP_ADDRESS(dst->sa_data); control = PPP_CONTROL(dst->sa_data); @@ -804,6 +821,11 @@ ppp_requeue(struct ppp_softc *sc) case PPP_IP: mode = sc->sc_npmode[NP_IP]; break; +#ifdef INET6 + case PPP_IPV6: + mode = sc->sc_npmode[NP_IPV6]; + break; +#endif default: mode = NPMODE_PASS; } @@ -1391,7 +1413,25 @@ ppp_inproc(struct ppp_softc *sc, struct mbuf *m) ipv4_input(ifp, m); rv = 1; break; +#ifdef INET6 + case PPP_IPV6: + /* + * IPv6 packet - take off the ppp header and pass it up to IPv6. + */ + if ((ifp->if_flags & IFF_UP) == 0 || + sc->sc_npmode[NP_IPV6] != NPMODE_PASS) { + /* interface is down - drop the packet. */ + m_freem(m); + return; + } + m->m_pkthdr.len -= PPP_HDRLEN; + m->m_data += PPP_HDRLEN; + m->m_len -= PPP_HDRLEN; + ipv6_input(ifp, m); + rv = 1; + break; +#endif default: /* * Some other protocol - place on input queue for read(). diff --git a/sys/net/if_pppvar.h b/sys/net/if_pppvar.h index 1c4dd9977b5..256188c1682 100644 --- a/sys/net/if_pppvar.h +++ b/sys/net/if_pppvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pppvar.h,v 1.20 2020/05/20 06:44:30 mpi Exp $ */ +/* $OpenBSD: if_pppvar.h,v 1.21 2024/02/28 16:08:34 denis Exp $ */ /* $NetBSD: if_pppvar.h,v 1.5 1997/01/03 07:23:29 mikel Exp $ */ /* * if_pppvar.h - private structures and declarations for PPP. @@ -81,7 +81,8 @@ * indexing sc_npmode. */ #define NP_IP 0 /* Internet Protocol */ -#define NUM_NP 1 /* Number of NPs. */ +#define NP_IPV6 1 /* Internet Protocol v6 */ +#define NUM_NP 2 /* Number of NPs. */ struct ppp_pkt;