X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Fsys-linux.c;h=c0955a05b9a89dbd60afe4e51821df9473646a38;hb=HEAD;hp=561b150f2950a59777925303455a283dee174d27;hpb=ba7f7e053daae846a54a1d08d3d133a5f1266ace;p=ppp.git diff --git a/pppd/sys-linux.c b/pppd/sys-linux.c index 561b150..b94f3ec 100644 --- a/pppd/sys-linux.c +++ b/pppd/sys-linux.c @@ -2,7 +2,7 @@ * sys-linux.c - System-dependent procedures for setting up * PPP interfaces on Linux systems * - * Copyright (c) 1994-2004 Paul Mackerras. All rights reserved. + * Copyright (c) 1994-2024 Paul Mackerras. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -11,14 +11,10 @@ * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - * 2. The name(s) of the authors of this software must not be used to - * endorse or promote products derived from this software without - * prior written permission. - * - * 3. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by Paul Mackerras - * ". + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY @@ -131,16 +127,6 @@ #include #include #include - -/* Attempt at retaining compile-support with older than 4.7 kernels, or kernels - * where RTM_NEWSTATS isn't defined for whatever reason. - */ -#ifndef RTM_NEWSTATS -#define RTM_NEWSTATS 92 -#define RTM_GETSTATS 94 -#define IFLA_STATS_LINK_64 1 -#endif - #include /* glibc versions prior to 2.24 do not define SOL_NETLINK */ @@ -1776,6 +1762,7 @@ get_ppp_stats_ioctl(int u, struct pppd_stats *stats) static int get_ppp_stats_rtnetlink(int u, struct pppd_stats *stats) { +#ifdef RTM_NEWSTATS static int fd = -1; struct { @@ -1825,6 +1812,7 @@ get_ppp_stats_rtnetlink(int u, struct pppd_stats *stats) err: close(fd); fd = -1; +#endif return 0; } @@ -2201,11 +2189,27 @@ int sifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway, bool replac * - this is normally only the case the doing demand: */ if (defaultroute_exists(&tmp_rt, -1)) del_rt = &tmp_rt; + } else if (!replace) { + /* + * We don't want to replace an existing route. + * We may however add our route along an existing route with a different + * metric. + */ + if (defaultroute_exists(&rt, dfl_route_metric) && strcmp(rt.rt_dev, ifname) != 0) { + if (rt.rt_flags & RTF_GATEWAY) + error("not replacing existing default route via %I with metric %d", + SIN_ADDR(rt.rt_gateway), dfl_route_metric); + else + error("not replacing existing default route through %s with metric %d", + rt.rt_dev, dfl_route_metric); + return 0; + } } else if (defaultroute_exists(&old_def_rt, -1 ) && strcmp( old_def_rt.rt_dev, ifname) != 0) { /* - * We did not yet replace an existing default route, let's - * check if we should save and replace a default route: + * We want to replace an existing route and did not replace an existing + * default route yet, let's check if we should save and replace an + * existing default route: */ u_int32_t old_gateway = SIN_ADDR(old_def_rt.rt_gateway); @@ -2271,8 +2275,6 @@ int cifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway) SET_SA_FAMILY (rt.rt_dst, AF_INET); SET_SA_FAMILY (rt.rt_gateway, AF_INET); - rt.rt_dev = ifname; - rt.rt_dev = ifname; rt.rt_metric = dfl_route_metric + 1; /* +1 for binary compatibility */