ppp: add reqprefix norelease ac_mac
authorAndy Chiang <[email protected]>
Tue, 9 Sep 2025 00:37:09 +0000 (07:37 +0700)
committerRobert Marko <[email protected]>
Sun, 9 Nov 2025 15:17:01 +0000 (16:17 +0100)
Use ppp and enable autoipv6, odhcp6c supports reqprefix and norelease to minimize the chance of IPv6 PD changes.[1]
PPPoE supports connecting to a specific AC/BRAS by using the pppoe-mac parameter.[2]

1. https://github.com/openwrt/openwrt/blob/master/package/network/ipv6/odhcp6c/files/dhcpv6.sh#L67
   https://github.com/openwrt/openwrt/blob/master/package/network/ipv6/odhcp6c/files/dhcpv6.sh#L77
2. https://github.com/ppp-project/ppp/blob/master/pppd/plugins/pppoe/plugin.c#L93

Signed-off-by: Andy Chiang <[email protected]>
Link: https://github.com/openwrt/openwrt/pull/19978
Signed-off-by: Robert Marko <[email protected]>
package/network/services/ppp/files/lib/netifd/ppp6-up
package/network/services/ppp/files/ppp.sh

index 51339ad3ec5d4fc3adeae1009c760af44bad51a9..913e50015f04ec39c7a3cfd7db5f84b630e8dd9e 100755 (executable)
@@ -26,9 +26,11 @@ if [ -n "$AUTOIPV6" ]; then
        [ -n "$ZONE" ] && json_add_string zone "$ZONE"
        [ -n "$EXTENDPREFIX" ] && json_add_string extendprefix 1
        [ -n "$IP6TABLE" ] && json_add_string ip6table $IP6TABLE
+       [ -n "$REQPREFIX" ] && json_add_string reqprefix $REQPREFIX
        [ -n "$PEERDNS" ] && json_add_boolean peerdns $PEERDNS
        [ "$NOSOURCEFILTER" = "1" ] && json_add_boolean sourcefilter "0"
        [ "$DELEGATE" = "0" ] && json_add_boolean delegate "0"
+       [ -n "$NORELEASE" ] && json_add_boolean norelease "1"
        json_close_object
        ubus call network add_dynamic "$(json_dump)"
 fi
index d7c0cdb1ae794a6a81840ff717d377125aa9120f..79fc61fcaaf0ebd52850f955929ec42fcdb2d704 100755 (executable)
@@ -79,18 +79,20 @@ ppp_generic_init_config() {
        proto_config_add_int mtu
        proto_config_add_string pppname
        proto_config_add_string unnumbered
+       proto_config_add_string reqprefix
        proto_config_add_boolean persist
        proto_config_add_int maxfail
        proto_config_add_int holdoff
        proto_config_add_boolean sourcefilter
        proto_config_add_boolean delegate
+       proto_config_add_boolean norelease
 }
 
 ppp_generic_setup() {
        local config="$1"; shift
        local localip
 
-       json_get_vars ip6table demand keepalive keepalive_adaptive username password pppd_options pppname unnumbered persist maxfail holdoff peerdns sourcefilter delegate
+       json_get_vars ip6table demand keepalive keepalive_adaptive username password pppd_options pppname unnumbered reqprefix persist maxfail holdoff peerdns sourcefilter delegate norelease
 
        [ ! -e /proc/sys/net/ipv6 ] && ipv6=0 || json_get_var ipv6 ipv6
 
@@ -101,6 +103,11 @@ ppp_generic_setup() {
                autoipv6=1
        fi
 
+       if [ "$autoipv6" != 1 ]; then
+               reqprefix=""
+               norelease=""
+       fi
+
        if [ "${demand:-0}" -gt 0 ]; then
                demand="precompiled-active-filter /etc/ppp/filter demand idle $demand"
        else
@@ -137,6 +144,7 @@ ppp_generic_setup() {
        [ -n "$disconnect" ] || json_get_var disconnect disconnect
        [ "$sourcefilter" = "0" ] || sourcefilter=""
        [ "$delegate" != "0" ] && delegate=""
+       [ "$norelease" = "1" ] || norelease=""
 
        proto_run_command "$config" /usr/sbin/pppd \
                nodetach ipparam "$config" \
@@ -145,6 +153,8 @@ ppp_generic_setup() {
                ${lcp_failure:+lcp-echo-interval $lcp_interval lcp-echo-failure $lcp_failure $lcp_adaptive} \
                ${ipv6:++ipv6} \
                ${autoipv6:+set AUTOIPV6=1} \
+               ${reqprefix:+set REQPREFIX=$reqprefix} \
+               ${norelease:+set NORELEASE=1} \
                ${ip6table:+set IP6TABLE=$ip6table} \
                ${peerdns:+set PEERDNS=$peerdns} \
                ${sourcefilter:+set NOSOURCEFILTER=1} \
@@ -215,6 +225,7 @@ proto_pppoe_init_config() {
        ppp_generic_init_config
        proto_config_add_string "ac"
        proto_config_add_string "service"
+       proto_config_add_string "ac_mac"
        proto_config_add_string "host_uniq"
        proto_config_add_int "padi_attempts"
        proto_config_add_int "padi_timeout"
@@ -233,6 +244,7 @@ proto_pppoe_setup() {
 
        json_get_var ac ac
        json_get_var service service
+       json_get_var ac_mac ac_mac
        json_get_var host_uniq host_uniq
        json_get_var padi_attempts padi_attempts
        json_get_var padi_timeout padi_timeout
@@ -241,6 +253,7 @@ proto_pppoe_setup() {
                plugin pppoe.so \
                ${ac:+rp_pppoe_ac "$ac"} \
                ${service:+rp_pppoe_service "$service"} \
+               ${ac_mac:+pppoe-mac "$ac_mac"} \
                ${host_uniq:+host-uniq "$host_uniq"} \
                ${padi_attempts:+pppoe-padi-attempts $padi_attempts} \
                ${padi_timeout:+pppoe-padi-timeout $padi_timeout} \