From: Roy Marples Date: Wed, 24 Apr 2019 11:00:57 +0000 (+0000) Subject: sun: Fix adding IPv4LL default route X-Git-Tag: v7.2.1~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f96f6447a6b3adfd17ad2c07ca08154c4751b872;p=thirdparty%2Fdhcpcd.git sun: Fix adding IPv4LL default route --- diff --git a/src/if-sun.c b/src/if-sun.c index bb5b5c0a..191e0e68 100644 --- a/src/if-sun.c +++ b/src/if-sun.c @@ -526,6 +526,7 @@ if_route0(struct dhcpcd_ctx *ctx, struct rtm *rtmsg, struct rt_msghdr *rtm; char *bp = rtmsg->buffer; socklen_t sl; + bool gateway_unspec; /* WARNING: Solaris will not allow you to delete RTF_KERNEL routes. * This includes subnet/prefix routes. */ @@ -544,6 +545,8 @@ if_route0(struct dhcpcd_ctx *ctx, struct rtm *rtmsg, rtm->rtm_flags = rt->rt_flags; rtm->rtm_addrs = RTA_DST | RTA_GATEWAY; + gateway_unspec = sa_is_unspecified(&rt->rt_gateway); + if (cmd == RTM_ADD || cmd == RTM_CHANGE) { bool netmask_bcast = sa_is_allones(&rt->rt_netmask); @@ -563,7 +566,7 @@ if_route0(struct dhcpcd_ctx *ctx, struct rtm *rtmsg, if (netmask_bcast) rtm->rtm_flags |= RTF_HOST; - else + else if (!gateway_unspec) rtm->rtm_flags |= RTF_GATEWAY; /* Emulate the kernel by marking address generated @@ -582,7 +585,7 @@ if_route0(struct dhcpcd_ctx *ctx, struct rtm *rtmsg, ADDSA(&rt->rt_dest); - if (sa_is_unspecified(&rt->rt_gateway)) + if (gateway_unspec) ADDSA(&rt->rt_ifa); else ADDSA(&rt->rt_gateway);