From 2b23ab519c7592781d76f9cf7af69806a9f97199 Mon Sep 17 00:00:00 2001
From: Maxime Bizon <mbizon@freebox.fr>
Date: Fri, 17 Jan 2020 16:44:44 +0100
Subject: [PATCH 17/18] pppd: add option to skip IPv6 network config apply

---
 pppd/ipv6cp.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/pppd/ipv6cp.c b/pppd/ipv6cp.c
index 0443bd5..952d631 100644
--- a/pppd/ipv6cp.c
+++ b/pppd/ipv6cp.c
@@ -175,6 +175,7 @@ ipv6cp_options ipv6cp_gotoptions[NUM_PPP];	/* Options that peer ack'd */
 ipv6cp_options ipv6cp_allowoptions[NUM_PPP];	/* Options we allow peer to request */
 ipv6cp_options ipv6cp_hisoptions[NUM_PPP];	/* Options that we ack'd */
 int no_ifaceid_neg = 0;
+static bool noapplyv6cfg;			/* don't apply network config */
 
 /* local vars */
 static int default_route_set[NUM_PPP];		/* Have set up a default route */
@@ -272,6 +273,9 @@ static option_t ipv6cp_option_list[] = {
     { "ipv6cp-max-failure", o_int, &ipv6cp_fsm[0].maxnakloops,
       "Set max #conf-naks for IPv6CP", OPT_PRIO },
 
+    { "noapplyv6cfg", o_bool, &noapplyv6cfg,
+      "don't apply IPv6 network config", 1 },
+
    { NULL }
 };
 
@@ -1158,18 +1162,18 @@ ipv6_demand_conf(u)
 {
     ipv6cp_options *wo = &ipv6cp_wantoptions[u];
 
-    if (!sif6up(u))
+    if (!noapplyv6cfg && !sif6up(u))
 	return 0;
-    if (!sif6addr(u, wo->ourid, wo->hisid))
+    if (!noapplyv6cfg && !sif6addr(u, wo->ourid, wo->hisid))
 	return 0;
 #if !defined(__linux__) && !(defined(SVR4) && (defined(SNI) || defined(__USLC__)))
-    if (!sifup(u))
+    if (!noapplyv6cfg && !sifup(u))
 	return 0;
 #endif
     if (!sifnpmode(u, PPP_IPV6, NPMODE_QUEUE))
 	return 0;
     if (wo->default_route)
-	if (sif6defaultroute(u, wo->ourid, wo->hisid))
+	if (!noapplyv6cfg && sif6defaultroute(u, wo->ourid, wo->hisid))
 	    default_route_set[u] = 1;
 
     notice("ipv6_demand_conf");
@@ -1260,14 +1264,14 @@ ipv6cp_up(f)
 
     } else {
 	/* bring the interface up for IPv6 */
-	if (!sif6up(f->unit)) {
+	if (!noapplyv6cfg && !sif6up(f->unit)) {
 	    if (debug)
 		warn("sif6up failed (IPV6)");
 	    ipv6cp_close(f->unit, "Interface configuration failed");
 	    return;
 	}
 
-	if (!sif6addr(f->unit, go->ourid, ho->hisid)) {
+	if (!noapplyv6cfg && !sif6addr(f->unit, go->ourid, ho->hisid)) {
 	    if (debug)
 		warn("sif6addr failed");
 	    ipv6cp_close(f->unit, "Interface configuration failed");
@@ -1277,7 +1281,7 @@ ipv6cp_up(f)
 
 	/* assign a default route through the interface if required */
 	if (ipv6cp_wantoptions[f->unit].default_route)
-	    if (sif6defaultroute(f->unit, go->ourid, ho->hisid))
+	    if (!noapplyv6cfg && sif6defaultroute(f->unit, go->ourid, ho->hisid))
 		default_route_set[f->unit] = 1;
 
 	notice("local  LL address %s", llv6_ntoa(go->ourid));
@@ -1364,7 +1368,8 @@ ipv6cp_clear_addrs(unit, ourid, hisid)
     eui64_t ourid;
     eui64_t hisid;
 {
-    cif6addr(unit, ourid, hisid);
+     if (!noapplyv6cfg)
+        cif6addr(unit, ourid, hisid);
 }
 
 
-- 
2.17.1

