Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#31380 - [ppp] [netcfg] ipv6 over pppoe support patch

Attached to Project: Arch Linux
Opened by Gala Dragos (arch_gala) - Saturday, 01 September 2012, 18:06 GMT
Last edited by Evangelos Foutras (foutrelis) - Wednesday, 05 December 2012, 19:07 GMT
Task Type Feature Request
Category Packages: Core
Status Closed
Assigned To Thomas Bächler (brain0)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 3
Private No

Details

Description:
A patch for netcfg to support ipv6 over pppoe connections

Additional info:
* package version(s) 2.8.9

Attached is modified pppoe script to allow ipv6 to be enabled over pppoe connections. It requires pppd over 2.4.3, current shipped version in Arch is 2.4.5 so there should be no problem.

In order to use the patch you define "PPPOE_IPV6=yes" in the connection connection configuration file. The modified pppoe script will detect this and write the correct thing in pppd options file.

This should have a high priority, because we have entered the IPV6 era, aren't we ?
This task depends upon

Closed by  Evangelos Foutras (foutrelis)
Wednesday, 05 December 2012, 19:07 GMT
Reason for closing:  Implemented
Additional comments about closing:  Implemented in ppp 2.4.5-5.
Comment by Gala Dragos (arch_gala) - Sunday, 02 September 2012, 06:56 GMT
somehow the file wasn't attached
   pppoe (2.5 KiB)
Comment by Gala Dragos (arch_gala) - Wednesday, 05 September 2012, 19:14 GMT
Just a follow up on the actual behavior of the script, as noticed on my server.

To use IPv6 over pppoe the system must be configured properly, therefore we must do the following:
- automatic router advertisements must be accepted (for ipv6) at least on the new ppp interface;
- temporary address usage must NOT be enabled, at least on the new ppp interface.

The script currently does not cover the above configurations, if somebody can figure out how to get the created ppp interface name I can whip something up to automatically set the correct flags in /proc.

Also the script fixed a problem with the original one:
- the pppd options file is created at "/run/network/pppoe.eth0.connection_file_name", which is wrong as not all connections are done over eth0;

I have fixed the above by allowing the script to specify the actual interface name over which the ppp is initiated, instead of eth0.
Comment by Gala Dragos (arch_gala) - Saturday, 15 September 2012, 08:56 GMT
I've completed the pppoe script ! (See attachment)

Now it handles the flags needed in /proc for the ppp interface to be able to get an ipv6 address with no intervention from the user, aside from specifically enabling ipv6 over pppoe.

Tests done on my isp have completed successfully. I would really like to see this in the next release of netcfg package.

I haven't found any other network manager (in Arch or other distro) to support ipv6 over pppoe.
   pppoe (3.2 KiB)
Comment by Gala Dragos (arch_gala) - Saturday, 15 September 2012, 09:18 GMT Comment by Jouke Witteveen (jouke) - Saturday, 15 September 2012, 09:20 GMT
I took a quick look at your modifications and am not entirely satisfied.

> @@ -1,6 +1,8 @@
> #! /bin/bash
> . /usr/lib/network/network
>
> +# ipv6 extensions added by GALALAE Dragos Ionut
> +

Thomas Bächler is the main author. Might as well list him too. Additionally an e-mail address would be nice if you really want to list yourself.

> _quotestring() {
> echo "\"${1/\"/\\\"}\""
> }
> @@ -9,9 +11,9 @@ pppoe_up() {
> local cfg
> load_profile "$1"
>
> - mkdir -p "$STATE_DIR"/pppoe.eth0."$1"/
> - chmod 700 "$STATE_DIR"/pppoe.eth0."$1"/
> - cfg="$STATE_DIR"/pppoe.eth0."$1"/options
> + mkdir -p "$STATE_DIR"/pppoe."${INTERFACE}"."$1"/
> + chmod 700 "$STATE_DIR"/pppoe."${INTERFACE}"."$1"/
> + cfg="$STATE_DIR"/pppoe."${INTERFACE}"."$1"/options

Looks sane, perhaps Thomas can clarify why it wasn't like this in the first place.

> : > "${cfg}"
> chmod 600 "${cfg}"
>
> @@ -43,22 +45,43 @@ pppoe_up() {
> [[ -n ${PPPOE_AC} ]] && echo "rp_pppoe_ac $(_quotestring "${PPPOE_AC}")" >> "${cfg}"
> [[ -n ${PPPOE_SESSION} ]] && echo "rp_pppoe_sess $(_quotestring "${PPPOE_SESSION}")" >> "${cfg}"
> [[ -n ${PPPOE_MAC} ]] && echo "pppoe-mac $(_quotestring "${PPPOE_MAC}")" >> "${cfg}"
> +
> + if [[ ${PPPOE_IPV6} == yes ]]; then
> + echo "+ipv6" >> "${cfg}"
> + fi

What is wrong with just
[[ ${PPPOE_IPV6} == yes ]] && echo "+ipv6" >> "${cfg}"
like all the lines above?
Additionally, I think PPPOE_IP6 would be a slightly better name, or even just IP6 (cf. ethernet).

>
> /sbin/ip link set dev ${INTERFACE} up
> - /usr/sbin/pppd file "${cfg}"
> +
> + # get bad status from a piped program
> + set -o pipefail
> + # execute pppd with required parameters, and get the name of the newly created ppp interface
> + local pppiface
> + pppiface=$( /usr/sbin/pppd file "${cfg}" | grep 'ppp[0-9]\+$' | sed 's/.*\(ppp[0-9]\+\)/\1/')

Rather something like:
pppiface=$(/usr/sbin/pppd file "${cfg}" | grep -o 'ppp[[:digit:]]\+$')

>
> + # status ok ?

Unnecessary comment.

> if [[ $? -ne 0 ]]; then
> rm "${cfg}"
> - rmdir "$STATE_DIR"/pppoe.eth0."$1"/
> + rmdir "$STATE_DIR"/pppoe."${INTERFACE}"."$1"/
> report_fail "Couldn't make pppd connection."
> return 1
> fi
> +
> + # ipv6 over ppp need special care, because they probably assumed that ppp will never be used with ipv6
> + if [[ ${PPPOE_IPV6} == yes ]]; then

Don't forget to rename the variable here too.

> + # must disable the privacy extensions on the connection,
> + # because it would otherwise use those and they are not routed by the isp
> + echo "0" > /proc/sys/net/ipv6/conf/${pppiface}/use_tempaddr
> + # if forwarding is enabled, then we must force the interface to receive an ip,
> + # see the specs why we need this
> + echo "2" > /proc/sys/net/ipv6/conf/${pppiface}/accept_ra
> + fi
> +
> }
>
> pppoe_down() {
> load_profile "$1"
> local cfg
> - cfg="$STATE_DIR"/pppoe.eth0."$1"/options
> + cfg="$STATE_DIR"/pppoe."${INTERFACE}"."$1"/options
> PIDFILE="/var/run/ppp-$1.pid"
>
> if [[ -e $PIDFILE ]]; then
> @@ -67,7 +90,7 @@ pppoe_down() {
> fi
>
> rm "${cfg}"
> - rmdir "$STATE_DIR"/pppoe.eth0."$1"/
> + rmdir "$STATE_DIR"/pppoe."${INTERFACE}"."$1"/
> }
>
> pppoe_$1 "$2"

I have added Thomas, because he is the original author. If he thinks it is fine, I will push it.
Comment by Gala Dragos (arch_gala) - Saturday, 15 September 2012, 09:31 GMT
Very good! I have no objection to this. I would have done it myself, but it haven't crossed my mind.

Heck you can even delete it as it was meant for the developers, if they are kind enough to add me to the contributors list.

The main thing is, does the script works for you ?
Comment by Thomas Bächler (brain0) - Saturday, 15 September 2012, 09:46 GMT
The eth0 stuff was an oversight, apparently nobody noticed.
Comment by Thomas Bächler (brain0) - Saturday, 15 September 2012, 10:01 GMT
First of all, the s/eth0/$INTERFACE/ bugfix must be separated into its own patch, otherwise this becomes an unreadable mess.
Second, the patch contains lots of trailing whitespaces and indentation errors.

I don't like the method which is used to determine the name of the ppp interface. The safest way is to explicitly determine it via the 'unit' option, and make sure that the interface is unused beforehand - for example: for i=0..9, test if /sys/class/net/ppp$i exists, and if not, add the 'unit $i' option. Unfortunately, this can also get racy if two ppp processes are started at the same time.

Another solution would be to add /etc/ppp/ip6-up to the ppp package to handle this - this is probably the best solution.
Comment by Gala Dragos (arch_gala) - Saturday, 15 September 2012, 10:28 GMT
>> this can also get racy if two ppp processes are started at the same time

which is why I opted to extract the ppp interface name from pppd's output

Also this cleans up the boot log, as it removes the unnecessary output from pppd, which appears when connection starts.

>> indentation errors
I use tab for indentations, and gedit as an editor

>> The eth0 stuff was an oversight, apparently nobody noticed.

I've only noticed it because I had my pppoe connections over nic0.
Comment by Thomas Bächler (brain0) - Saturday, 15 September 2012, 10:36 GMT
> I use tab for indentations, and gedit as an editor

The indentation is inconsistent all around the changed file.

> > this can also get racy if two ppp processes are started at the same time
> which is why I opted to extract the ppp interface name from pppd's output

It's ugly to do it this way. I think adding this to a default ip6-up script for ppp makes much more sense - these settings apply to all ipv6 ppp connections, not just netcfg.

> Also this cleans up the boot log, as it removes the unnecessary output from pppd, which appears when connection starts.

This can be changed in the rc.d script for initscripts. I'd like to keep the output, as you can find it in systemd's journal after boot.
Comment by Gala Dragos (arch_gala) - Saturday, 15 September 2012, 11:07 GMT
ipv6 addresses will no longer appear on standard output, as they are negotiated after the connection was established, this is what makes the output information useless, as it does not show all the information.

I agree on an ip6-up script, it really does make sense, especially it you consider some mobile operators are starting to role out ip6 on their network.

By using the unit option on pppd you are taking away the automatic and consistent interface naming, which pppd handles so well. Isn't there an option to instruct pppd to pass the new interface name to the script?

Alternatively you can take snapshots of configured ppp interface names before you run pppd and compare them with ppp interface names after pppd has started successfully. Initially I've parsed "ip link show" to achieve this, but I thought it was too complicated, so I've modified it to parse pppd's own output, which always contains the ppp interface name that is created now.
Comment by Thomas Bächler (brain0) - Saturday, 15 September 2012, 12:11 GMT
This is what we'll do: I will add ip6-up to the ppp package, which will handle the interface settings gracefully. Then we'll separate the rest into two patches: 1) The $INTERFACE bugfix, 2) the ipv6 support - the latter will basically be a one-liner, as the pppoe script does not need to know the interface name anymore.
Comment by Jouke Witteveen (jouke) - Saturday, 15 September 2012, 12:15 GMT
@Gala: do you want to give it a shot and come up with two patches that I can apply, or is it okay if I just do the two commits myself (they are rather trivial), with attribution?
Comment by Gala Dragos (arch_gala) - Saturday, 15 September 2012, 13:14 GMT
attached the files here and I'll try them out.
Comment by Thomas Bächler (brain0) - Saturday, 15 September 2012, 13:18 GMT
Okay, I'm taking care of the ppp package later.
Comment by Jouke Witteveen (jouke) - Saturday, 15 September 2012, 14:11 GMT
The netcfg part is fixed in f9846 and 5e1ac.
@Thomas: can I hand this report off to you?
Comment by Gala Dragos (arch_gala) - Saturday, 15 September 2012, 17:31 GMT
So were exactly is the source control web site ?
Comment by Thomas Bächler (brain0) - Saturday, 15 September 2012, 17:54 GMT
@Jouke: Yes, I'll take care of the rest.
Comment by Thomas Bächler (brain0) - Saturday, 15 September 2012, 22:10 GMT Comment by Thomas Bächler (brain0) - Monday, 15 October 2012, 21:00 GMT
Package is in testing now.
Comment by Gala Dragos (arch_gala) - Saturday, 01 December 2012, 10:19 GMT
Just wanted to say THANKS. The modifications are now in release and they work.

Loading...