[systemd-devel] [PATCH] networkd: drop routes when lease expires
Tom Gundersen
teg at jklm.no
Thu Apr 3 07:00:56 PDT 2014
Applied. Thanks!
Cheers,
Tom
On Tue, Apr 1, 2014 at 10:55 PM, Umut Tezduyar Lindskog
<umut.tezduyar at axis.com> wrote:
> ---
> src/network/networkd-link.c | 22 ++++++++++++++++++++++
> 1 file changed, 22 insertions(+)
>
> diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
> index 973755a..4e0fe0a 100644
> --- a/src/network/networkd-link.c
> +++ b/src/network/networkd-link.c
> @@ -579,8 +579,11 @@ static int link_set_mtu(Link *link, uint32_t mtu) {
>
> static int dhcp_lease_lost(Link *link) {
> _cleanup_address_free_ Address *address = NULL;
> + _cleanup_route_free_ Route *route_gw = NULL;
> + _cleanup_route_free_ Route *route = NULL;
> struct in_addr addr;
> struct in_addr netmask;
> + struct in_addr gateway;
> unsigned prefixlen;
> int r;
>
> @@ -593,8 +596,27 @@ static int dhcp_lease_lost(Link *link) {
> if (r >= 0) {
> sd_dhcp_lease_get_address(link->dhcp_lease, &addr);
> sd_dhcp_lease_get_netmask(link->dhcp_lease, &netmask);
> + sd_dhcp_lease_get_router(link->dhcp_lease, &gateway);
> prefixlen = net_netmask_to_prefixlen(&netmask);
>
> + r = route_new_dynamic(&route_gw);
> + if (r >= 0) {
> + route_gw->family = AF_INET;
> + route_gw->dst_addr.in = gateway;
> + route_gw->dst_prefixlen = 32;
> + route_gw->scope = RT_SCOPE_LINK;
> +
> + route_drop(route_gw, link, &route_drop_handler);
> + }
> +
> + r = route_new_dynamic(&route);
> + if (r >= 0) {
> + route->family = AF_INET;
> + route->in_addr.in = gateway;
> +
> + route_drop(route, link, &route_drop_handler);
> + }
> +
> address->family = AF_INET;
> address->in_addr.in = addr;
> address->prefixlen = prefixlen;
> --
> 1.7.10.4
>
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel
More information about the systemd-devel
mailing list