aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/ppp/APKBUILD14
-rw-r--r--main/ppp/defaultroute-metric.3.patch129
2 files changed, 142 insertions, 1 deletions
diff --git a/main/ppp/APKBUILD b/main/ppp/APKBUILD
index c3907106ca..162d6da0f9 100644
--- a/main/ppp/APKBUILD
+++ b/main/ppp/APKBUILD
@@ -1,7 +1,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=ppp
pkgver=2.4.5
-pkgrel=6
+pkgrel=7
pkgdesc="A daemon which implements the PPP protocol for dial-up networking"
url="http://www.samba.org/ppp/"
arch="all"
@@ -10,6 +10,7 @@ depends=
makedepends="libpcap-dev"
subpackages="$pkgname-dev $pkgname-doc"
source="ftp://ftp.samba.org/pub/$pkgname/$pkgname-$pkgver.tar.gz
+ defaultroute-metric.3.patch
options
pon
poff
@@ -19,6 +20,16 @@ source="ftp://ftp.samba.org/pub/$pkgname/$pkgname-$pkgver.tar.gz
ip-down"
_builddir="$srcdir"/$pkgname-$pkgver
+prepare() {
+ local i
+ cd "$_builddir"
+ for i in $source; do
+ case $i in
+ *.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
+ esac
+ done
+}
+
build () {
cd "$_builddir"
@@ -58,6 +69,7 @@ package() {
mkdir -p "$pkgdir"/etc/ppp/peers
}
md5sums="4621bc56167b6953ec4071043fe0ec57 ppp-2.4.5.tar.gz
+e26f807a61490fedbc9a7632caebd973 defaultroute-metric.3.patch
9185f645bb433b22a9951d9d12f79c35 options
48c024f73a80c8b69c4def22f86902cc pon
2d811f8470ccdea3b8c4505a438483e9 poff
diff --git a/main/ppp/defaultroute-metric.3.patch b/main/ppp/defaultroute-metric.3.patch
new file mode 100644
index 0000000000..2eee724c23
--- /dev/null
+++ b/main/ppp/defaultroute-metric.3.patch
@@ -0,0 +1,129 @@
+Default route metric
+
+Define the metric of the default route and only add it if there
+is no other default route with the same metric. With the default
+value of -1, the route is only added if there is no default route
+at all.
+
+Olivier Mehani <olivier.mehani@nicta.com.au>
+Index: ppp-2.4.4/pppd/options.c
+===================================================================
+--- ppp-2.4.4.orig/pppd/options.c 2006-06-18 21:26:00.000000000 +1000
++++ ppp-2.4.4/pppd/options.c 2010-04-22 17:08:38.000000000 +1000
+@@ -119,6 +119,7 @@
+ bool dryrun; /* print out option values and exit */
+ char *domain; /* domain name set by domain option */
+ int child_wait = 5; /* # seconds to wait for children at exit */
++int dfl_route_metric = -1; /* metric of the default route to set over the PPP link */
+
+ #ifdef MAXOCTETS
+ unsigned int maxoctets = 0; /* default - no limit */
+@@ -281,6 +282,10 @@
+ "Number of seconds to wait for child processes at exit",
+ OPT_PRIO },
+
++ { "defaultroute-metric", o_int, &dfl_route_metric,
++ "Metric to use for the default route (Linux only; -1 for default behavior)",
++ OPT_PRIV|OPT_LLIMIT|OPT_INITONLY, NULL, 0, -1 },
++
+ #ifdef HAVE_MULTILINK
+ { "multilink", o_bool, &multilink,
+ "Enable multilink operation", OPT_PRIO | 1 },
+Index: ppp-2.4.4/pppd/sys-linux.c
+===================================================================
+--- ppp-2.4.4.orig/pppd/sys-linux.c 2005-08-27 08:44:35.000000000 +1000
++++ ppp-2.4.4/pppd/sys-linux.c 2010-04-22 17:09:44.000000000 +1000
+@@ -232,7 +232,7 @@
+ static void close_route_table (void);
+ static int open_route_table (void);
+ static int read_route_table (struct rtentry *rt);
+-static int defaultroute_exists (struct rtentry *rt);
++static int defaultroute_exists (struct rtentry *rt, int metric);
+ static int get_ether_addr (u_int32_t ipaddr, struct sockaddr *hwaddr,
+ char *name, int namelen);
+ static void decode_version (char *buf, int *version, int *mod, int *patch);
+@@ -242,6 +242,8 @@
+
+ extern u_char inpacket_buf[]; /* borrowed from main.c */
+
++extern int dfl_route_metric;
++
+ /*
+ * SET_SA_FAMILY - set the sa_family field of a struct sockaddr,
+ * if it exists.
+@@ -1526,9 +1528,10 @@
+ /********************************************************************
+ *
+ * defaultroute_exists - determine if there is a default route
++ * with the given metric (or negative for any)
+ */
+
+-static int defaultroute_exists (struct rtentry *rt)
++static int defaultroute_exists (struct rtentry *rt, int metric)
+ {
+ int result = 0;
+
+@@ -1541,7 +1544,8 @@
+
+ if (kernel_version > KVERSION(2,1,0) && SIN_ADDR(rt->rt_genmask) != 0)
+ continue;
+- if (SIN_ADDR(rt->rt_dst) == 0L) {
++ if (SIN_ADDR(rt->rt_dst) == 0L && (metric < 0 ||
++ (metric >= 0 && (rt->rt_metric + 1) == metric))) {
+ result = 1;
+ break;
+ }
+@@ -1588,13 +1592,13 @@
+ {
+ struct rtentry rt;
+
+- if (defaultroute_exists(&rt) && strcmp(rt.rt_dev, ifname) != 0) {
++ 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",
+- SIN_ADDR(rt.rt_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",
+- rt.rt_dev);
++ error("not replacing existing default route through %s with metric %d",
++ rt.rt_dev, dfl_route_metric);
+ return 0;
+ }
+
+@@ -1602,6 +1606,7 @@
+ SET_SA_FAMILY (rt.rt_dst, AF_INET);
+
+ rt.rt_dev = ifname;
++ rt.rt_metric = dfl_route_metric + 1; /* +1 for binary compatibility */
+
+ if (kernel_version > KVERSION(2,1,0)) {
+ SET_SA_FAMILY (rt.rt_genmask, AF_INET);
+@@ -1634,6 +1639,9 @@
+ SET_SA_FAMILY (rt.rt_dst, AF_INET);
+ SET_SA_FAMILY (rt.rt_gateway, AF_INET);
+
++ rt.rt_dev = ifname;
++ rt.rt_metric = dfl_route_metric + 1; /* +1 for binary compatibility */
++
+ if (kernel_version > KVERSION(2,1,0)) {
+ SET_SA_FAMILY (rt.rt_genmask, AF_INET);
+ SIN_ADDR(rt.rt_genmask) = 0L;
+Index: ppp-2.4.4/pppd/pppd.8
+===================================================================
+--- ppp-2.4.4.orig/pppd/pppd.8 2006-06-16 10:01:23.000000000 +1000
++++ ppp-2.4.4/pppd/pppd.8 2010-04-22 17:08:38.000000000 +1000
+@@ -121,6 +121,12 @@
+ This entry is removed when the PPP connection is broken. This option
+ is privileged if the \fInodefaultroute\fR option has been specified.
+ .TP
++.B defaultroute-metric
++Define the metric of the \fIdefaultroute\fR and only add it if there
++is no other default route with the same metric. With the default
++value of -1, the route is only added if there is no default route at
++all.
++.TP
+ .B disconnect \fIscript
+ Execute the command specified by \fIscript\fR, by passing it to a
+ shell, after