This appears to just be cosmetic.
#include <sys/param.h>
#include <sys/stat.h>
+#include <linux/icmpv6.h>
#include <linux/if_addr.h>
#include <linux/if_link.h>
#include <linux/if_packet.h>
return 0;
}
+static int
+add_attr_8(struct nlmsghdr *n, unsigned short maxlen, unsigned short type,
+ uint8_t data)
+{
+
+ return add_attr_l(n, maxlen, type, &data, sizeof(data));
+}
+
static int
add_attr_32(struct nlmsghdr *n, unsigned short maxlen, unsigned short type,
uint32_t data)
RTA_DATA(metrics),
(unsigned short)RTA_PAYLOAD(metrics));
}
+
+ if (rt->rt_dflags & RTDF_RA) {
+ uint8_t pref;
+
+ switch(rt->rt_pref) {
+ case RTPREF_LOW:
+ pref = ICMPV6_ROUTER_PREF_LOW;
+ break;
+ case RTPREF_MEDIUM:
+ pref = ICMPV6_ROUTER_PREF_MEDIUM;
+ break;
+ case RTPREF_HIGH:
+ pref = ICMPV6_ROUTER_PREF_HIGH;
+ break;
+ default:
+ pref = ICMPV6_ROUTER_PREF_INVALID;
+ break;
+ }
+ add_attr_8(&nlm.hdr, sizeof(nlm), RTA_PREF, pref);
+ }
}
if (!sa_is_loopback(&rt->rt_gateway))
char buffer[32];
};
-static int
-add_attr_8(struct nlmsghdr *n, unsigned short maxlen, unsigned short type,
- uint8_t data)
-{
-
- return add_attr_l(n, maxlen, type, &data, sizeof(data));
-}
-
static struct rtattr *
add_attr_nest(struct nlmsghdr *n, unsigned short maxlen, unsigned short type)
{
rt = inet6_makeprefix(rap->iface, rap, addr);
if (rt) {
rt->rt_dflags |= RTDF_RA;
+#ifdef HAVE_ROUTE_PREF
+ rt->rt_pref = ipv6nd_rtpref(rap);
+#endif
rt_proto_add(routes, rt);
}
}
if (rt == NULL)
continue;
rt->rt_dflags |= RTDF_RA;
+#ifdef HAVE_ROUTE_PREF
+ rt->rt_pref = ipv6nd_rtpref(rap);
+#endif
rt_proto_add(routes, rt);
}
return 0;
#define ND_RA_FLAG_RTPREF_RSV 0x10
#endif
-/* RTPREF_MEDIUM has to be 0! */
-#define RTPREF_HIGH 1
-#define RTPREF_MEDIUM 0
-#define RTPREF_LOW (-1)
-#define RTPREF_RESERVED (-2)
-#define RTPREF_INVALID (-3) /* internal */
-
#define EXPIRED_MAX 5 /* Remember 5 expired routers to avoid
logspam. */
RTR_CARRIER_EXPIRE, ipv6nd_expire, ifp);
}
-static int
+int
ipv6nd_rtpref(struct ra *rap)
{
int ipv6nd_open(struct dhcpcd_ctx *);
#endif
void ipv6nd_recvmsg(struct dhcpcd_ctx *, struct msghdr *);
+int ipv6nd_rtpref(struct ra *);
void ipv6nd_printoptions(const struct dhcpcd_ctx *,
const struct dhcp_opt *, size_t);
void ipv6nd_startrs(struct interface *);
#endif
} else
#endif
- if ((rt = malloc(sizeof(*rt))) == NULL) {
+ if ((rt = calloc(1, sizeof(*rt))) == NULL)
logerr(__func__);
- return NULL;
- }
- memset(rt, 0, sizeof(*rt));
return rt;
}
# endif
#endif
+#ifdef __linux__
+# define HAVE_ROUTE_PREF
+#endif
+
#if defined(__OpenBSD__) || defined (__sun)
# define ROUTE_PER_GATEWAY
/* XXX dhcpcd doesn't really support this yet.
#ifdef HAVE_ROUTE_METRIC
unsigned int rt_metric;
#endif
+#ifdef HAVE_ROUTE_PREF
+ int rt_pref;
+#endif
+#define RTPREF_HIGH 1
+#define RTPREF_MEDIUM 0 /* has to be zero */
+#define RTPREF_LOW (-1)
+#define RTPREF_RESERVED (-2)
+#define RTPREF_INVALID (-3) /* internal */
unsigned int rt_dflags;
#define RTDF_IFA_ROUTE 0x02 /* Address generated route */
#define RTDF_FAKE 0x04 /* Maybe us on lease reboot */