rpcd-mod-luci: fix reporting network device flags

Fix reporting of ceertain flag values larger than 255, such as IFF_PROMISC
by explicitly casting the bit test expression to a boolean result since
the implicit integer truncation to uint8_t will turn the `0x100` result of
a set IFF_PROMISC bit into just `0x0`.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
Jo-Philipp Wich 2023-02-06 15:46:49 +01:00
parent 09c2709507
commit a570e30006

View File

@ -788,13 +788,13 @@ rpc_luci_parse_network_device_sys(const char *name, struct ifaddrs *ifaddr)
blobmsg_close_table(&blob, o2);
o2 = blobmsg_open_table(&blob, "flags");
blobmsg_add_u8(&blob, "up", ifa_flags & IFF_UP);
blobmsg_add_u8(&blob, "broadcast", ifa_flags & IFF_BROADCAST);
blobmsg_add_u8(&blob, "promisc", ifa_flags & IFF_PROMISC);
blobmsg_add_u8(&blob, "loopback", ifa_flags & IFF_LOOPBACK);
blobmsg_add_u8(&blob, "noarp", ifa_flags & IFF_NOARP);
blobmsg_add_u8(&blob, "multicast", ifa_flags & IFF_MULTICAST);
blobmsg_add_u8(&blob, "pointtopoint", ifa_flags & IFF_POINTOPOINT);
blobmsg_add_u8(&blob, "up", !!(ifa_flags & IFF_UP));
blobmsg_add_u8(&blob, "broadcast", !!(ifa_flags & IFF_BROADCAST));
blobmsg_add_u8(&blob, "promisc", !!(ifa_flags & IFF_PROMISC));
blobmsg_add_u8(&blob, "loopback", !!(ifa_flags & IFF_LOOPBACK));
blobmsg_add_u8(&blob, "noarp", !!(ifa_flags & IFF_NOARP));
blobmsg_add_u8(&blob, "multicast", !!(ifa_flags & IFF_MULTICAST));
blobmsg_add_u8(&blob, "pointtopoint", !!(ifa_flags & IFF_POINTOPOINT));
blobmsg_close_table(&blob, o2);
o2 = blobmsg_open_table(&blob, "link");