diff options
author | Thomas Haller <thaller@redhat.com> | 2018-10-11 13:22:08 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-10-13 17:11:52 +0200 |
commit | 43c3c259c8e2fd4aa5416b79efd47a72cca790ec (patch) | |
tree | 30fa4ab14116759e923f9ece869886d6cf6b6c56 | |
parent | 02958bba80d7b9c1701f657c75a08c81e243f83b (diff) | |
download | NetworkManager-43c3c259c8e2fd4aa5416b79efd47a72cca790ec.tar.gz |
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
-rw-r--r-- | src/ndisc/nm-lndp-ndisc.c | 8 | ||||
-rw-r--r-- | src/ndisc/nm-ndisc.c | 1 |
2 files changed, 5 insertions, 4 deletions
diff --git a/src/ndisc/nm-lndp-ndisc.c b/src/ndisc/nm-lndp-ndisc.c index 8bb1812764..48a17bdf4f 100644 --- a/src/ndisc/nm-lndp-ndisc.c +++ b/src/ndisc/nm-lndp-ndisc.c @@ -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) { diff --git a/src/ndisc/nm-ndisc.c b/src/ndisc/nm-ndisc.c index a6b4453891..9c80c0ec15 100644 --- a/src/ndisc/nm-ndisc.c +++ b/src/ndisc/nm-ndisc.c @@ -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); |