[v2] alfred: Support interfaces IDs with more than two digits

Submitted by Adrian Schmutzler on June 13, 2018, 12:45 p.m.

Details

Message ID 1528893918-8047-1-git-send-email-freifunk@adrianschmutzler.de
State Accepted
Headers show

Commit Message

Adrian Schmutzler June 13, 2018, 12:45 p.m.
Occationally /proc/net/if_inet6 contains interface IDs with
three digits. In this case, the regex in wait_for_ll_address()
does not work anymore and alfred is not starting.

This patch changes the evaluation so that fields are used instead
of the mere position by counting characters.

This is a backport from openwrt-routing and can be removed when
updating to OpenWRT 18.06, but not for newer versions of 17.01.

Fixes #98.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>

Tested-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>

---

Changes in v2:
- Use a more general version of the match in awk
---
 ...ort-interface-IDs-with-more-than-two-digi.patch | 35 ++++++++++++++++++++++
 buildscript                                        |  3 +-
 2 files changed, 37 insertions(+), 1 deletion(-)
 create mode 100644 build_patches/routing/0001-alfred-Support-interface-IDs-with-more-than-two-digi.patch

Patch hide | download patch | download mbox

diff --git a/build_patches/routing/0001-alfred-Support-interface-IDs-with-more-than-two-digi.patch b/build_patches/routing/0001-alfred-Support-interface-IDs-with-more-than-two-digi.patch
new file mode 100644
index 0000000..163f556
--- /dev/null
+++ b/build_patches/routing/0001-alfred-Support-interface-IDs-with-more-than-two-digi.patch
@@ -0,0 +1,35 @@ 
+From 135bc605b4cf91d40ac97f1129a6a5a950f3ff72 Mon Sep 17 00:00:00 2001
+From: Adrian Schmutzler <freifunk@adrianschmutzler.de>
+Date: Mon, 19 Mar 2018 14:16:54 +0100
+Subject: [PATCH] alfred: Support interface IDs with more than two digits
+
+Occationally /proc/net/if_inet6 contains interface IDs with
+three digits. In this case, the regex in wait_for_ll_address()
+does not work anymore and alfred is not starting.
+
+This patch changes the evaluation so that fields are used instead
+of the mere position by counting characters.
+
+Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
+---
+ alfred/files/alfred.init | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/alfred/files/alfred.init b/alfred/files/alfred.init
+index 4c9a9e19..82934368 100755
+--- a/alfred/files/alfred.init
++++ b/alfred/files/alfred.init
+@@ -46,11 +46,11 @@ wait_for_ll_address()
+ 	for i in $(seq $timeout); do
+ 		# We look for
+ 		# - the link-local address (starts with fe80)
+-		# - without tentative flag (bit 0x40 in the flags field; the first char of the flags field begins 38 columns after the fe80 prefix
++		# - without tentative flag (bit 0x40 in the flags field; the first char of the fifth field is evaluated)
+ 		# - on interface $iface
+ 		if awk '
+ 			BEGIN { RET=1 }
+-			/^fe80.{37} [012389ab]/ { if ($6 == "'"$iface"'") RET=0 }
++			$1 ~ /^fe80/ && $5 ~ /^[012389ab]/ && $6 == "'"$iface"'" { RET=0 }
+ 			END { exit RET }
+ 		' /proc/net/if_inet6; then
+ 			return
diff --git a/buildscript b/buildscript
index ab092da..95ae31d 100755
--- a/buildscript
+++ b/buildscript
@@ -38,7 +38,8 @@  GLUON_PKGS="kmod-batman-adv-legacy micrond simple-tc uradvd"
 #official openwrt routing packages
 ROUTING=(routing
          https://git.openwrt.org/feed/routing.git
-         d11075cd40a88602bf4ba2b275f72100ddcb4767) # lede-17.01
+         d11075cd40a88602bf4ba2b275f72100ddcb4767
+         "0001-alfred-Support-interface-IDs-with-more-than-two-digi.patch") # lede-17.01
 ROUTING_PKGS="kmod-batman-adv batctl alfred"
 
 FFF=(fff)

Comments

Robert Langhammer June 14, 2018, 1:54 p.m.
Hallo Adrian,

schoene awk Loesung!

Reviewed-by: Robert Langhgammer <rlanghammer@web.de>


Am 13.06.2018 um 14:45 schrieb Adrian Schmutzler:
> Occationally /proc/net/if_inet6 contains interface IDs with
> three digits. In this case, the regex in wait_for_ll_address()
> does not work anymore and alfred is not starting.
>
> This patch changes the evaluation so that fields are used instead
> of the mere position by counting characters.
>
> This is a backport from openwrt-routing and can be removed when
> updating to OpenWRT 18.06, but not for newer versions of 17.01.
>
> Fixes #98.
>
> Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
>
> Tested-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
>
> ---
>
> Changes in v2:
> - Use a more general version of the match in awk
> ---
>  ...ort-interface-IDs-with-more-than-two-digi.patch | 35 ++++++++++++++++++++++
>  buildscript                                        |  3 +-
>  2 files changed, 37 insertions(+), 1 deletion(-)
>  create mode 100644 build_patches/routing/0001-alfred-Support-interface-IDs-with-more-than-two-digi.patch
>
> diff --git a/build_patches/routing/0001-alfred-Support-interface-IDs-with-more-than-two-digi.patch b/build_patches/routing/0001-alfred-Support-interface-IDs-with-more-than-two-digi.patch
> new file mode 100644
> index 0000000..163f556
> --- /dev/null
> +++ b/build_patches/routing/0001-alfred-Support-interface-IDs-with-more-than-two-digi.patch
> @@ -0,0 +1,35 @@
> +From 135bc605b4cf91d40ac97f1129a6a5a950f3ff72 Mon Sep 17 00:00:00 2001
> +From: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> +Date: Mon, 19 Mar 2018 14:16:54 +0100
> +Subject: [PATCH] alfred: Support interface IDs with more than two digits
> +
> +Occationally /proc/net/if_inet6 contains interface IDs with
> +three digits. In this case, the regex in wait_for_ll_address()
> +does not work anymore and alfred is not starting.
> +
> +This patch changes the evaluation so that fields are used instead
> +of the mere position by counting characters.
> +
> +Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> +---
> + alfred/files/alfred.init | 4 ++--
> + 1 file changed, 2 insertions(+), 2 deletions(-)
> +
> +diff --git a/alfred/files/alfred.init b/alfred/files/alfred.init
> +index 4c9a9e19..82934368 100755
> +--- a/alfred/files/alfred.init
> ++++ b/alfred/files/alfred.init
> +@@ -46,11 +46,11 @@ wait_for_ll_address()
> + 	for i in $(seq $timeout); do
> + 		# We look for
> + 		# - the link-local address (starts with fe80)
> +-		# - without tentative flag (bit 0x40 in the flags field; the first char of the flags field begins 38 columns after the fe80 prefix
> ++		# - without tentative flag (bit 0x40 in the flags field; the first char of the fifth field is evaluated)
> + 		# - on interface $iface
> + 		if awk '
> + 			BEGIN { RET=1 }
> +-			/^fe80.{37} [012389ab]/ { if ($6 == "'"$iface"'") RET=0 }
> ++			$1 ~ /^fe80/ && $5 ~ /^[012389ab]/ && $6 == "'"$iface"'" { RET=0 }
> + 			END { exit RET }
> + 		' /proc/net/if_inet6; then
> + 			return
> diff --git a/buildscript b/buildscript
> index ab092da..95ae31d 100755
> --- a/buildscript
> +++ b/buildscript
> @@ -38,7 +38,8 @@ GLUON_PKGS="kmod-batman-adv-legacy micrond simple-tc uradvd"
>  #official openwrt routing packages
>  ROUTING=(routing
>           https://git.openwrt.org/feed/routing.git
> -         d11075cd40a88602bf4ba2b275f72100ddcb4767) # lede-17.01
> +         d11075cd40a88602bf4ba2b275f72100ddcb4767
> +         "0001-alfred-Support-interface-IDs-with-more-than-two-digi.patch") # lede-17.01
>  ROUTING_PKGS="kmod-batman-adv batctl alfred"
>  
>  FFF=(fff)
Tim Niemeyer June 17, 2018, 8:24 a.m.
Hi

Am Mittwoch, den 13.06.2018, 14:45 +0200 schrieb Adrian Schmutzler:
> Occationally /proc/net/if_inet6 contains interface IDs with
> three digits. In this case, the regex in wait_for_ll_address()

Wie hast du das denn raus gefunden?

Reviewed-by: Tim Niemeyer <tim@tn-x.org>

Tim

> does not work anymore and alfred is not starting.
> 
> This patch changes the evaluation so that fields are used instead
> of the mere position by counting characters.
> 
> This is a backport from openwrt-routing and can be removed when
> updating to OpenWRT 18.06, but not for newer versions of 17.01.
> 
> Fixes #98.
> 
> Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> 
> Tested-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> 
> ---
> 
> Changes in v2:
> - Use a more general version of the match in awk
> ---
>  ...ort-interface-IDs-with-more-than-two-digi.patch | 35
> ++++++++++++++++++++++
>  buildscript                                        |  3 +-
>  2 files changed, 37 insertions(+), 1 deletion(-)
>  create mode 100644 build_patches/routing/0001-alfred-Support-
> interface-IDs-with-more-than-two-digi.patch
> 
> diff --git a/build_patches/routing/0001-alfred-Support-interface-IDs-
> with-more-than-two-digi.patch b/build_patches/routing/0001-alfred-
> Support-interface-IDs-with-more-than-two-digi.patch
> new file mode 100644
> index 0000000..163f556
> --- /dev/null
> +++ b/build_patches/routing/0001-alfred-Support-interface-IDs-with-
> more-than-two-digi.patch
> @@ -0,0 +1,35 @@
> +From 135bc605b4cf91d40ac97f1129a6a5a950f3ff72 Mon Sep 17 00:00:00
> 2001
> +From: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> +Date: Mon, 19 Mar 2018 14:16:54 +0100
> +Subject: [PATCH] alfred: Support interface IDs with more than two
> digits
> +
> +Occationally /proc/net/if_inet6 contains interface IDs with
> +three digits. In this case, the regex in wait_for_ll_address()
> +does not work anymore and alfred is not starting.
> +
> +This patch changes the evaluation so that fields are used instead
> +of the mere position by counting characters.
> +
> +Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> +---
> + alfred/files/alfred.init | 4 ++--
> + 1 file changed, 2 insertions(+), 2 deletions(-)
> +
> +diff --git a/alfred/files/alfred.init b/alfred/files/alfred.init
> +index 4c9a9e19..82934368 100755
> +--- a/alfred/files/alfred.init
> ++++ b/alfred/files/alfred.init
> +@@ -46,11 +46,11 @@ wait_for_ll_address()
> + 	for i in $(seq $timeout); do
> + 		# We look for
> + 		# - the link-local address (starts with fe80)
> +-		# - without tentative flag (bit 0x40 in the flags
> field; the first char of the flags field begins 38 columns after the
> fe80 prefix
> ++		# - without tentative flag (bit 0x40 in the flags
> field; the first char of the fifth field is evaluated)
> + 		# - on interface $iface
> + 		if awk '
> + 			BEGIN { RET=1 }
> +-			/^fe80.{37} [012389ab]/ { if ($6 ==
> "'"$iface"'") RET=0 }
> ++			$1 ~ /^fe80/ && $5 ~ /^[012389ab]/ && $6 ==
> "'"$iface"'" { RET=0 }
> + 			END { exit RET }
> + 		' /proc/net/if_inet6; then
> + 			return
> diff --git a/buildscript b/buildscript
> index ab092da..95ae31d 100755
> --- a/buildscript
> +++ b/buildscript
> @@ -38,7 +38,8 @@ GLUON_PKGS="kmod-batman-adv-legacy micrond simple-
> tc uradvd"
>  #official openwrt routing packages
>  ROUTING=(routing
>           https://git.openwrt.org/feed/routing.git
> -         d11075cd40a88602bf4ba2b275f72100ddcb4767) # lede-17.01
> +         d11075cd40a88602bf4ba2b275f72100ddcb4767
> +         "0001-alfred-Support-interface-IDs-with-more-than-two-
> digi.patch") # lede-17.01
>  ROUTING_PKGS="kmod-batman-adv batctl alfred"
>  
>  FFF=(fff)
Tim Niemeyer June 17, 2018, 8:28 a.m.
Hi

Und applied.

Danke.
Tim

Am Mittwoch, den 13.06.2018, 14:45 +0200 schrieb Adrian Schmutzler:
> Occationally /proc/net/if_inet6 contains interface IDs with
> three digits. In this case, the regex in wait_for_ll_address()
> does not work anymore and alfred is not starting.
> 
> This patch changes the evaluation so that fields are used instead
> of the mere position by counting characters.
> 
> This is a backport from openwrt-routing and can be removed when
> updating to OpenWRT 18.06, but not for newer versions of 17.01.
> 
> Fixes #98.
> 
> Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> 
> Tested-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> 
> ---
> 
> Changes in v2:
> - Use a more general version of the match in awk
> ---
>  ...ort-interface-IDs-with-more-than-two-digi.patch | 35
> ++++++++++++++++++++++
>  buildscript                                        |  3 +-
>  2 files changed, 37 insertions(+), 1 deletion(-)
>  create mode 100644 build_patches/routing/0001-alfred-Support-
> interface-IDs-with-more-than-two-digi.patch
> 
> diff --git a/build_patches/routing/0001-alfred-Support-interface-IDs-
> with-more-than-two-digi.patch b/build_patches/routing/0001-alfred-
> Support-interface-IDs-with-more-than-two-digi.patch
> new file mode 100644
> index 0000000..163f556
> --- /dev/null
> +++ b/build_patches/routing/0001-alfred-Support-interface-IDs-with-
> more-than-two-digi.patch
> @@ -0,0 +1,35 @@
> +From 135bc605b4cf91d40ac97f1129a6a5a950f3ff72 Mon Sep 17 00:00:00
> 2001
> +From: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> +Date: Mon, 19 Mar 2018 14:16:54 +0100
> +Subject: [PATCH] alfred: Support interface IDs with more than two
> digits
> +
> +Occationally /proc/net/if_inet6 contains interface IDs with
> +three digits. In this case, the regex in wait_for_ll_address()
> +does not work anymore and alfred is not starting.
> +
> +This patch changes the evaluation so that fields are used instead
> +of the mere position by counting characters.
> +
> +Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> +---
> + alfred/files/alfred.init | 4 ++--
> + 1 file changed, 2 insertions(+), 2 deletions(-)
> +
> +diff --git a/alfred/files/alfred.init b/alfred/files/alfred.init
> +index 4c9a9e19..82934368 100755
> +--- a/alfred/files/alfred.init
> ++++ b/alfred/files/alfred.init
> +@@ -46,11 +46,11 @@ wait_for_ll_address()
> + 	for i in $(seq $timeout); do
> + 		# We look for
> + 		# - the link-local address (starts with fe80)
> +-		# - without tentative flag (bit 0x40 in the flags
> field; the first char of the flags field begins 38 columns after the
> fe80 prefix
> ++		# - without tentative flag (bit 0x40 in the flags
> field; the first char of the fifth field is evaluated)
> + 		# - on interface $iface
> + 		if awk '
> + 			BEGIN { RET=1 }
> +-			/^fe80.{37} [012389ab]/ { if ($6 ==
> "'"$iface"'") RET=0 }
> ++			$1 ~ /^fe80/ && $5 ~ /^[012389ab]/ && $6 ==
> "'"$iface"'" { RET=0 }
> + 			END { exit RET }
> + 		' /proc/net/if_inet6; then
> + 			return
> diff --git a/buildscript b/buildscript
> index ab092da..95ae31d 100755
> --- a/buildscript
> +++ b/buildscript
> @@ -38,7 +38,8 @@ GLUON_PKGS="kmod-batman-adv-legacy micrond simple-
> tc uradvd"
>  #official openwrt routing packages
>  ROUTING=(routing
>           https://git.openwrt.org/feed/routing.git
> -         d11075cd40a88602bf4ba2b275f72100ddcb4767) # lede-17.01
> +         d11075cd40a88602bf4ba2b275f72100ddcb4767
> +         "0001-alfred-Support-interface-IDs-with-more-than-two-
> digi.patch") # lede-17.01
>  ROUTING_PKGS="kmod-batman-adv batctl alfred"
>  
>  FFF=(fff)
Adrian Schmutzler June 17, 2018, 12:47 p.m.
Hallo Tim,

https://mantis.freifunk-franken.de/view.php?id=98

Christian hat das ursprünglich entdeckt. Ist im Mantis verlinkt. Ich habe dann nur versucht, es zu beheben.

Der schöne awk ist auch nicht von mir, sondern bei openwrt-routing vorgeschlagen worden.

https://github.com/openwrt-routing/packages/pull/354

Hätte vll. ein

Fixes #98

mit in den Patch tun sollen.

Grüße

Adrian

> -----Original Message-----
> From: Tim Niemeyer [mailto:tim@tn-x.org]
> Sent: Sonntag, 17. Juni 2018 10:25
> To: Adrian Schmutzler <freifunk@adrianschmutzler.de>; franken-
> dev@freifunk.net
> Subject: Re: [PATCH v2] alfred: Support interfaces IDs with more than two
> digits
> 
> Hi
> 
> Am Mittwoch, den 13.06.2018, 14:45 +0200 schrieb Adrian Schmutzler:
> > Occationally /proc/net/if_inet6 contains interface IDs with three
> > digits. In this case, the regex in wait_for_ll_address()
> 
> Wie hast du das denn raus gefunden?
> 
> Reviewed-by: Tim Niemeyer <tim@tn-x.org>
> 
> Tim
> 
> > does not work anymore and alfred is not starting.
> >
> > This patch changes the evaluation so that fields are used instead of
> > the mere position by counting characters.
> >
> > This is a backport from openwrt-routing and can be removed when
> > updating to OpenWRT 18.06, but not for newer versions of 17.01.
> >
> > Fixes #98.
> >
> > Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> >
> > Tested-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> >
> > ---
> >
> > Changes in v2:
> > - Use a more general version of the match in awk
> > ---
> >  ...ort-interface-IDs-with-more-than-two-digi.patch | 35
> > ++++++++++++++++++++++
> >  buildscript                                        |  3 +-
> >  2 files changed, 37 insertions(+), 1 deletion(-)
> >  create mode 100644 build_patches/routing/0001-alfred-Support-
> > interface-IDs-with-more-than-two-digi.patch
> >
> > diff --git a/build_patches/routing/0001-alfred-Support-interface-IDs-
> > with-more-than-two-digi.patch b/build_patches/routing/0001-alfred-
> > Support-interface-IDs-with-more-than-two-digi.patch
> > new file mode 100644
> > index 0000000..163f556
> > --- /dev/null
> > +++ b/build_patches/routing/0001-alfred-Support-interface-IDs-with-
> > more-than-two-digi.patch
> > @@ -0,0 +1,35 @@
> > +From 135bc605b4cf91d40ac97f1129a6a5a950f3ff72 Mon Sep 17 00:00:00
> > 2001
> > +From: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> > +Date: Mon, 19 Mar 2018 14:16:54 +0100
> > +Subject: [PATCH] alfred: Support interface IDs with more than two
> > digits
> > +
> > +Occationally /proc/net/if_inet6 contains interface IDs with three
> > +digits. In this case, the regex in wait_for_ll_address() does not
> > +work anymore and alfred is not starting.
> > +
> > +This patch changes the evaluation so that fields are used instead of
> > +the mere position by counting characters.
> > +
> > +Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> > +---
> > + alfred/files/alfred.init | 4 ++--
> > + 1 file changed, 2 insertions(+), 2 deletions(-)
> > +
> > +diff --git a/alfred/files/alfred.init b/alfred/files/alfred.init
> > +index 4c9a9e19..82934368 100755
> > +--- a/alfred/files/alfred.init
> > ++++ b/alfred/files/alfred.init
> > +@@ -46,11 +46,11 @@ wait_for_ll_address()
> > + 	for i in $(seq $timeout); do
> > + 		# We look for
> > + 		# - the link-local address (starts with fe80)
> > +-		# - without tentative flag (bit 0x40 in the flags
> > field; the first char of the flags field begins 38 columns after the
> > fe80 prefix
> > ++		# - without tentative flag (bit 0x40 in the flags
> > field; the first char of the fifth field is evaluated)
> > + 		# - on interface $iface
> > + 		if awk '
> > + 			BEGIN { RET=1 }
> > +-			/^fe80.{37} [012389ab]/ { if ($6 ==
> > "'"$iface"'") RET=0 }
> > ++			$1 ~ /^fe80/ && $5 ~ /^[012389ab]/ && $6 ==
> > "'"$iface"'" { RET=0 }
> > + 			END { exit RET }
> > + 		' /proc/net/if_inet6; then
> > + 			return
> > diff --git a/buildscript b/buildscript index ab092da..95ae31d 100755
> > --- a/buildscript
> > +++ b/buildscript
> > @@ -38,7 +38,8 @@ GLUON_PKGS="kmod-batman-adv-legacy micrond
> simple-
> > tc uradvd"
> >  #official openwrt routing packages
> >  ROUTING=(routing
> >           https://git.openwrt.org/feed/routing.git
> > -         d11075cd40a88602bf4ba2b275f72100ddcb4767) # lede-17.01
> > +         d11075cd40a88602bf4ba2b275f72100ddcb4767
> > +         "0001-alfred-Support-interface-IDs-with-more-than-two-
> > digi.patch") # lede-17.01
> >  ROUTING_PKGS="kmod-batman-adv batctl alfred"
> >
> >  FFF=(fff)