summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2015-04-10 13:52:00 +0200
committerSteven Barth <steven@midlink.org>2015-04-10 13:52:00 +0200
commite23972527f93a3d2a5412400384519ff550708b7 (patch)
treede695a9029e4784ace97d017fbf0b36458cd96c5
parent9bdbc5a4be1ab75145431bc728159a55c723e2ca (diff)
downloadodhcpd-e23972527f93a3d2a5412400384519ff550708b7.tar.gz
ra: always send current hop limit
-rw-r--r--src/odhcpd.c8
-rw-r--r--src/odhcpd.h2
-rw-r--r--src/router.c11
3 files changed, 12 insertions, 9 deletions
diff --git a/src/odhcpd.c b/src/odhcpd.c
index 52bca13..aad5b37 100644
--- a/src/odhcpd.c
+++ b/src/odhcpd.c
@@ -113,11 +113,11 @@ int odhcpd_open_rtnl(void)
// Read IPv6 MTU for interface
-int odhcpd_get_interface_mtu(const char *ifname)
+int odhcpd_get_interface_config(const char *ifname, const char *what)
{
char buf[64];
- const char *sysctl_pattern = "/proc/sys/net/ipv6/conf/%s/mtu";
- snprintf(buf, sizeof(buf), sysctl_pattern, ifname);
+ const char *sysctl_pattern = "/proc/sys/net/ipv6/conf/%s/%s";
+ snprintf(buf, sizeof(buf), sysctl_pattern, ifname, what);
int fd = open(buf, O_RDONLY);
ssize_t len = read(fd, buf, sizeof(buf) - 1);
@@ -126,10 +126,8 @@ int odhcpd_get_interface_mtu(const char *ifname)
if (len < 0)
return -1;
-
buf[len] = 0;
return atoi(buf);
-
}
diff --git a/src/odhcpd.h b/src/odhcpd.h
index 21dc99f..5944661 100644
--- a/src/odhcpd.h
+++ b/src/odhcpd.h
@@ -186,7 +186,7 @@ ssize_t odhcpd_get_interface_addresses(int ifindex,
struct odhcpd_ipaddr *addrs, size_t cnt);
int odhcpd_get_preferred_interface_address(int ifindex, struct in6_addr *addr);
struct interface* odhcpd_get_interface_by_name(const char *name);
-int odhcpd_get_interface_mtu(const char *ifname);
+int odhcpd_get_interface_config(const char *ifname, const char *what);
int odhcpd_get_mac(const struct interface *iface, uint8_t mac[6]);
struct interface* odhcpd_get_interface_by_index(int ifindex);
struct interface* odhcpd_get_master_interface(void);
diff --git a/src/router.c b/src/router.c
index 60d6b3f..f942d8f 100644
--- a/src/router.c
+++ b/src/router.c
@@ -209,9 +209,11 @@ static bool parse_routes(struct odhcpd_ipaddr *n, ssize_t len)
// Router Advert server mode
static uint64_t send_router_advert(struct interface *iface, const struct in6_addr *from)
{
- int mtu = odhcpd_get_interface_mtu(iface->ifname);
- if (mtu < 0)
- mtu = 1500;
+ int mtu = odhcpd_get_interface_config(iface->ifname, "mtu");
+ int hlim = odhcpd_get_interface_config(iface->ifname, "hop_limit");
+
+ if (mtu < 1280)
+ mtu = 1280;
struct {
struct nd_router_advert h;
@@ -224,6 +226,9 @@ static uint64_t send_router_advert(struct interface *iface, const struct in6_add
.mtu = {ND_OPT_MTU, 1, 0, htonl(mtu)},
};
+ if (hlim > 0)
+ adv.h.nd_ra_curhoplimit = hlim;
+
if (iface->dhcpv6)
adv.h.nd_ra_flags_reserved = ND_RA_FLAG_OTHER;