[OpenWrt-Devel] [PATCH netifd] interface: warn if ip6hint is truncated
Hans Dedecker
dedeckeh at gmail.com
Fri Nov 29 14:50:06 EST 2019
On Wed, Nov 20, 2019 at 7:11 PM Uwe Kleine-König <uwe at kleine-koenig.org> wrote:
>
> When for example a /60 is assigned to a network the last 4 bits of the
> ip6hint are unused. Emit a warning if any of these unused bits is set as
> it indicates that someone didn't understand how the hint is used. (As I
> did earlier today resulting in spending some time understanding the
> code.)
Patch applied with some minor tweaks
(https://git.openwrt.org/?p=project/netifd.git;a=commit;h=e45b1408284c05984b38a910a1f0a07d6c761397);
I added your SoB as this was missing in the patch
Hans
> ---
> interface.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/interface.c b/interface.c
> index 028dc6ccd5e5..839de0bb88ad 100644
> --- a/interface.c
> +++ b/interface.c
> @@ -863,9 +863,15 @@ interface_alloc(const char *name, struct blob_attr *config, bool dynamic)
> }
>
> iface->assignment_hint = -1;
> - if ((cur = tb[IFACE_ATTR_IP6HINT]))
> - iface->assignment_hint = strtol(blobmsg_get_string(cur), NULL, 16) &
> - ~((1 << (64 - iface->assignment_length)) - 1);
> + if ((cur = tb[IFACE_ATTR_IP6HINT])) {
> + int32_t assignment_hint = strtol(blobmsg_get_string(cur), NULL, 16);
> +
> + iface->assignment_hint = assignment_hint & ~((1 << (64 - iface->assignment_length)) - 1);
> +
> + if (iface->assignment_hint != assignment_hint)
> + netifd_log_message(L_WARNING, "Ignoring set bits of assignment hint for interface '%s'\n",
> + iface->name);
> + }
>
> if ((cur = tb[IFACE_ATTR_IP6CLASS]))
> interface_add_assignment_classes(iface, cur);
> --
> 2.24.0
>
>
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list