Skip to contentSkip to conversation

pppd: bugfixes and enhancements

PATCH New Gustavo Zacarias 2 participants 9 messages Oct 20, 2011 – Oct 21, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 pppd: bugfixes and enhancements

Fix exponential timeout bug for PPPoE.
Fix undefined (0.0.0.0) default gateway issue.
Add adaptive LCP echo patch and gateway metric functionality.

---
 package/pppd/pppd-2.4.5-defaultgateway.patch       |   95 ++++++++++++++++
 package/pppd/pppd-2.4.5-defaultmetric.patch        |  115 ++++++++++++++++++++
 package/pppd/pppd-2.4.5-lcp-echo-adaptive.patch    |   64 +++++++++++
 .../pppd/pppd-2.4.5-no-exponential-timeout.patch   |   28 +++++
 4 files changed, 302 insertions(+), 0 deletions(-)
 create mode 100644 package/pppd/pppd-2.4.5-defaultgateway.patch
 create mode 100644 package/pppd/pppd-2.4.5-defaultmetric.patch
 create mode 100644 package/pppd/pppd-2.4.5-lcp-echo-adaptive.patch
 create mode 100644 package/pppd/pppd-2.4.5-no-exponential-timeout.patch
package/pppd/pppd-2.4.5-defaultgateway.patch new file +95 -0
new file mode 100644
index 0000000..8a4f621
@@ -0,0 +1,95 @@
+This patch reverses revision 1.114 of the pppd/sys-linux.c file.
+The default gateway is needed by the openswan's %defaultroute.
+
+Obtained from gentoo patchset.
+
+Signed-off-by: Gustavo Zacarias <[email protected]>
+
+diff -Nur ppp-2.4.5.orig/pppd/sys-linux.c ppp-2.4.5/pppd/sys-linux.c
+--- ppp-2.4.5.orig/pppd/sys-linux.c	2010-08-08 09:44:29.000000000 +0200
++++ ppp-2.4.5/pppd/sys-linux.c	2010-08-08 09:53:02.000000000 +0200
+@@ -209,7 +209,7 @@
+ static unsigned char inbuf[512]; /* buffer for chars read from loopback */
+ 
+ static int	if_is_up;	/* Interface has been marked up */
+-static int	have_default_route;	/* Gateway for default route added */
++static u_int32_t default_route_gateway;	/* Gateway for default route added */
+ static u_int32_t proxy_arp_addr;	/* Addr for proxy arp entry added */
+ static char proxy_arp_dev[16];		/* Device for proxy arp entry */
+ static u_int32_t our_old_addr;		/* for detecting address changes */
+@@ -346,8 +346,8 @@
+ /*
+  * Delete any routes through the device.
+  */
+-    if (have_default_route)
+-	cifdefaultroute(0, 0, 0);
++    if (default_route_gateway != 0)
++	cifdefaultroute(0, 0, default_route_gateway);
+ 
+     if (has_proxy_arp)
+ 	cifproxyarp(0, proxy_arp_addr);
+@@ -1639,17 +1639,17 @@
+     struct rtentry rt;
+ 
+     if (defaultroute_exists(&rt) && 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));
+-	else
+-	    error("not replacing existing default route through %s",
+-		  rt.rt_dev);
++	u_int32_t old_gateway = SIN_ADDR(rt.rt_gateway);
++
++	if (old_gateway != gateway)
++	    error("not replacing existing default route to %s [%I]",
++		  rt.rt_dev, old_gateway);
+ 	return 0;
+     }
+ 
+-    memset (&rt, 0, sizeof (rt));
+-    SET_SA_FAMILY (rt.rt_dst, AF_INET);
++    memset (&rt, '\0', sizeof (rt));
++    SET_SA_FAMILY (rt.rt_dst,     AF_INET);
++    SET_SA_FAMILY (rt.rt_gateway, AF_INET);
+ 
+     rt.rt_dev = ifname;
+ 
+@@ -1658,14 +1658,16 @@
+ 	SIN_ADDR(rt.rt_genmask) = 0L;
+     }
+ 
+-    rt.rt_flags = RTF_UP;
++    SIN_ADDR(rt.rt_gateway) = gateway;
++
++    rt.rt_flags = RTF_UP | RTF_GATEWAY;
+     if (ioctl(sock_fd, SIOCADDRT, &rt) < 0) {
+ 	if ( ! ok_error ( errno ))
+ 	    error("default route ioctl(SIOCADDRT): %m");
+ 	return 0;
+     }
+ 
+-    have_default_route = 1;
++    default_route_gateway = gateway;
+     return 1;
+ }
+ 
+@@ -1678,7 +1680,7 @@
+ {
+     struct rtentry rt;
+ 
+-    have_default_route = 0;
++    default_route_gateway = 0;
+ 
+     memset (&rt, '\0', sizeof (rt));
+     SET_SA_FAMILY (rt.rt_dst,     AF_INET);
+@@ -1691,7 +1693,9 @@
+ 	SIN_ADDR(rt.rt_genmask) = 0L;
+     }
+ 
+-    rt.rt_flags = RTF_UP;
++    SIN_ADDR(rt.rt_gateway) = gateway;
++
++    rt.rt_flags = RTF_UP | RTF_GATEWAY;
+     if (ioctl(sock_fd, SIOCDELRT, &rt) < 0 && errno != ESRCH) {
+ 	if (still_ppp()) {
+ 	    if ( ! ok_error ( errno ))
package/pppd/pppd-2.4.5-defaultmetric.patch new file +115 -0

115 lines not on this page · raw message

package/pppd/pppd-2.4.5-lcp-echo-adaptive.patch new file +64 -0

64 lines not on this page · raw message

package/pppd/pppd-2.4.5-no-exponential-timeout.patch new file +28 -0
new file mode 100644
index 0000000..431f7bf
@@ -0,0 +1,28 @@
+Fix exponential timeout bug for PPPoE.
+
+Obtained from OpenWRT svn.
+
+Signed-off-by: Gustavo Zacarias <[email protected]>
+
+--- a/pppd/plugins/rp-pppoe/discovery.c
++++ b/pppd/plugins/rp-pppoe/discovery.c
+@@ -548,7 +548,9 @@ discovery(PPPoEConnection *conn)
+ 	conn->discoveryState = STATE_SENT_PADI;
+ 	waitForPADO(conn, timeout);
+ 
++#if 0
+ 	timeout *= 2;
++#endif
+     } while (conn->discoveryState == STATE_SENT_PADI);
+ 
+     timeout = conn->discoveryTimeout;
+@@ -563,7 +565,9 @@ discovery(PPPoEConnection *conn)
+ 	sendPADR(conn);
+ 	conn->discoveryState = STATE_SENT_PADR;
+ 	waitForPADS(conn, timeout);
++#if 0
+ 	timeout *= 2;
++#endif
+     } while (conn->discoveryState == STATE_SENT_PADR);
+ 
+     /* We're done. */
Signature · 1 line
1.7.3.4
#1 lore raw

PATCH 2/4 ocf: new package

Add the ocf package and kernel extension.

---
 linux/Config.ext.in    |    7 +++++++
 linux/linux-ext-ocf.mk |   21 +++++++++++++++++++++
 package/Config.in      |    1 +
 package/ocf/Config.in  |    9 +++++++++
 package/ocf/ocf.mk     |   30 ++++++++++++++++++++++++++++++
 5 files changed, 68 insertions(+), 0 deletions(-)
 create mode 100644 linux/linux-ext-ocf.mk
 create mode 100644 package/ocf/Config.in
 create mode 100644 package/ocf/ocf.mk
linux/Config.ext.in +7 -0
index 8a9f87e..dd26399 100644
@@ -15,6 +15,13 @@ config BR2_LINUX_KERNEL_EXT_XENOMAI_ADEOS_PATCH
 	  Download it at http://download.gna.org/adeos/patches/v2.6/$(ARCH)/
 	  and verify that your kernel version in buildroot matches.
 
+# OCF
+config BR2_LINUX_KERNEL_EXT_OCF
+	bool "Open Cryptographic Framework (OCF)"
+	select BR2_PACKAGE_OCF
+	help
+	  OCF Kernel part.
+
 # RTAI
 config BR2_LINUX_KERNEL_EXT_RTAI
        bool "RTAI Real-time patch"
linux/linux-ext-ocf.mk new file +21 -0
new file mode 100644
index 0000000..d31d77d
@@ -0,0 +1,21 @@
+##################################################
+# Linux OCF extension
+#
+# Patch the linux kernel with OCF
+##################################################
+
+ifeq ($(BR2_LINUX_KERNEL_EXT_OCF),y)
+LINUX_DEPENDENCIES += ocf
+
+# Prepare kernel patch
+# The linux-2.6.38.patch is just the main inclusion, most of the code
+# resides in the ocf/ subdir.
+define OCF_PREPARE_KERNEL
+	support/scripts/apply-patches.sh $(LINUX_DIR) \
+		$(OCF_DIR)/patches/ linux-2.6.38-ocf.patch ; \
+	cp -rf $(OCF_DIR)/ocf $(LINUX_DIR)/crypto/ocf ;
+endef
+
+LINUX_PRE_PATCH_HOOKS += OCF_PREPARE_KERNEL
+
+endif #BR2_LINUX_EXT_OCF
package/Config.in +1 -0
index 3cd724c..4943909 100644
@@ -258,6 +258,7 @@ source "package/gnutls/Config.in"
 source "package/libgcrypt/Config.in"
 source "package/libgpg-error/Config.in"
 source "package/libnss/Config.in"
+source "package/ocf/Config.in"
 source "package/openssl/Config.in"
 endmenu
 
package/ocf/Config.in new file +9 -0
new file mode 100644
index 0000000..2033cda
@@ -0,0 +1,9 @@
+config BR2_PACKAGE_OCF
+	bool "ocf"
+	help
+	  OCF-Linux is a Linux port of the OpenBSD/FreeBSD Cryptographic
+	  Framework (OCF). This port aims to bring full asynchronous HW/SW
+	  crypto acceleration to the Linux kernel and applications
+	  running under Linux.
+	  
+	  http://ocf-linux.sourceforge.net/
package/ocf/ocf.mk new file +30 -0
new file mode 100644
index 0000000..1ba01cf
@@ -0,0 +1,30 @@
+#############################################################
+#
+# ocf
+#
+#############################################################
+
+OCF_VERSION = 20110720
+OCF_SITE = http://$(BR2_SOURCEFORGE_MIRROR).dl.sourceforge.net/sourceforge/ocf-linux
+OCF_SOURCE = ocf-linux-$(OCF_VERSION).tar.gz
+OCF_INSTALL_STAGING = YES
+
+define OCF_INSTALL_STAGING_CMDS
+	$(INSTALL) -D -m 644 $(@D)/ocf/cryptodev.h \
+		$(STAGING_DIR)/usr/include/crypto/cryptodev.h
+endef
+
+define OCF_UNINSTALL_STAGING_CMDS
+	rm -f $(STAGING_DIR)/usr/include/crypto/cryptodev.h
+endef
+
+define OCF_INSTALL_TARGET_CMDS
+	$(INSTALL) -D -m 644 $(@D)/ocf/cryptodev.h \
+		$(TARGET_DIR)/usr/include/crypto/cryptodev.h
+endef
+
+define OCF_UNINSTALL_TARGET_CMDS
+	rm -f $(TARGET_DIR)/usr/include/crypto/cryptodev.h
+endef
+
+$(eval $(call GENTARGETS))
Signature · 1 line
1.7.3.4
#2 lore raw

PATCH 2/4 ocf: new package

Le Thu, 20 Oct 2011 14:48:51 -0300,
Gustavo Zacarias <[email protected]> a ?crit :

package/ocf/Config.in line 9

Quoted 9 lines
package/ocf/Config.in new file +9 -0
+config BR2_PACKAGE_OCF
+	bool "ocf"
+	help
+	  OCF-Linux is a Linux port of the OpenBSD/FreeBSD Cryptographic
+	  Framework (OCF). This port aims to bring full asynchronous HW/SW
+	  crypto acceleration to the Linux kernel and applications
+	  running under Linux.
+	  
+	  http://ocf-linux.sourceforge.net/

Maybe mention here that there is a kernel-side part that must be enabled for this to work, and that it can be enabled with BR2_LINUX_KERNEL_EXT_OCF ?

Quoted 7 lines
package/ocf/ocf.mk new file +7 -0
+define OCF_INSTALL_STAGING_CMDS
+	$(INSTALL) -D -m 644 $(@D)/ocf/cryptodev.h \
+		$(STAGING_DIR)/usr/include/crypto/cryptodev.h
+endef
+
+define OCF_UNINSTALL_STAGING_CMDS
+	rm -f $(STAGING_DIR)/usr/include/crypto/cryptodev.h

package/ocf/ocf.mk line 28

Quoted 10 lines
package/ocf/ocf.mk new file +10 -0
+endef
+
+define OCF_INSTALL_TARGET_CMDS
+	$(INSTALL) -D -m 644 $(@D)/ocf/cryptodev.h \
+		$(TARGET_DIR)/usr/include/crypto/cryptodev.h
+endef
+
+define OCF_UNINSTALL_TARGET_CMDS
+	rm -f $(TARGET_DIR)/usr/include/crypto/cryptodev.h
+endef

So basically, it's just a header that needs to be installed?

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#3 lore raw

PATCH 2/4 ocf: new package

Quoted 16 lines · Thomas Petazzoni

Le Thu, 20 Oct 2011 14:48:51 -0300,
Gustavo Zacarias <[email protected]> a ?crit :

package/ocf/Config.in line 9

Quoted 9 lines
package/ocf/Config.in new file +9 -0
+config BR2_PACKAGE_OCF
+	bool "ocf"
+	help
+	  OCF-Linux is a Linux port of the OpenBSD/FreeBSD Cryptographic
+	  Framework (OCF). This port aims to bring full asynchronous HW/SW
+	  crypto acceleration to the Linux kernel and applications
+	  running under Linux.
+
+	  http://ocf-linux.sourceforge.net/

Maybe mention here that there is a kernel-side part that must be enabled for this to work, and that it can be enabled with BR2_LINUX_KERNEL_EXT_OCF ?

Fair enough, though it won't break anything if it's enabled and you lack OCF support on the kernel side.
Similar to what would happen if you don't load the appropiate modules or lack hardware support.

Quoted 3 lines

So basically, it's just a header that needs to be installed?

Thomas

Yes.
For the moment we've got OpenSSL and maybe Openswan that uses OCF. Of course anything that links to OpenSSL uses OCF when it's properly enabled on supporting hardware.

Regards.

#4 lore raw

PATCH 2/4 ocf: new package

Le Fri, 21 Oct 2011 07:33:12 -0300,
Gustavo Zacarias <[email protected]> a ?crit :

Quoted 4 lines

Fair enough, though it won't break anything if it's enabled and you lack OCF support on the kernel side.
Similar to what would happen if you don't load the appropiate modules or lack hardware support.

Yeah, it's not a hard dependency, just a documentation comment on how to take advantage of it.

Quoted 8 lines
Quoted 3 lines

So basically, it's just a header that needs to be installed?

Thomas

Yes.
For the moment we've got OpenSSL and maybe Openswan that uses OCF. Of course anything that links to OpenSSL uses OCF when it's properly enabled on supporting hardware.

Ok, thanks!

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#5 lore raw

PATCH 3/4 openssl: split out ocf

In reply to Gustavo Zacarias

Ditch OCF and switch to the proper package.

---
 package/openssl/Config.in                |    1 +
 package/openssl/ocf-cryptodev-20101223.h |  480 ------------------------------
 package/openssl/openssl.mk               |   10 +-
 3 files changed, 3 insertions(+), 488 deletions(-)
 delete mode 100644 package/openssl/ocf-cryptodev-20101223.h
package/openssl/Config.in +1 -0
index 3e09d88..0240603 100644
@@ -25,6 +25,7 @@ config BR2_PACKAGE_OPENSSL_ENGINES
 config BR2_PACKAGE_OPENSSL_OCF
 	bool "openssl ocf support"
 	depends on BR2_PACKAGE_OPENSSL
+	select BR2_PACKAGE_OCF
 	help
 	  Enable openssl cryptodev (OCF) hardware acceleration support.
 	  This requires kernel patches from the ocf-linux project otherwise
package/openssl/ocf-cryptodev-20101223.h deleted +0 -480

480 lines not on this page · raw message

package/openssl/openssl.mk +2 -8
index 51a00dd..526a5dd 100644
@@ -12,14 +12,8 @@ OPENSSL_TARGET_ARCH = generic32
 OPENSSL_CFLAGS = $(TARGET_CFLAGS)
 
 ifeq ($(BR2_PACKAGE_OPENSSL_OCF),y)
-OPENSSL_CFLAGS += -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS
-
-define OPENSSL_INSTALL_CRYPTODEV_H
-$(INSTALL) -D package/openssl/ocf-cryptodev-20101223.h \
-	$(STAGING_DIR)/usr/include/crypto/cryptodev.h
-endef
-
-OPENSSL_POST_EXTRACT_HOOKS += OPENSSL_INSTALL_CRYPTODEV_H
+	OPENSSL_CFLAGS += -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS
+	OPENSSL_DEPENDENCIES += ocf
 endif
 
 # Some architectures are optimized in OpenSSL
Signature · 1 line
1.7.3.4
#6 lore raw

PATCH 4/4 openswan: new package

In reply to Gustavo Zacarias
---
 package/Config.in            |    1 +
 package/openswan/Config.in   |    8 ++++++++
 package/openswan/openswan.mk |   35 +++++++++++++++++++++++++++++++++++
 3 files changed, 44 insertions(+), 0 deletions(-)
 create mode 100644 package/openswan/Config.in
 create mode 100644 package/openswan/openswan.mk
package/Config.in +1 -0
index 4943909..aeec8bd 100644
@@ -456,6 +456,7 @@ source "package/nuttcp/Config.in"
 source "package/olsr/Config.in"
 source "package/openntpd/Config.in"
 source "package/openssh/Config.in"
+source "package/openswan/Config.in"
 source "package/openvpn/Config.in"
 source "package/portmap/Config.in"
 source "package/pppd/Config.in"
package/openswan/Config.in new file +8 -0
new file mode 100644
index 0000000..3336156
@@ -0,0 +1,8 @@
+config BR2_PACKAGE_OPENSWAN
+	bool "openswan"
+	select BR2_PACKAGE_GMP
+	select BR2_PACKAGE_IPROUTE2
+	help
+	  Openswan is an implementation of IPsec for Linux
+
+	  http://www.openswan.org
package/openswan/openswan.mk new file +35 -0
new file mode 100644
index 0000000..dbd2557
@@ -0,0 +1,35 @@
+#############################################################
+#
+# openswan
+#
+#############################################################
+
+OPENSWAN_VERSION = 2.6.36
+OPENSWAN_SITE = http://www.openswan.org/download
+OPENSWAN_DEPENDENCIES = host-bison gmp iproute2
+OPENSWAN_MAKEOPT = ARCH=$(BR2_ARCH) CC="$(TARGET_CC)" \
+	USERCOMPILE="$(TARGET_CFLAGS)" INC_USRLOCAL=/usr \
+	USE_KLIPS=false USE_MAST=false USE_NM=false
+
+ifeq ($(BR2_PACKAGE_LIBCURL),y)
+	OPENSWAN_DEPENDENCIES = libcurl
+	OPENSWAN_MAKEOPT += USE_LIBCURL=true
+endif
+
+ifeq ($(BR2_PACKAGE_OPENSSL),y)
+	OPENSWAN_DEPENDENCIES += openssl
+	OPENSWAN_MAKEOPT += HAVE_OPENSSL=true
+ifeq ($(BR2_PACKAGE_OPENSSL_OCF),y)
+	OPENSWAN_MAKEOPT += HAVE_OCF=true
+endif
+endif
+
+define OPENSWAN_BUILD_CMDS
+	$(MAKE) -C $(@D) $(OPENSWAN_MAKEOPT) programs
+endef
+
+define OPENSWAN_INSTALL_TARGET_CMDS
+	$(MAKE) -C $(@D) $(OPENSWAN_MAKEOPT) DESTDIR=$(TARGET_DIR) install
+endef
+
+$(eval $(call GENTARGETS))
Signature · 1 line
1.7.3.4
#7 lore raw

PATCH 1/4 pppd: bugfixes and enhancements

In reply to Gustavo Zacarias

Le Thu, 20 Oct 2011 14:48:50 -0300,
Gustavo Zacarias <[email protected]> a ?crit :

Quoted 5 lines

Fix exponential timeout bug for PPPoE.
Fix undefined (0.0.0.0) default gateway issue.
Add adaptive LCP echo patch and gateway metric functionality.

Have those patches been submitted upstream ? We really don't want to start accumulating too many non-build related patches, such as bug fixes or feature additions.

Thanks!

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#8 lore raw

PATCH 1/4 pppd: bugfixes and enhancements

Quoted 7 lines · Thomas Petazzoni

Have those patches been submitted upstream ? We really don't want to start accumulating too many non-build related patches, such as bug fixes or feature additions.

Thanks!

Thomas

Yes.
Debian and OpenWRT have some of them too (not quite exactly the same but they do the same).
It's pretty likely that the default gateway patch won't be merged upstream from what i've read, the argument being somewhat in the lines of desktop security versus embedded and siding with the first. However it's pretty much required for openswan to work correctly or we'd have to do some very nasty scripts to deal with it (openswan not working out of the box).
Regards.