rdisc,device: set MTU if an appropriate option is present in a RA

https://bugzilla.gnome.org/show_bug.cgi?id=738104

Reported-by: Charles R. Anderson <cra@wpi.edu>
This commit is contained in:
Lubomir Rintel 2014-10-09 12:06:53 +02:00 committed by Thomas Haller
parent 810dc260ef
commit 7d57793004
3 changed files with 24 additions and 0 deletions

View file

@ -3663,6 +3663,13 @@ rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, NMDevice *self)
nm_device_ipv6_sysctl_set (self, "hop_limit", val);
}
if (changed & NM_RDISC_CONFIG_MTU) {
char val[16];
g_snprintf (val, sizeof (val), "%d", rdisc->mtu);
nm_device_ipv6_sysctl_set (self, "mtu", val);
}
nm_device_activate_schedule_ip6_config_result (self);
}

View file

@ -621,6 +621,21 @@ receive_ra (struct ndp *ndp, struct ndp_msg *msg, gpointer user_data)
changed |= NM_RDISC_CONFIG_HOP_LIMIT;
}
/* MTU */
ndp_msg_opt_for_each_offset(offset, msg, NDP_MSG_OPT_MTU) {
guint32 mtu = ndp_msg_opt_mtu(msg, offset);
if (mtu >= 1280) {
rdisc->mtu = mtu;
changed |= NM_RDISC_CONFIG_MTU;
} else {
/* All sorts of bad things would happen if we accepted this.
* Kernel would set it, but would flush out all IPv6 addresses away
* from the link, even the link-local, and we wouldn't be able to
* listen for further RAs that could fix the MTU. */
warning ("(%s): MTU too small for IPv6 ignored: %d", rdisc->ifname, mtu);
}
}
check_timestamps (rdisc, now, changed);
return 0;

View file

@ -95,6 +95,7 @@ typedef enum {
NM_RDISC_CONFIG_DNS_SERVERS = 1 << 4,
NM_RDISC_CONFIG_DNS_DOMAINS = 1 << 5,
NM_RDISC_CONFIG_HOP_LIMIT = 1 << 6,
NM_RDISC_CONFIG_MTU = 1 << 7,
} NMRDiscConfigMap;
#define NM_RDISC_MAX_ADDRESSES_DEFAULT 16
@ -125,6 +126,7 @@ typedef struct {
GArray *dns_servers;
GArray *dns_domains;
int hop_limit;
guint32 mtu;
} NMRDisc;
typedef struct {