From: Martin Schiller Date: Mon, 8 Jan 2018 12:12:20 +0000 (+0100) Subject: linux-atm: add br2684ctl option to specify the netdev name X-Git-Tag: v18.06.0-rc1~1355 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=1b1388f6404e6c3b0734de0a3dfbea63d69f677e;p=oweals%2Fopenwrt.git linux-atm: add br2684ctl option to specify the netdev name Add the uci option nameprefix to specifc a target netdev name. Patch the br2684ctl code to accept and set a netdev name via commandline parameters. It allows to use the same netdev name for ATM and PTM lines on lantiq xdsl hardware. Signed-off-by: Martin Schiller Signed-off-by: Mathis Kresin --- diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate index bbed567def..fa148685cc 100755 --- a/package/base-files/files/bin/config_generate +++ b/package/base-files/files/bin/config_generate @@ -24,8 +24,8 @@ generate_static_network() { json_select dsl if json_is_a atmbridge object; then json_select atmbridge - local vpi vci encaps payload - json_get_vars vpi vci encaps payload + local vpi vci encaps payload nameprefix + json_get_vars vpi vci encaps payload nameprefix uci -q batch <<-EOF delete network.atm set network.atm='atm-bridge' @@ -33,6 +33,7 @@ generate_static_network() { set network.atm.vci='$vci' set network.atm.encaps='$encaps' set network.atm.payload='$payload' + set network.atm.nameprefix='$nameprefix' EOF json_select .. fi diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh index 82ac1d2a4d..3126fe6510 100755 --- a/package/base-files/files/lib/functions/uci-defaults.sh +++ b/package/base-files/files/lib/functions/uci-defaults.sh @@ -319,6 +319,7 @@ ucidef_add_atm_bridge() { local vci="$2" local encaps="$3" local payload="$4" + local nameprefix="$5" json_select_object dsl json_select_object atmbridge @@ -326,6 +327,7 @@ ucidef_add_atm_bridge() { json_add_int vci "$vci" json_add_string encaps "$encaps" json_add_string payload "$payload" + json_add_string nameprefix "$nameprefix" json_select .. json_select .. } diff --git a/package/network/utils/linux-atm/files/br2684ctl b/package/network/utils/linux-atm/files/br2684ctl index 0fa86bdefd..6513dd38ad 100755 --- a/package/network/utils/linux-atm/files/br2684ctl +++ b/package/network/utils/linux-atm/files/br2684ctl @@ -13,6 +13,9 @@ start_daemon() { config_get atmdev "$cfg" atmdev 0 + local nameprefix + config_get nameprefix "$cfg" nameprefix "nas" + local unit config_get unit "$cfg" unit 0 @@ -58,8 +61,8 @@ start_daemon() { procd_open_instance procd_set_param command \ - /usr/sbin/br2684ctl_wrap "nas$unit" \ - -c "$unit" -e "$encaps" -p "$payload" \ + /usr/sbin/br2684ctl_wrap "${nameprefix}${unit}" \ + -n "$nameprefix" -c "$unit" -e "$encaps" -p "$payload" \ -a "$circuit" ${qos:+-q "$qos"} ${sendsize:+-s "$sendsize"} \ -S /lib/netifd/br2684-up procd_close_instance diff --git a/package/network/utils/linux-atm/patches/501-br2684ctl_itfname.patch b/package/network/utils/linux-atm/patches/501-br2684ctl_itfname.patch new file mode 100644 index 0000000000..839b395fe4 --- /dev/null +++ b/package/network/utils/linux-atm/patches/501-br2684ctl_itfname.patch @@ -0,0 +1,74 @@ +--- a/src/br2684/br2684ctl.c ++++ b/src/br2684/br2684ctl.c +@@ -45,6 +45,7 @@ struct br2684_params { + + int lastsock, lastitf; + static char *up_script; ++const char *itfname = "nas"; + + + void fatal(const char *str, int err) +@@ -73,7 +74,7 @@ int create_pidfile(int num) + + if (num < 0) return -1; + +- snprintf(name, 32, "/var/run/br2684ctl-nas%d.pid", num); ++ snprintf(name, 32, "/var/run/br2684ctl-%s%d.pid", itfname, num); + pidfile = fopen(name, "w"); + if (pidfile == NULL) return -1; + fprintf(pidfile, "%d", getpid()); +@@ -102,7 +103,7 @@ int create_br(int itfnum, int payload) + ni.media |= BR2684_FLAG_ROUTED; + #endif + ni.mtu = 1500; +- sprintf(ni.ifname, "nas%d", itfnum); ++ sprintf(ni.ifname, "%s%d", itfname, itfnum); + err=ioctl (lastsock, ATM_NEWBACKENDIF, &ni); + + if (err == 0) +@@ -167,7 +168,7 @@ int assign_vcc(char *astr, int encap, in + + be.backend_num = ATM_BACKEND_BR2684; + be.ifspec.method = BR2684_FIND_BYIFNAME; +- sprintf(be.ifspec.spec.ifname, "nas%d", lastitf); ++ sprintf(be.ifspec.spec.ifname, "%s%d", itfname, lastitf); + be.fcs_in = BR2684_FCSIN_NO; + be.fcs_out = BR2684_FCSOUT_NO; + be.fcs_auto = 0; +@@ -198,7 +199,7 @@ void start_interface(struct br2684_param + assign_vcc(params->astr, params->encap, params->payload, params->sndbuf, + params->reqqos); + if (up_script) { +- asprintf(&cmd, "%s nas%d", up_script, lastitf); ++ asprintf(&cmd, "%s %s%d", up_script, itfname, lastitf); + system(cmd); + free(cmd); + } +@@ -207,7 +208,7 @@ void start_interface(struct br2684_param + + void usage(char *s) + { +- printf("usage: %s [-b] [[-c number] [-e 0|1] [-s sndbuf] [-q qos] [-p 0|1] " ++ printf("usage: %s [-b] [-n name] [[-c number] [-e 0|1] [-s sndbuf] [-q qos] [-p 0|1] " + "[-a [itf.]vpi.vci]*]* [-S script]\n", s); + printf(" encapsulations: 0=llc, 1=vcmux\n payloads: 0=routed, 1=bridged\n"); + exit(1); +@@ -234,7 +235,7 @@ int main (int argc, char **argv) + + openlog (LOG_NAME,LOG_OPTION,LOG_FACILITY); + if (argc>1) +- while ((c = getopt(argc, argv,"q:a:bc:e:s:S:p:?h")) !=EOF) ++ while ((c = getopt(argc, argv,"q:a:bn:c:e:s:S:p:?h")) !=EOF) + switch (c) { + case 'q': + printf ("optarg : %s",optarg); +@@ -247,6 +248,9 @@ int main (int argc, char **argv) + case 'b': + background=1; + break; ++ case 'n': ++ itfname = optarg; ++ break; + case 'c': + /* temporary, to make it work with multiple interfaces: */ + if (params.itfnum>=0) start_interface(¶ms);