From 40c707632d0e7871bfdbaff22f70aaf18dace97a Mon Sep 17 00:00:00 2001 From: Brandon Philips Date: Thu, 20 Mar 2014 11:34:54 -0700 Subject: [PATCH] fix(sys-apps/systemd): explicitly route to the gateway Fix sent and pending upstream. --- ...reate-explicit-host-route-to-gateway.patch | 66 +++++++++++++++++++ .../sys-apps/systemd/systemd-211-r4.ebuild | 3 +- 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/files/0001-network-dhcp-create-explicit-host-route-to-gateway.patch diff --git a/sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/files/0001-network-dhcp-create-explicit-host-route-to-gateway.patch b/sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/files/0001-network-dhcp-create-explicit-host-route-to-gateway.patch new file mode 100644 index 0000000000..e1427e11fb --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/files/0001-network-dhcp-create-explicit-host-route-to-gateway.patch @@ -0,0 +1,66 @@ +From 2b1ce33baa29bddf5367c0bcfcfb884e36641cc7 Mon Sep 17 00:00:00 2001 +From: Brandon Philips +Date: Thu, 20 Mar 2014 11:28:12 -0700 +Subject: [PATCH] network: dhcp: create explicit host route to gateway + +Some DHCP servers gives you a netmask of 255.255.255.255 so the gateway is not +routable. Other DHCP client implementations look through the existing routes to +figure out if they should add an explicit host route. See below for a link. + +However, it makes sense to just create the route explicitly whether it is +needed or not since it is explicit, makes the dhcp route entries independent of +other entries and saves us from knowing the state of the kernel tables. + +The code from dhcpcd that works around this issue is on line 637. +https://android.googlesource.com/platform/external/dhcpcd/+/master/configure.c +--- + src/network/networkd-link.c | 26 ++++++++++++++++++++++++++ + 1 file changed, 26 insertions(+) + +diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c +index 275ad97..8077ac7 100644 +--- a/src/network/networkd-link.c ++++ b/src/network/networkd-link.c +@@ -237,6 +237,8 @@ static int link_enter_set_routes(Link *link) { + + if (link->dhcp_lease) { + _cleanup_route_free_ Route *route = NULL; ++ _cleanup_route_free_ Route *route_gw = NULL; ++ struct in_addr netmask; + struct in_addr gateway; + + r = sd_dhcp_lease_get_router(link->dhcp_lease, &gateway); +@@ -253,6 +255,30 @@ static int link_enter_set_routes(Link *link) { + return r; + } + ++ r = route_new_dynamic(&route_gw); ++ if (r < 0) { ++ log_error_link(link, "Could not allocate route: %s", ++ strerror(-r)); ++ return r; ++ } ++ ++ /* The dhcp netmask may mask out the gateway. Add an explicit ++ * route for the gw host so that we can route no matter the ++ * netmask or existing kernel route tables. */ ++ route_gw->family = AF_INET; ++ route_gw->dst_addr.in = gateway; ++ route_gw->dst_prefixlen = 32; ++ route_gw->scope = RT_SCOPE_LINK; ++ ++ r = route_configure(route_gw, link, &route_handler); ++ if (r < 0) { ++ log_warning_link(link, ++ "could not set host route: %s", strerror(-r)); ++ return r; ++ } ++ ++ link->route_messages ++; ++ + route->family = AF_INET; + route->in_addr.in = gateway; + +-- +1.8.5.2 (Apple Git-48) + diff --git a/sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/systemd-211-r4.ebuild b/sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/systemd-211-r4.ebuild index 95a03f535c..5679ca4513 100644 --- a/sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/systemd-211-r4.ebuild +++ b/sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/systemd-211-r4.ebuild @@ -132,8 +132,9 @@ src_prepare() { # dns feature for more than one server epatch "${FILESDIR}"/211-networkd-allow-more-than-one-static-dns-server.patch - # patch to fix dhcp on gce + # patches to fix dhcp on gce epatch "${FILESDIR}"/211-0001-sd-dhcp-client-accept-infinite-lease-lifetime.patch + epatch "${FILESDIR}"/0001-network-dhcp-create-explicit-host-route-to-gateway.patch if [[ ${PV} == *9999 ]]; then if use doc; then