-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
We should avoid code duplication between rp-pppoe and this project #383
Comments
Sounds like a good idea; how do you suggest we go about it? |
Just my thoughts: rp-pppoe I believe was the original implementation. MOST users will never need the servers, the bridge mechanisms and most of the other tools provided by the rp-pppoe package, only the pppoe module as per current available in ppp. From a perspective of "if rp-pppoe requires additional options in pppoe.so module" it makes sense for me to package the ppp module with rp-pppoe. I do, however, think that unlikely. The way I would go personally if this was up to me and I controlled both packages (I'm not responsible for either, but believe I've got insight into both) is to put the pppoe module in ppp package as it's more involved with the ppp internals than pppoe-server (for example). Further to this, rp-pppoe (and specifically pppoe-server) cannot stand without ppp (even if the module is I don't know if there is much sense to keep the pppoe userspace implementation around any more. One other option which may be considered but which has a bit higher administrative overhead is a git submodule for the pppoe.so file ppp module specifically which can be imported into both projects (even though rp-pppoe cannot stand without ppp), or just an outright separate repository for that. |
I think that rp-pppoe can be in the "ppp-project" organization near ppp. |
I think the first step should be to examine how the C source files have diverged between the ppp project and upstream rp-pppoe and reconcile those divergences. Once that's done, we can look at what functions in the common C files are needed by both the PPPoE client and server software and try to minimize those. One example is I'm not sure if it makes sense to have a library in the ppp project against which the pppoe-server links, or just duplicate the common code if there's only a small amount of it. My personal preference would be to remove all the PPPoE stuff from the ppp project and just keep it in rp-pppoe, but I don't think that's going to fly :) I also don't think moving all of rp-pppoe under the ppp project makes sense; the server code is really different from everything else. But anyway... resolving the divergence of the source should be the first step. |
Oh, and I'm OK with getting rid of the userspace PPPoE code, but that means it's irrevocably tied to Linux. I know at some point, user-mode rp-pppoe used to work on BSD and even Solaris, but I suspect that has long bit-rotted. |
ppp itself doesn't work on BSD any more, but it does on Solaris. I accidentally tested user-mode and it works, but most likely won't perform as well, so until it breaks proper I suggest keeping it is probably the best option. Could you also please clarify what you mean with "I'm not sure if it makes sense to have a library in the ppp project against which the pppoe-server links" - do you mean to say there is code that goes into both the pppoe module (ie, the ppp plugin) as well as the other pppoe-* binaries? This seems to be accurate upon actually looking into more detail, specifically the discovery portion of the pppoe plugin, and specifically parsePacket() seems to relate. This is a reasonably simple function from the looks of it, the rest of the common.c file looks mostly distinct functions. discovery.c at least has diverged quite far. And here are the interesting commits:
The first change after these were then on the last day of 2020 in order to rename from rp-pppoe to pppoe, and then there were a bunch of changes. Unfortunately I don't have full VCS history for the current rp-pppoe version, so can't really comment if much has happened on that front? |
Yes; I meant having a library in the ppp project that contains the functions common to pppoe-server and the pppoe plugin. As you say, there are not many of them and they are pretty simple, so maybe duplicating those is not a big deal. Probably would be a good idea to split common.c into two files... one that contains functions only used by the client and one that contains functions also used by the server. As I may have mentioned, I can't make the full PPPoE git history available because in the past I worked on some proprietary code for a customer, and that's in the git history. :( |
When I speak about "ppp-project" is to have the code here: https://github.com/ppp-project/rp-pppoe. https://github.com/ppp-project/ppp and https://github.com/ppp-project/rp-pppoe are two repositories at a same place to improve the code... @dfskoll: Since I have proposed you to put the code on GitHub, new contributions have been done... |
What is the advantage of having under ppp-project rather than under dfskoll? It seems like the only difference is who controls the project, and at this point, I prefer to keep control. |
I think @dfskoll is right in that the first step is to review the code differences between the two. And then perhaps if possible consolidation of said code. I don't think there should be any difference between these two, and that kernel mode vs user-mode is really just a feature of said plugin (dependent on how you chose to configure and compile it). Second to that, I am not a big fan of putting the code of (rp-)pppoe directly in the code tree of pppd. It's a bit of a cluster ** with automake/autoconf and having to generate multiple config.h files. It feels like the pppoe plugin (as well as several other plugins) should be standalone projects. Perhaps under the ppp-project umbrella, or some other entity. Typically, any project can create and distribute a plugin for pppd, but I think the (rp-)pppoe module is different in that it can be used for both client and server. And people who would like to use this as a client, is not interested in the server piece of it. Establishing a repository in ppp-project/rp-ppope-plugin or something similar would require
Also, it should be possible with packaging of rp-pppoe project to configure a dependency on the rp-pppoe-plugin being installed. Ultimately, I don't think maintaining two repositories for rp-pppoe-plugin (or forking @dfskoll is a nice thing) is inherently difficult. It also confuses users, issue tracking, maintenance, etc. |
@Neustradamus if you / Paul were to make a https://github.com/ppp-project/rp-pppoe-plugin (doesn't exist yet), would it be possible to assign "ownership" of the project (or joint ownership) to @dfskoll Note the name difference here, just saying rp-pppoe implies the entire project from @dfskoll. I think it somehow should be named with "plugin" somehow to make distinction that it only provides the plugin. |
@dfskoll is rp-pppoe (server) and utilities distributed as a package per Debian or Ubuntu? If not, you should probably file a intent to package or request to package for this software with Debian and cook up a package recipe for this. |
The Debian package is called See https://packages.debian.org/bullseye/amd64/pppoe/filelist It does not include the pppoe.so plugin, which is part of the ppp package: |
Yeah, I just found it by So rp-pppoe.so file (which supports kernel mode?) isn't distributed on Debian? |
It is, but in the |
So users like @jkroonza needs to go out of their way to get rp-pppoe sources and compile the plugin? Yeah, I see that by the control file require ppp >= 2.3.10-1. |
I think they can use the plugin that's included with |
Yeah, I am curious now. I was under the impression it had to do with performance... |
The plugin included with |
I did cleanup of pppoe.so plugin in ppp repository, removed and changed code better fit in ppp repository. I'm not sure if such changes are useful / suitable for rp-pppoe server project. Other changes are mostly fixups for the client code. As jkroonza said, most users do not need server part of pppoe. I think that rp-pppoe server code should work with pppoe.so plugin from ppp repository. So what about putting all client code with pppoe.so plugin into ppp project and all server code (without pppoe.so plugin) into rp-pppoe? Or is there is too many common code which makes sense to somehow share between ppp and rp-pppoe projects? |
That's what I'm getting at. You changed the pppoe.so code. But so did I, upstream, independently. We should try to merge the code together because some of the upstream changes might be good to have in ppp/plugins/pppoe. Eventually, when the changes are merged, I guess it makes sense to have all of the plugin code live only in the ppp project, and have rp-pppoe concentrate on supplying the server and relay implementations. To the extent that there's common code between the rp-pppoe server and the pppoe plugin, there will be code duplication. I have to look and see how much duplicated code there really is. |
One of the things I remember being fixed in the ppp/pppoe version is compiler warnings (that still exist in the rp-pppoe project when compiling with the plugin). And yes, I do recall @pali fixing a bunch of things there as well. My two cents is that there should be only one single source of the truth, and it should be able to handle server and client mode, user and kernel mode version in the same plugin. Also, I would love to see a wiki enabled on the GitHub project with some documentation to how to configure either of these. |
And yes, there will be some duplication of code. That's just a fact when you split a project in two. |
I don't see any compiler warnings with the latest rp-pppoe git HEAD. This is on Debian 11.
No warnings with just a plain |
This maybe because I am on a different distribution than what you are running. Currently, I am on a Ubuntu Cloud / Minimal (uvt-kvm create) using Ubuntu 22.04 Jammy Jellyfish, install gcc and build-essentials and I have the following (using git repository). I don't have such warnings in the logs when compiling pppd project.
|
Ugh, wow. 🙂 OK, when I have time, I will look at the fixes done in the ppp tree and merge them into rp-pppoe (and will probably need to make additional fixes of my own for code that's not in the ppp tree.) I'll set up an Ubuntu LXC container at some point... but $DAY_JOB is becoming a bit demanding, so no ETA on this. Regards, Dianne. |
They are in my experience inter-changeable. On Gentoo we've been renaming rp-pppoe from ppp package to pppoe for a while now to avoid the naming conflict, and just installed both, user can choose which he prefers to use. The plugin is only required for kernel mode. user-mode uses pty option which runs a binary specifically encapsulating and decapsulating the pppoe traffic in userspace compared to kernel mode. This is inefficient and won't scale, but it's sufficient in some cases (like running a small number of connections). My recommendation remains: Plugin in ppp project (for the pure and simple reason that it's convenient for the majority of pppoe users, just install ppp and you've got pppoe client support - majority of pppoe users). Everything else in rp-pppoe package. Gentoo originally had rp-pppoe merged predominantly for client support (early 2000's). I highly doubt the server components would have worked reliably until the work I did in the last couple of years. |
OK. I think the way forward is to clean up the code so the plugin in the ppp project is up-to-date with the changes that have been made in rp-pppoe; it will then become the One True PPPoE implementation. On the rp-pppoe side, I think we should get rid of the user-space program rp-pppoe will then become just a relay and server implementation, dependent on the plugin that ships with the ppp project. Does that make sense? |
@jkroonza I am slightly confused by your response. Yes, if you use pppd via a pty option to start the pppoe negotiation; I would understand it, but if you run it directly:
Wouldn't that start the pppoe via the Ethernet interface directly using a AF_PPPOX socket? Let there be known, I don't know the data path of these packets by just reviewing the code. Looks like rp-pppoe in addition has capability to use BPF filters or AF_PACKET / RAW sockets to grab packets it is interested in. While the rp-pppoe.so does have additional code in if.c (1100 lines vs 250 lines in pppd/pppoe's if.c), I don't see them being so much different. Could someone please enlighten me? It seems like using kernel mode should be possible using either version of the plugin, and if not; there should be possible to update the pppd/pppoe plugin to do so. @dfskoll You may want to consider the change history in pppd/pppoe to figure out what have changed and to why. Looks like @pali helped fixing a bunch of stuff here too. |
Also, that command line resembles very much how network-manager configures pppd when configuring a pppoe interface: |
And that is kernel mode :). What we mean with userspace mode is that where kernel mode support is not available pppoe-server will pass With pppoe.so plugin, the plugin will perform discovery etc from userspace, and then pass the details to the kernel such that the pppoe session data does not pass through userspace at all. I believe this is the AF_PPPOX socket mechanism. I guess it's possible to include userspace support straight into the pppoe.so plugin in cases where it cannot hand-off to the kernel, but I've yet to bump into this being a problem. To be honest, scanning the code for pppoe.c I'm not actually sure how packets are sent/received, but each and every packet passes through this process. Which is why we call it userspace mode. |
Yes, user mode vs. kernel-mode refers to the session packets. In user mode, they all pass through This is the part of
and conversely, this bit reads PPPoE packets from the Ethernet interface and sends them to
|
Interesting Based on my past experiences, I think there was maybe a common misconception that rp-pppoe provided the kernel mode support for configuring pppoe and thus the pppoe.so was taken from the rp-pppoe project. Or perhaps that feature was later implemented in pppd's version of pppoe (or after my experience with pppoe dated ca 2008). When @jkroonza said he needed the rp-pppoe's project's rp-pppoe.so it was because he needed it in context of running a pppoe-server, and that is what pppd's pppoe.so couldn't provide? In conclusion, either version of (rp-)pppoe supports configuring pppoe w/kernel support where control packets are being handled in user space, but session packets are handled by kernel space. If this is true, then the only reason one really would want to go through the trouble of installing rp-pppoe's version of pppoe.so is if they are running a pppoe-server, right? Not to add to the confusion, but it looks like the Debian guys package the pppd's version of pppoe.so (with a symlink from rp-pppoe.so that later gets overwritten if one would install the rp-pppoe version of the plugin - @bootc @rfc1036?). Gentoo has been using the rp-pppoe's version of the plugin all along (@jkroonza @samsam?). Not sure what RedHat does, but maybe @yarda would be able to confirm what version they are using, but it all points out that we should be driving this from a single repository at some point. I guess we need to actually dig in and find the differences in the code and what needs to be carried forward. Another point here is we do know the entire change history since 2002 to pppoe.so via pppd (it's public). What would it take to bring it up to add the server support needed for running it with pppoe-server software? Looking at e.g. if.c, there is a bunch of code removed for handling cases e.g. reading packets via BPF or RAW sockets? Do we still needed these in a "modern" version of pppoe.so? Lastly, any of this conversation in this thread / issue, it would need a buy-in from @paulusmack for it to even happen. |
In my opinion, the way forward to clean up the code is:
|
One concern with this approach is that we'll lose the change history from pppd's version of pppoe.so. You repository, the history is lacking between for a time-period of 10+ years, no? One additional question I have is, would it be less work to start from a import from pppd's version of pppoe? What would need to be added? |
we could merge rp-pppoe --> pppd PPPoE is an old protocol and IMO there's little of value in the change history. But I have no issues with merging rp-pppoe into pppd if you want to preserve the history. |
I don't have a particular beef with any of the two approaches. It's just another point of view, and I wonder if some of the check-points you listed would be a no-op if you started from the other repository. Basically, the least amount of work / changes principle. I don't have the depth of knowledge as to the history of either projects, or the actual code / functionality. In either case, with a new repository; you'd probably need some of my help setting up autoconf/automake and I can do that. |
So to make it clear. Linux kernel provides support for encapsulating and decapsulating of IP/IPv6 packets from PPPoE packets on eth interface directly to ppp interface without putting packets into userspace. All other PPPoE packets (e.g. IPCP, LCP, ...) are still passed to userspace where pppd can handle authentication ip address exchange etc... Normally kernel PPP API requires tty-capable file descriptor on which it starts/creates ppp network interface. Linux kernel allows also file descriptor of connected AF_PPPOX socket. And one option for AF_PPPOX socket is PX_PROTO_OE (PPPoE) with connect address of type struct sockaddr_pppox, which contains interface name of eth interface, MAC address of the peer and PPPoE session id. ppp's plugin pppoe.so uses only above kernel interface. There is no userspace support of PPPoE implemented in that plugin. So it is Linux-only. Note that discovery of PPPoE server/concentrator is done in userspace (in pppoe.so plugin) because as described above, discovery is not part of the kernel. And thanks to this, it is possible to use ppp's pppoe.so plugin also for PPPoE server. It is just needed to change userspace session code by another code, which rp-pppoe server implements. Userspace pppoe solution (which is not part of the ppp project; but is in rp-pppoe) needs to receive raw PPPoE packets from eth inerface, unpack it and then raw PPP packets put into tty (pts) file descriptor which is connected to kernel's ppp. I hope that I did not make mistake in above description. (if yes, please correct me) |
ppp's plugin pppoe.so uses only above kernel interface. There is no userspace support of PPPoE implemented in that plugin. So it is Linux-only. Not quite... PPPoE discovery packets are handled in user-space. The kernel handles PPPoE session packets itself. |
@pali - I think I understand now and thank you for that detailed explanation. Even if rp-pppoe's pppoe.so plugin supports user-mode only operation, I am not sure if this is a needed feature of a "modern" pppoe.so plugin. Every essential distribution of Linux seems to provide the AF_PPPOX interface with PX_PROTO_OE out of the box. Either way, if this pppoe plugin is made to be Linux only, I also don't see the need to pull in additional code for user-mode pppoe, and I think this is aligned with what @dfskoll was proposing. |
Of course! (I wrote this in next sentence of my post.)
Yes! I also do not see any reason for userspace pppoe support (meaning userspace replacement of PX_PROTO_OE) too. AF_PPPOX is available in Linux kernel for a long time. |
The pppoe-server.c code in rp-pppoe assumes the plugin is called rp-pppoe. Thus I "need" it in terms of ./src/Makefile.in:PLUGIN_PATH=$(PLUGIN_DIR)/rp-pppoe.so Yea, I can probably override that at build time looking at that properly, but at INSTALL time that'll cause a file conflict with ppp's variant (which is the same one really).
No, we don't need it ever. We can use the one from ppp. They are functionally the same, including supported arguments. It's cosmetic changes really.
Gentoo installed both, user gets to choose. Which is confusing. pppoe-server resulted in rp-pppoe being used, however, in a client scenario either one would suffice.
Nothing. I've tested pppoe.so by creating a symlink to rp-pppoe.so (after removing the one from rp-pppoe) and it works.
No not really. No changes required to ppp, only on rp-pppoe side. If there were changes made to rp-pppoe.so between ppp forking it and now, @dfskoll should have the history and should be able to decide what should be rebased onto the pppoe from ppp, and file PRs which can then be evaluated on a case by case basis. One other option should such a merge really be a problem, would be to leave rp-pppoe.so in rp-pppoe, but make compiling it optional, but even when not compiling it allow kernel-mode configuration in pppoe-server and allow specifying the plugin name via argument, eg -k will simply do kernel mode using rp-pppoe.so, but -K pppoe.so could signify to pass plugin pppoe.so rather than plugin rp-pppoe.so ... for example. I would not make any other changes (including dropping user-space support which is available in rp-pppoe - this can be done at a later stage independently of this endeavour here, I would however highly recommend kernel mode be made the default). There are a bunch of really outdated scripts part of the rp-pppoe project (@dfskoll actually raised this in another discussion), but those kind of changes are to rp-pppoe project and outside the scope of this discussion in my opinion. Thus in my opinion only really two approaches:
In both cases I suspect making the argument to pppd's plugin option start-time configurable at the very least. I'd recommend option 1 purely for the sake of having one source of truth. The changes @dfskoll made over the years could be done as a patch series on ppp, thus thereby gaining the change history. Of course it would need to be rebased then. I'd offer to do this work, but unfortunately only @dfskoll has this history available. |
The problem with continuing to support user-mode PPPoE in rp-pppoe is that there would be a substantial amount of source code overlap with the plugin in ppp. This, IMO, argues for removing pppoe.so from ppp and having rp-pppoe be the single source of truth. I think we should drop user-mode PPPoE support. There's no reason for it any more. As for patches to ppp's plugin code, I wasn't planning on going through all of my git history anyway. I was just going to compare the code and extract the differences and merge as appropriate. (But this won't happen for a while as I am busy at the moment...) |
In either approach I would advocate for removing the pppoe.so from both pppd and rp-pppoe project in favor of establishing a separate git repository under the ppp-project umbrella. This would require @paulusmack to create / set it up, import the files, adding a separate autoconf / automake files, add additional patches, communicate these changes with packagers for various platforms. As I pointed out earlier, there are two ways of going about it, import the files from rp-pppoe's project, or import the files from pppd's project. In the end, I think you'll find that the proposed changes for removing the user-space code, and misc cleanup already done in pppd may be the shorter path. Also, a bonus would be to do this in a fashion that would preserve git history. Another thing that could favor an import from pppd's pppoe.so module is that it's been in a public git repository dating back to when the fork was made. @dfskoll's repository was scrubbed for various changes pertaining to work performed in conjunction with a company. This of course runs the risk of proprietary code bleeding over unless that process was carefully done. |
The proprietary code was kept completely separate right from the beginning; there's no proprietary code in the public rp-pppoe repos. There have been fixes in rp-pppoe that have not been made to the version of pppoe.so in the ppp project. |
@enaess I do not understand the motivation for a separate repository here. Could you please clarify? Not my call at all, but I kind feel responsible for this tangent getting started. pppoe-server cannot run without ppp anyway. I believe pppoe-bridge should be able to, but honestly I'm struggling to think of a practical use-case for pppoe-bridge. Killing the user-space implementation may completely get rid of the pppoe-discovery code in rp-pppoe, thus eliminating even that small amount of duplicated code. There may be more duplicated code than this, but that is which I'm aware off. Currently I know ppp also functions on Solaris, it looks like BSD support was discontinued. How does pppoe and pppol2tp work on solaris - if at all? |
@jkroonza I believe the entire motivation behind this discussion was to establish a single source of "truth" - a single code base / repository going forward. This is to
The pppoe and pppol2tp was never ported or built on Solaris. In fact the entire set of plugin directories is not built on Solaris. |
@enaess that is my understanding too. Agree with everything you stated above. My understanding from the above is that there is no pppoe on Solaris without the userspace program from rp-pppoe? So if there are users using that, it means that dropping that would move things backwards. If we drop that, then I don't see any reason for creating a third repository. If we want to keep it (I personally could not care less seeing that I don't use that, but I also don't want to anger users for no good reason) that would then motivate a possible third repo for pppoe rather, let's call it ppp-pppoe for the sake of just giving it a name which can build either the userspace program, or the ppp plugin (on linux at least), or both. |
It's my understanding that Solaris has its own kernel-mode implementation of PPPoE that no longer uses rp-pppoe, and I believe the same for FreeBSD. The DLPI and BPF code in rp-pppoe clutters the code with I also do not see the need for a third repo. The PPPoE plugin can live under pppd/plugins and RP-PPPoE (the server and relay implementation) can stay where they are; I don't see any advantage to putting them under the ppp project. Regards, Dianne. |
+1 |
I was under the impression that @dfskoll would want to be one of the owners of a new repository under ppp-project/pppoe-plugin (or whatever name seemed appropriate). Generally, I was hoping to remove the additional plugin(s) from pppd for a simpler autoconf/automake configuration. Though this change does have impact on others
So with the current proposal, we are collectively thinking the rp-pppoe project should just nuke it's version of the pppoe plugin and patches be submitted to pppd/pppoe plugin to account for differences. I'd generally be okay with that, not sure if that is what @dfskoll originally signed up for. @Neustradamus what do you think? |
I didn't originally sign up for moving the plugin under ppp and nuking it from rp-pppoe, but I've come around to thinking that's the best path forward. The PPPoE protocol is mature and so is the PPPoE plugin code. Any interesting new work is going to be done on the rp-pppoe server, so I'm fine with handing off the protocol-handling code to the ppp/pppd project. |
And... I have changed my mind. It has been brought to my attention that user-mode PPPoE still has use-cases (specifically, on systems where everything is statically-linked... on such systems, plugins are impossible.) I assume that the PPP project has no interest in maintaining user-mode PPPoE using the As such, I'm abandoning the idea of merging the two projects. I will continue maintaining RP-PPPoE, and the PPP project can maintain its fork of the plugin code separately. Distro packagers can decide whether to ship the So I guess I consider this issue closed, but I won't actually close it in case there's further discussion. Regards, Dianne. |
@paulusmack @enaess This can be closed. |
The
pppd/plugins/pppoe
directory contains a substantial amount of code from therp-pppoe
project, and unfortunately that code has diverged from upstream.I think we should synchronize the projects so the code isn't duplicated, and possibly remove the pppoe plugin from the ppp project once rp-pppoe builds and installs properly alongside ppp.
Created this issue in response to #379 (comment)
The text was updated successfully, but these errors were encountered: