When we get an invalid length for a DHCP option, try and continue anyway.
When MTU is less than 576 we now ignore it instead of setting the MTU to 576.
Build correctly on dietlibc, thanks to d00mer.
+Check that if_nametoindex returns a valid index, thanks to d00mer.
dhcpcd-3.0.16
RFC 2131 is full of confusion regarding MTU it seems as the effective minimum
if (! del)
nlm.hdr.nlmsg_flags |= NLM_F_CREATE | NLM_F_REPLACE;
nlm.hdr.nlmsg_type = del ? RTM_DELADDR : RTM_NEWADDR;
- nlm.ifa.ifa_index = if_nametoindex (ifname);
+ if (! (nlm.ifa.ifa_index = if_nametoindex (ifname)))
+ {
+ logger (LOG_ERR, "if_nametoindex: Couldn't find index for interface `%s'",
+ ifname);
+ return -1;
+ }
nlm.ifa.ifa_family = AF_INET;
nlm.ifa.ifa_prefixlen = inet_ntocidr (netmask);
{
char *dstd;
char *gend;
+ unsigned int ifindex;
struct
{
struct nlmsghdr hdr;
add_attr_l (&nlm.hdr, sizeof (nlm), RTA_GATEWAY, &gateway.s_addr,
sizeof (gateway.s_addr));
- add_attr_32 (&nlm.hdr, sizeof (nlm), RTA_OIF, if_nametoindex (ifname));
+
+ if (! (ifindex = if_nametoindex (ifname)))
+ {
+ logger (LOG_ERR, "if_nametoindex: Couldn't find index for interface `%s'",
+ ifname);
+ return -1;
+ }
+
+ add_attr_32 (&nlm.hdr, sizeof (nlm), RTA_OIF, ifindex);
add_attr_32 (&nlm.hdr, sizeof (nlm), RTA_PRIORITY, metric);
return send_netlink (&nlm.hdr);
sll.sll_protocol = htons (ETH_P_ARP);
else
sll.sll_protocol = htons (ETH_P_IP);
- sll.sll_ifindex = if_nametoindex (iface->name);
+ if (! (sll.sll_ifindex = if_nametoindex (iface->name)))
+ {
+ logger (LOG_ERR, "if_nametoindex: Couldn't find index for interface `%s'",
+ iface->name);
+ close (fd);
+ return -1;
+ }
if (bind(fd, (struct sockaddr *) &sll, sizeof (struct sockaddr_ll)) == -1)
{
memset (&sll, 0, sizeof (struct sockaddr_ll));
sll.sll_family = AF_PACKET;
sll.sll_protocol = htons (type);
- sll.sll_ifindex = if_nametoindex (iface->name);
+ if (! (sll.sll_ifindex = if_nametoindex (iface->name)))
+ {
+ logger (LOG_ERR, "if_nametoindex: Couldn't find index for interface `%s'",
+ iface->name);
+ return -1;
+ }
sll.sll_halen = ETHER_ADDR_LEN;
memset(sll.sll_addr, 0xff, sizeof (sll.sll_addr));