ra_default integer 0 Override default route
0: default, 1: ignore no public address, 2: ignore all
-ra_management integer 1 RA management mode
- 0: no M-Flag but A-Flag, 1: both M and A, 2: M but not A
+ra_flags list other-config List of RA flags to be
+ advertised in RA messages
+ [managed-config other-config home-agent none]
+ra_slaac bool 1 Announce slaac for a prefix
ra_offlink bool 0 Announce prefixes off-link
ra_preference string medium Route(r) preference
[medium|high|low]
IFACE_ATTR_DHCPV6_PD,
IFACE_ATTR_DHCPV6_NA,
IFACE_ATTR_RA_DEFAULT,
- IFACE_ATTR_RA_MANAGEMENT,
+ IFACE_ATTR_RA_FLAGS,
+ IFACE_ATTR_RA_SLAAC,
IFACE_ATTR_RA_OFFLINK,
IFACE_ATTR_RA_PREFERENCE,
IFACE_ATTR_RA_ADVROUTER,
[IFACE_ATTR_PD_MANAGER] = { .name = "pd_manager", .type = BLOBMSG_TYPE_STRING },
[IFACE_ATTR_PD_CER] = { .name = "pd_cer", .type = BLOBMSG_TYPE_STRING },
[IFACE_ATTR_RA_DEFAULT] = { .name = "ra_default", .type = BLOBMSG_TYPE_INT32 },
- [IFACE_ATTR_RA_MANAGEMENT] = { .name = "ra_management", .type = BLOBMSG_TYPE_INT32 },
+ [IFACE_ATTR_RA_FLAGS] = { .name = "ra_flags", . type = BLOBMSG_TYPE_ARRAY },
+ [IFACE_ATTR_RA_SLAAC] = { .name = "ra_slaac", .type = BLOBMSG_TYPE_BOOL },
[IFACE_ATTR_RA_OFFLINK] = { .name = "ra_offlink", .type = BLOBMSG_TYPE_BOOL },
[IFACE_ATTR_RA_PREFERENCE] = { .name = "ra_preference", .type = BLOBMSG_TYPE_STRING },
[IFACE_ATTR_RA_ADVROUTER] = { .name = "ra_advrouter", .type = BLOBMSG_TYPE_BOOL },
.params = odhcpd_attrs,
};
+static const struct { const char *name; uint8_t flag; } ra_flags[] = {
+ { .name = "managed-config", .flag = ND_RA_FLAG_MANAGED },
+ { .name = "other-config", .flag = ND_RA_FLAG_OTHER },
+ { .name = "home-agent", .flag = ND_RA_FLAG_HOME_AGENT },
+ { .name = "none", . flag = 0 },
+ { .name = NULL, },
+};
+
static int mkdir_p(char *dir, mode_t mask)
{
char *l = strrchr(dir, '/');
iface->dhcpv6_assignall = true;
iface->dhcpv6_pd = true;
iface->dhcpv6_na = true;
- iface->ra_managed = RA_MANAGED_MFLAG;
+ iface->ra_flags = ND_RA_FLAG_OTHER;
+ iface->ra_slaac = true;
iface->ra_maxinterval = 600;
iface->ra_mininterval = iface->ra_maxinterval/3;
iface->ra_lifetime = -1;
return -1;
}
+static int parse_ra_flags(uint8_t *flags, struct blob_attr *attr)
+{
+ struct blob_attr *cur;
+ unsigned rem;
+
+ blobmsg_for_each_attr(cur, attr, rem) {
+ int i;
+
+ if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING)
+ continue;
+
+ if (!blobmsg_check_attr(cur, false))
+ continue;
+
+ for (i = 0; ra_flags[i].name; i++) {
+ if (!strcmp(ra_flags[i].name, blobmsg_get_string(cur))) {
+ *flags |= ra_flags[i].flag;
+ break;
+ }
+ }
+
+ if (!ra_flags[i].name)
+ return -1;
+ }
+
+ return 0;
+}
+
static void set_config(struct uci_section *s)
{
struct blob_attr *tb[ODHCPD_ATTR_MAX], *c;
if ((c = tb[IFACE_ATTR_RA_DEFAULT]))
iface->default_router = blobmsg_get_u32(c);
- if ((c = tb[IFACE_ATTR_RA_MANAGEMENT]))
- iface->ra_managed = blobmsg_get_u32(c);
+ if ((c = tb[IFACE_ATTR_RA_FLAGS])) {
+ iface->ra_flags = 0;
+ if (parse_ra_flags(&iface->ra_flags, c) < 0)
+ goto err;
+ }
if ((c = tb[IFACE_ATTR_RA_REACHABLETIME])) {
uint32_t ra_reachabletime = blobmsg_get_u32(c);
iface->ra_mtu = ra_mtu;
}
+ if ((c = tb[IFACE_ATTR_RA_SLAAC]))
+ iface->ra_slaac = blobmsg_get_bool(c);
+
if ((c = tb[IFACE_ATTR_RA_OFFLINK]))
iface->ra_not_onlink = blobmsg_get_bool(c);
if (hlim > 0)
adv.h.nd_ra_curhoplimit = hlim;
- if (iface->dhcpv6 != MODE_DISABLED) {
- adv.h.nd_ra_flags_reserved = ND_RA_FLAG_OTHER;
-
- if (iface->ra_managed >= RA_MANAGED_MFLAG)
- adv.h.nd_ra_flags_reserved |= ND_RA_FLAG_MANAGED;
- }
+ adv.h.nd_ra_flags_reserved = iface->ra_flags;
if (iface->route_preference < 0)
adv.h.nd_ra_flags_reserved |= ND_RA_PREF_LOW;
p->nd_opt_pi_flags_reserved = 0;
if (!iface->ra_not_onlink)
p->nd_opt_pi_flags_reserved |= ND_OPT_PI_FLAG_ONLINK;
- if (iface->ra_managed < RA_MANAGED_NO_AFLAG && addr->prefix <= 64)
+ if (iface->ra_slaac && addr->prefix <= 64)
p->nd_opt_pi_flags_reserved |= ND_OPT_PI_FLAG_AUTO;
if (iface->ra_advrouter)
p->nd_opt_pi_flags_reserved |= ND_OPT_PI_FLAG_RADDR;