openwrt / odhcpd

This repository is a mirror of https://git.openwrt.org/?p=project/odhcpd.git. Pull requests will be accepted which will be merged in odhcpd.git
GNU General Public License v2.0
162 stars 98 forks source link

ra_mtu default value '0' causes error on config_parse_interface #169

Closed morohe closed 3 years ago

morohe commented 3 years ago

Currently the default value of ra_mtu is 0, but it causes an error in parsing the config file.

config.c int config_parse_interface(void *data, size_t len, const char *name, bool overwrite)
~to line number 780~
if ((c = tb[IFACE_ATTR_RA_MTU])) {
        uint32_t ra_mtu = blobmsg_get_u32(c);
        if (ra_mtu < 1280 || ra_mtu > 65535)
                goto err;

                iface->ra_mtu = ra_mtu;
}

ra_mtu is checked with the following and it looks fine.

static int send_router_advert(struct interface *iface, const struct in6_addr *from)
~to line number 477~
if (mtu == 0)
        mtu = odhcpd_get_interface_config(iface->ifname, "mtu");

if (mtu < 1280)
        mtu = 1280;

To fix this issue, my suggest is

  1. Add write to syslog on parse error detail in config_parse_interface.
  2. Fix README.md ra_mtu default value is not zero, It's 1280.
  3. Remove detailed error check on parse, if always checked at the time of use.
  4. Or set to default value on error.

Thanks.

morohe commented 3 years ago

Sorry, I reported to bugs.openwrt.org. Close this issue.