"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/if-bsd.c" between
dhcpcd-7.1.0.tar.xz and dhcpcd-7.1.1.tar.xz

About: dhcpcd is a RFC2131 compliant DHCP (Dynamic Host Configuration Protocol) client.

if-bsd.c  (dhcpcd-7.1.0.tar.xz):if-bsd.c  (dhcpcd-7.1.1.tar.xz)
skipping to change at line 200 skipping to change at line 200
void void
if_closesockets_os(struct dhcpcd_ctx *ctx) if_closesockets_os(struct dhcpcd_ctx *ctx)
{ {
struct priv *priv; struct priv *priv;
priv = (struct priv *)ctx->priv; priv = (struct priv *)ctx->priv;
if (priv->pf_inet6_fd != -1) if (priv->pf_inet6_fd != -1)
close(priv->pf_inet6_fd); close(priv->pf_inet6_fd);
} }
#if defined(INET) || defined(INET6)
static void static void
if_linkaddr(struct sockaddr_dl *sdl, const struct interface *ifp) if_linkaddr(struct sockaddr_dl *sdl, const struct interface *ifp)
{ {
memset(sdl, 0, sizeof(*sdl)); memset(sdl, 0, sizeof(*sdl));
sdl->sdl_family = AF_LINK; sdl->sdl_family = AF_LINK;
sdl->sdl_len = sizeof(*sdl); sdl->sdl_len = sizeof(*sdl);
sdl->sdl_nlen = sdl->sdl_alen = sdl->sdl_slen = 0; sdl->sdl_nlen = sdl->sdl_alen = sdl->sdl_slen = 0;
sdl->sdl_index = (unsigned short)ifp->index; sdl->sdl_index = (unsigned short)ifp->index;
} }
#endif
#if defined(SIOCG80211NWID) || defined(SIOCGETVLAN) #if defined(SIOCG80211NWID) || defined(SIOCGETVLAN)
static int if_direct_ioctl(int s, const char *ifname, static int if_direct_ioctl(int s, const char *ifname,
unsigned long cmd, void *data) unsigned long cmd, void *data)
{ {
strlcpy(data, ifname, IFNAMSIZ); strlcpy(data, ifname, IFNAMSIZ);
return ioctl(s, cmd, data); return ioctl(s, cmd, data);
} }
skipping to change at line 362 skipping to change at line 360
cp = data; cp = data;
for (i = 0; i < RTAX_MAX; i++) { for (i = 0; i < RTAX_MAX; i++) {
if (type & (1 << i)) { if (type & (1 << i)) {
sa[i] = (const struct sockaddr *)cp; sa[i] = (const struct sockaddr *)cp;
RT_ADVANCE(cp, sa[i]); RT_ADVANCE(cp, sa[i]);
} else } else
sa[i] = NULL; sa[i] = NULL;
} }
} }
#if defined(INET) || defined(INET6)
static struct interface * static struct interface *
if_findsdl(struct dhcpcd_ctx *ctx, const struct sockaddr_dl *sdl) if_findsdl(struct dhcpcd_ctx *ctx, const struct sockaddr_dl *sdl)
{ {
if (sdl->sdl_index) if (sdl->sdl_index)
return if_findindex(ctx->ifaces, sdl->sdl_index); return if_findindex(ctx->ifaces, sdl->sdl_index);
if (sdl->sdl_nlen) { if (sdl->sdl_nlen) {
char ifname[IF_NAMESIZE]; char ifname[IF_NAMESIZE];
skipping to change at line 507 skipping to change at line 504
if (cmd == RTM_ADD || cmd == RTM_CHANGE) { if (cmd == RTM_ADD || cmd == RTM_CHANGE) {
bool netmask_bcast = sa_is_allones(&rt->rt_netmask); bool netmask_bcast = sa_is_allones(&rt->rt_netmask);
rtm->rtm_flags |= RTF_UP; rtm->rtm_flags |= RTF_UP;
rtm->rtm_addrs |= RTA_GATEWAY; rtm->rtm_addrs |= RTA_GATEWAY;
if (!(rtm->rtm_flags & RTF_REJECT) && if (!(rtm->rtm_flags & RTF_REJECT) &&
!sa_is_loopback(&rt->rt_gateway)) !sa_is_loopback(&rt->rt_gateway))
{ {
rtm->rtm_index = (unsigned short)rt->rt_ifp->index; rtm->rtm_index = (unsigned short)rt->rt_ifp->index;
#ifdef __OpenBSD__ /*
* OpenBSD rejects the message for on-link routes.
* FreeBSD-12 kernel apparently panics.
* I can't replicate the panic, but better safe than sorry!
* https://roy.marples.name/archives/dhcpcd-discuss/0002286.html
*
* Neither OS currently allows IPv6 address sharing anyway, so let's
* try to encourage someone to fix that by logging a waring during compile.
*/
#if defined(__FreeBSD__) || defined(__OpenBSD__)
#warning OS does not allow IPv6 address sharing
if (!gateway_unspec || rt->rt_dest.sa_family!=AF_INET6) if (!gateway_unspec || rt->rt_dest.sa_family!=AF_INET6)
#endif #endif
rtm->rtm_addrs |= RTA_IFP; rtm->rtm_addrs |= RTA_IFP;
if (!sa_is_unspecified(&rt->rt_ifa)) if (!sa_is_unspecified(&rt->rt_ifa))
rtm->rtm_addrs |= RTA_IFA; rtm->rtm_addrs |= RTA_IFA;
} }
if (netmask_bcast) if (netmask_bcast)
rtm->rtm_flags |= RTF_HOST; rtm->rtm_flags |= RTF_HOST;
/* Network routes are cloning or connected if supported. /* Network routes are cloning or connected if supported.
* All other routes are static. */ * All other routes are static. */
skipping to change at line 691 skipping to change at line 698
rtm = (void *)p; rtm = (void *)p;
if (if_copyrt(ctx, &rt, rtm) == 0) { if (if_copyrt(ctx, &rt, rtm) == 0) {
rt.rt_dflags |= RTDF_INIT; rt.rt_dflags |= RTDF_INIT;
rt_recvrt(RTM_ADD, &rt); rt_recvrt(RTM_ADD, &rt);
} }
} }
free(buf); free(buf);
return 0; return 0;
} }
#endif
#ifdef INET #ifdef INET
int int
if_address(unsigned char cmd, const struct ipv4_addr *ia) if_address(unsigned char cmd, const struct ipv4_addr *ia)
{ {
int r; int r;
struct in_aliasreq ifra; struct in_aliasreq ifra;
memset(&ifra, 0, sizeof(ifra)); memset(&ifra, 0, sizeof(ifra));
strlcpy(ifra.ifra_name, ia->iface->name, sizeof(ifra.ifra_name)); strlcpy(ifra.ifra_name, ia->iface->name, sizeof(ifra.ifra_name));
skipping to change at line 952 skipping to change at line 957
static void static void
if_ifinfo(struct dhcpcd_ctx *ctx, const struct if_msghdr *ifm) if_ifinfo(struct dhcpcd_ctx *ctx, const struct if_msghdr *ifm)
{ {
struct interface *ifp; struct interface *ifp;
int link_state; int link_state;
if ((ifp = if_findindex(ctx->ifaces, ifm->ifm_index)) == NULL) if ((ifp = if_findindex(ctx->ifaces, ifm->ifm_index)) == NULL)
return; return;
/* If we get LINK_STATE_UNKNOWN here, it means the interface switch (ifm->ifm_data.ifi_link_state) {
* doesn't support reporting carrier state. case LINK_STATE_UNKNOWN:
* As such, we need to rely on IFF_UP. if (ifp->media_valid) {
* Even if LINK_STATE_UP is reported, we also need IFF_UP as well link_state = LINK_DOWN;
* so for dhcpcd they are equivalent and we only need to check break;
* LINK_STATE_DOWN. */ }
if (ifm->ifm_data.ifi_link_state == LINK_STATE_DOWN) /* Interface does not report media state, so we have
link_state = LINK_DOWN; * to rely on IFF_UP. */
else /* FALLTHROUGH */
case LINK_STATE_UP:
link_state = ifm->ifm_flags & IFF_UP ? LINK_UP : LINK_DOWN; link_state = ifm->ifm_flags & IFF_UP ? LINK_UP : LINK_DOWN;
break;
default:
link_state = LINK_DOWN;
break;
}
dhcpcd_handlecarrier(ctx, link_state, dhcpcd_handlecarrier(ctx, link_state,
(unsigned int)ifm->ifm_flags, ifp->name); (unsigned int)ifm->ifm_flags, ifp->name);
} }
static void static void
if_rtm(struct dhcpcd_ctx *ctx, const struct rt_msghdr *rtm) if_rtm(struct dhcpcd_ctx *ctx, const struct rt_msghdr *rtm)
{ {
struct rt rt; struct rt rt;
 End of changes. 7 change blocks. 
15 lines changed or deleted 26 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)