ndisc: ignore addresses with preferred lifetime larger than lifetime

Previously, we would coerce the value so that preferred is the same
as lifetime. However, RFC4862 5.5.3.c) says:

  c)  If the preferred lifetime is greater than the valid lifetime,
    silently ignore the Prefix Information option.  A node MAY wish to
    log a system management error in this case.

See-also: https://tools.ietf.org/search/rfc4862#section-5.5.3
This commit is contained in:
Thomas Haller 2018-10-11 13:22:08 +02:00
parent 02958bba80
commit 43c3c259c8
2 changed files with 5 additions and 4 deletions

View file

@ -221,10 +221,10 @@ receive_ra (struct ndp *ndp, struct ndp_msg *msg, gpointer user_data)
.preferred = ndp_msg_opt_prefix_preferred_time (msg, offset),
};
if (address.preferred > address.lifetime)
address.preferred = address.lifetime;
if (nm_ndisc_complete_and_add_address (ndisc, &address))
changed |= NM_NDISC_CONFIG_ADDRESSES;
if (address.preferred <= address.lifetime) {
if (nm_ndisc_complete_and_add_address (ndisc, &address))
changed |= NM_NDISC_CONFIG_ADDRESSES;
}
}
}
ndp_msg_opt_for_each_offset(offset, msg, NDP_MSG_OPT_ROUTE) {

View file

@ -416,6 +416,7 @@ nm_ndisc_add_address (NMNDisc *ndisc, const NMNDiscAddress *new)
nm_assert (new->timestamp > 0 && new->timestamp < G_MAXINT32);
nm_assert (!IN6_IS_ADDR_UNSPECIFIED (&new->address));
nm_assert (!IN6_IS_ADDR_LINKLOCAL (&new->address));
nm_assert (new->preferred <= new->lifetime);
for (i = 0; i < rdata->addresses->len; i++) {
NMNDiscAddress *item = &g_array_index (rdata->addresses, NMNDiscAddress, i);