All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ppp: Add support for setting ifname in ppp options
@ 2020-07-14 15:04 Mark Deneen
  2020-07-14 15:14 ` [OE-core] " Quentin Schulz
  2020-07-14 15:32 ` ✗ patchtest: failure for " Patchwork
  0 siblings, 2 replies; 4+ messages in thread
From: Mark Deneen @ 2020-07-14 15:04 UTC (permalink / raw)
  To: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 468 bytes --]

pppd is patched in most Linux distributions to allow arbitrary naming
of ppp interfaces, allowing users to create consistent firewall rules
rather than having interfaces named "ppp0", "ppp1", etc.  Yocto is
missing this option.

This patch, originally from SUSE, adds this option to pppd. It is not
included upstream because there are some pppd-supported platforms which
lack the ability to rename interfaces.

Signed-off-by: Mark Deneen <mdeneen@gmail.com>

[-- Attachment #2: 0001-allow-setting-ifname-in-ppp-config-options-patch-ori.patch --]
[-- Type: text/x-patch, Size: 7483 bytes --]

From bec9545448a2ae8ce4bdf4738f38734f44643aa6 Mon Sep 17 00:00:00 2001
From: Mark Deneen <mdeneen@gmail.com>
Date: Tue, 14 Jul 2020 10:41:41 -0400
Subject: [PATCH] allow setting ifname in ppp config options, patch originally
 from SUSE.

---
 .../ppp/ppp/0002-pppd-add-ifname-option.patch | 182 ++++++++++++++++++
 meta/recipes-connectivity/ppp/ppp_2.4.8.bb    |   1 +
 2 files changed, 183 insertions(+)
 create mode 100644 meta/recipes-connectivity/ppp/ppp/0002-pppd-add-ifname-option.patch

diff --git a/meta/recipes-connectivity/ppp/ppp/0002-pppd-add-ifname-option.patch b/meta/recipes-connectivity/ppp/ppp/0002-pppd-add-ifname-option.patch
new file mode 100644
index 0000000000..29e50cb949
--- /dev/null
+++ b/meta/recipes-connectivity/ppp/ppp/0002-pppd-add-ifname-option.patch
@@ -0,0 +1,182 @@
+diff --git a/pppd/main.c b/pppd/main.c
+index 6d50d1b..f1986ed 100644
+--- a/pppd/main.c
++++ b/pppd/main.c
+@@ -124,7 +124,7 @@
+ static const char rcsid[] = RCSID;
+ 
+ /* interface vars */
+-char ifname[32];		/* Interface name */
++char ifname[MAXIFNAMELEN];	/* Interface name */
+ int ifunit;			/* Interface unit number */
+ 
+ struct channel *the_channel;
+@@ -298,13 +298,6 @@ struct protent *protocols[] = {
+     NULL
+ };
+ 
+-/*
+- * If PPP_DRV_NAME is not defined, use the default "ppp" as the device name.
+- */
+-#if !defined(PPP_DRV_NAME)
+-#define PPP_DRV_NAME	"ppp"
+-#endif /* !defined(PPP_DRV_NAME) */
+-
+ int
+ main(argc, argv)
+     int argc;
+@@ -737,8 +730,11 @@ void
+ set_ifunit(iskey)
+     int iskey;
+ {
+-    info("Using interface %s%d", PPP_DRV_NAME, ifunit);
+-    slprintf(ifname, sizeof(ifname), "%s%d", PPP_DRV_NAME, ifunit);
++    if (req_ifname[0] != '\0')
++	slprintf(ifname, sizeof(ifname), "%s", req_ifname);
++    else
++	slprintf(ifname, sizeof(ifname), "%s%d", PPP_DRV_NAME, ifunit);
++    info("Using interface %s", ifname);
+     script_setenv("IFNAME", ifname, iskey);
+     if (iskey) {
+ 	create_pidfile(getpid());	/* write pid to file */
+diff --git a/pppd/options.c b/pppd/options.c
+index f66b765..91da515 100644
+--- a/pppd/options.c
++++ b/pppd/options.c
+@@ -114,6 +114,7 @@ char	linkname[MAXPATHLEN];	/* logical name for link */
+ bool	tune_kernel;		/* may alter kernel settings */
+ int	connect_delay = 1000;	/* wait this many ms after connect script */
+ int	req_unit = -1;		/* requested interface unit */
++char	req_ifname[MAXIFNAMELEN];	/* requested interface name */
+ bool	multilink = 0;		/* Enable multilink operation */
+ char	*bundle_name = NULL;	/* bundle name for multilink */
+ bool	dump_options;		/* print out option values */
+@@ -283,6 +284,10 @@ option_t general_options[] = {
+       "PPP interface unit number to use if possible",
+       OPT_PRIO | OPT_LLIMIT, 0, 0 },
+ 
++    { "ifname", o_string, req_ifname,
++      "Set PPP interface name",
++      OPT_PRIO | OPT_PRIV | OPT_STATIC, NULL, MAXIFNAMELEN },
++
+     { "dump", o_bool, &dump_options,
+       "Print out option values after parsing all options", 1 },
+     { "dryrun", o_bool, &dryrun,
+diff --git a/pppd/pppd.8 b/pppd/pppd.8
+index c8b595d..0acd493 100644
+--- a/pppd/pppd.8
++++ b/pppd/pppd.8
+@@ -1085,7 +1085,13 @@ under Linux and FreeBSD 2.2.8 and later.
+ .TP
+ .B unit \fInum
+ Sets the ppp unit number (for a ppp0 or ppp1 etc interface name) for outbound
+-connections.
++connections.  If the unit is already in use a dynamically allocated number will
++be used.
++.TP
++.B ifname \fIstring
++Set the ppp interface name for outbound connections.  If the interface name is
++already in use, or if the name cannot be used for any other reason, pppd will
++terminate.
+ .TP
+ .B unset \fIname
+ Remove a variable from the environment variable for scripts that are
+diff --git a/pppd/pppd.h b/pppd/pppd.h
+index 8ade4d8..7495df6 100644
+--- a/pppd/pppd.h
++++ b/pppd/pppd.h
+@@ -80,6 +80,16 @@
+ #define MAXARGS		1	/* max # args to a command */
+ #define MAXNAMELEN	256	/* max length of hostname or name for auth */
+ #define MAXSECRETLEN	256	/* max length of password or secret */
++#define MAXIFNAMELEN	32	/* max length of interface name; or use IFNAMSIZ, can we
++				   always include net/if.h? */
++
++/*
++ * If PPP_DRV_NAME is not defined, use the default "ppp" as the device name.
++ * Where should PPP_DRV_NAME come from? Do we include it here?
++ */
++#if !defined(PPP_DRV_NAME)
++#define PPP_DRV_NAME	"ppp"
++#endif /* !defined(PPP_DRV_NAME) */
+ 
+ /*
+  * Option descriptor structure.
+@@ -318,6 +328,7 @@ extern bool	tune_kernel;	/* May alter kernel settings as necessary */
+ extern int	connect_delay;	/* Time to delay after connect script */
+ extern int	max_data_rate;	/* max bytes/sec through charshunt */
+ extern int	req_unit;	/* interface unit number to use */
++extern char	req_ifname[MAXIFNAMELEN]; /* interface name to use */
+ extern bool	multilink;	/* enable multilink operation */
+ extern bool	noendpoint;	/* don't send or accept endpt. discrim. */
+ extern char	*bundle_name;	/* bundle name for multilink */
+diff --git a/pppd/sys-linux.c b/pppd/sys-linux.c
+index a105505..85dbb0b 100644
+--- a/pppd/sys-linux.c
++++ b/pppd/sys-linux.c
+@@ -643,6 +643,21 @@ static int make_ppp_unit()
+ 	}
+ 	if (x < 0)
+ 		error("Couldn't create new ppp unit: %m");
++
++	if (x == 0 && req_ifname[0] != '\0') {
++		struct ifreq ifr;
++		char t[MAXIFNAMELEN];
++		memset(&ifr, 0, sizeof(struct ifreq));
++		slprintf(t, sizeof(t), "%s%d", PPP_DRV_NAME, ifunit);
++		strncpy(ifr.ifr_name, t, IF_NAMESIZE);
++		strncpy(ifr.ifr_newname, req_ifname, IF_NAMESIZE);
++		x = ioctl(sock_fd, SIOCSIFNAME, &ifr);
++		if (x < 0)
++		    error("Couldn't rename interface %s to %s: %m", t, req_ifname);
++		else
++		    info("Renamed interface %s to %s", t, req_ifname);
++	}
++
+ 	return x;
+ }
+ 
+diff --git a/pppstats/pppstats.c b/pppstats/pppstats.c
+index 6367988..46cb9c2 100644
+--- a/pppstats/pppstats.c
++++ b/pppstats/pppstats.c
+@@ -88,7 +88,6 @@ int	aflag;			/* print absolute values, not deltas */
+ int	dflag;			/* print data rates, not bytes */
+ int	interval, count;
+ int	infinite;
+-int	unit;
+ int	s;			/* socket or /dev/ppp file descriptor */
+ int	signalled;		/* set if alarm goes off "early" */
+ char	*progname;
+@@ -449,6 +448,7 @@ main(argc, argv)
+ {
+     int c;
+ #ifdef STREAMS
++    int unit;
+     char *dev;
+ #endif
+ 
+@@ -506,11 +506,6 @@ main(argc, argv)
+     if (argc > 0)
+ 	interface = argv[0];
+ 
+-    if (sscanf(interface, PPP_DRV_NAME "%d", &unit) != 1) {
+-	fprintf(stderr, "%s: invalid interface '%s' specified\n",
+-		progname, interface);
+-    }
+-
+ #ifndef STREAMS
+     {
+ 	struct ifreq ifr;
+@@ -535,6 +530,11 @@ main(argc, argv)
+     }
+ 
+ #else	/* STREAMS */
++    if (sscanf(interface, PPP_DRV_NAME "%d", &unit) != 1) {
++	fprintf(stderr, "%s: invalid interface '%s' specified\n",
++		progname, interface);
++    }
++
+ #ifdef __osf__
+     dev = "/dev/streams/ppp";
+ #else
diff --git a/meta/recipes-connectivity/ppp/ppp_2.4.8.bb b/meta/recipes-connectivity/ppp/ppp_2.4.8.bb
index f9c60d6bad..231c40f6ca 100644
--- a/meta/recipes-connectivity/ppp/ppp_2.4.8.bb
+++ b/meta/recipes-connectivity/ppp/ppp_2.4.8.bb
@@ -30,6 +30,7 @@ SRC_URI = "https://download.samba.org/pub/${BPN}/${BP}.tar.gz \
            file://fix-CVE-2015-3310.patch \
            file://0001-ppp-Remove-unneeded-include.patch \
            file://0001-pppd-Fix-bounds-check-in-EAP-code.patch \
+           file://0002-pppd-add-ifname-option.patch \
            "
 
 SRC_URI_append_libc-musl = "\
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [OE-core] [PATCH] ppp: Add support for setting ifname in ppp options
  2020-07-14 15:04 [PATCH] ppp: Add support for setting ifname in ppp options Mark Deneen
@ 2020-07-14 15:14 ` Quentin Schulz
  2020-07-14 15:36   ` Mark Deneen
  2020-07-14 15:32 ` ✗ patchtest: failure for " Patchwork
  1 sibling, 1 reply; 4+ messages in thread
From: Quentin Schulz @ 2020-07-14 15:14 UTC (permalink / raw)
  To: Mark Deneen; +Cc: openembedded-core

Hi Mark,

On Tue, Jul 14, 2020 at 11:04:41AM -0400, Mark Deneen wrote:
> pppd is patched in most Linux distributions to allow arbitrary naming
> of ppp interfaces, allowing users to create consistent firewall rules
> rather than having interfaces named "ppp0", "ppp1", etc.  Yocto is
> missing this option.
> 
> This patch, originally from SUSE, adds this option to pppd. It is not
> included upstream because there are some pppd-supported platforms which
> lack the ability to rename interfaces.
> 
> Signed-off-by: Mark Deneen <mdeneen@gmail.com>

Please follow guidelines from:
https://www.openembedded.org/wiki/How_to_submit_a_patch_to_OpenEmbedded
to know how to contribute in a way that is matching OE patch management.

Your mail content should probably be the content of the commit log. Your
mail should directly be the output of git format-patch (send it with
git send-email), the patch shouldn't be attached to the mail but rather
"be" the mail.

On the content of the patch, it'd be nice to take the patch with the
authors, commit title and log from the original place where you took it
from.

It probably is:
https://sources.debian.org/patches/ppp/2.4.6-3.1/ppp-2.4.2-ifname.diff/
?

No author, no commit log :/ Though, I could find
https://sources.debian.org/patches/ppp/2.4.6-3.1/ppp-2.4.2-ifname.diff/
which is slightly different and the changelog seems decent between
Suse's and debian's patch.

Thanks,
Quentin

^ permalink raw reply	[flat|nested] 4+ messages in thread

* ✗ patchtest: failure for ppp: Add support for setting ifname in ppp options
  2020-07-14 15:04 [PATCH] ppp: Add support for setting ifname in ppp options Mark Deneen
  2020-07-14 15:14 ` [OE-core] " Quentin Schulz
@ 2020-07-14 15:32 ` Patchwork
  1 sibling, 0 replies; 4+ messages in thread
From: Patchwork @ 2020-07-14 15:32 UTC (permalink / raw)
  To: Mark Deneen; +Cc: openembedded-core

== Series Details ==

Series: ppp: Add support for setting ifname in ppp options
Revision: 1
URL   : https://patchwork.openembedded.org/series/25130/
State : failure

== Summary ==


Thank you for submitting this patch series to OpenEmbedded Core. This is
an automated response. Several tests have been executed on the proposed
series by patchtest resulting in the following failures:



* Issue             A patch file has been added, but does not have a Signed-off-by tag [test_signed_off_by_presence] 
  Suggested fix    Sign off the added patch file (meta/recipes-connectivity/ppp/ppp/0002-pppd-add-ifname-option.patch)

* Issue             Added patch file is missing Upstream-Status in the header [test_upstream_status_presence_format] 
  Suggested fix    Add Upstream-Status: <Valid status> to the header of meta/recipes-connectivity/ppp/ppp/0002-pppd-add-ifname-option.patch
  Standard format  Upstream-Status: <Valid status>
  Valid status     Pending, Accepted, Backport, Denied, Inappropriate [reason], Submitted [where]



If you believe any of these test results are incorrect, please reply to the
mailing list (openembedded-core@lists.openembedded.org) raising your concerns.
Otherwise we would appreciate you correcting the issues and submitting a new
version of the patchset if applicable. Please ensure you add/increment the
version number when sending the new version (i.e. [PATCH] -> [PATCH v2] ->
[PATCH v3] -> ...).

---
Guidelines:     https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines
Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest
Test suite:     http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [OE-core] [PATCH] ppp: Add support for setting ifname in ppp options
  2020-07-14 15:14 ` [OE-core] " Quentin Schulz
@ 2020-07-14 15:36   ` Mark Deneen
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Deneen @ 2020-07-14 15:36 UTC (permalink / raw)
  To: Quentin Schulz; +Cc: openembedded-core

Quentin,

Thanks for the feedback, and I will resend this.  I started off with a
patch which contained the original authors, but that was lost in the
process of applying the patch, since it is a patch of a patch.  I was
attempting to avoid patch fuzzing, since it had previously been
applied to pppd 2.4.8.  Is a small amount of fuzz acceptable?

-M

On Tue, Jul 14, 2020 at 11:14 AM Quentin Schulz
<quentin.schulz@streamunlimited.com> wrote:
>
> Hi Mark,
>
> On Tue, Jul 14, 2020 at 11:04:41AM -0400, Mark Deneen wrote:
> > pppd is patched in most Linux distributions to allow arbitrary naming
> > of ppp interfaces, allowing users to create consistent firewall rules
> > rather than having interfaces named "ppp0", "ppp1", etc.  Yocto is
> > missing this option.
> >
> > This patch, originally from SUSE, adds this option to pppd. It is not
> > included upstream because there are some pppd-supported platforms which
> > lack the ability to rename interfaces.
> >
> > Signed-off-by: Mark Deneen <mdeneen@gmail.com>
>
> Please follow guidelines from:
> https://www.openembedded.org/wiki/How_to_submit_a_patch_to_OpenEmbedded
> to know how to contribute in a way that is matching OE patch management.
>
> Your mail content should probably be the content of the commit log. Your
> mail should directly be the output of git format-patch (send it with
> git send-email), the patch shouldn't be attached to the mail but rather
> "be" the mail.
>
> On the content of the patch, it'd be nice to take the patch with the
> authors, commit title and log from the original place where you took it
> from.
>
> It probably is:
> https://sources.debian.org/patches/ppp/2.4.6-3.1/ppp-2.4.2-ifname.diff/
> ?
>
> No author, no commit log :/ Though, I could find
> https://sources.debian.org/patches/ppp/2.4.6-3.1/ppp-2.4.2-ifname.diff/
> which is slightly different and the changelog seems decent between
> Suse's and debian's patch.
>
> Thanks,
> Quentin

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-07-14 15:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-14 15:04 [PATCH] ppp: Add support for setting ifname in ppp options Mark Deneen
2020-07-14 15:14 ` [OE-core] " Quentin Schulz
2020-07-14 15:36   ` Mark Deneen
2020-07-14 15:32 ` ✗ patchtest: failure for " Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.