Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 621662 - net-dialup/pptpclient: >=sys-apps/iproute2-4.10.0 breaks routing
Summary: net-dialup/pptpclient: >=sys-apps/iproute2-4.10.0 breaks routing
Status: IN_PROGRESS
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal with 1 vote (vote)
Assignee: No maintainer - Look at https://wiki.gentoo.org/wiki/Project:Proxy_Maintainers if you want to take care of it
URL:
Whiteboard:
Keywords:
: 641972 (view as bug list)
Depends on:
Blocks: 639536
  Show dependency tree
 
Reported: 2017-06-13 10:07 UTC by MarisN
Modified: 2019-04-29 01:24 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Discard uid part of iproute2 ip route get (pptpclient-discard-uid.patch,863 bytes, patch)
2017-12-02 21:11 UTC, MarisN
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description MarisN 2017-06-13 10:07:22 UTC
After emerging >=sys-apps/iproute2-4.10.0, pppd is not able to set up correct routing table. Similar issue has been encountered also in Arch: https://bbs.archlinux.org/viewtopic.php?id=224744
Could be this upstream error report: https://github.com/paulusmack/ppp/issues/81

Output while running with >=sys-apps/iproute2-4.10.0:
Using interface ppp0
Connect: ppp0 <--> /dev/pts/1
Error: either "to" is duplicate, or "uid" is a garbage.
CHAP authentication succeeded
MPPE 128-bit stateless compression enabled
local  IP address XXX
remote IP address YYY

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         YYYYYYYYYYY     0.0.0.0         UG    0      0        0 ppp0
0.0.0.0         10.0.25.1       0.0.0.0         UG    203    0        0 eth0
YYYYYYYYYYY     0.0.0.0         255.255.255.255 UH    0      0        0 ppp0
10.0.25.0       0.0.0.0         255.255.255.0   U     203    0        0 eth0
127.0.0.0       127.0.0.1       255.0.0.0       UG    0      0        0 lo


After downgrading to sys-apps/iproute2-4.9.0:
Using interface ppp0
Connect: ppp0 <--> /dev/pts/3
CHAP authentication succeeded
MPPE 128-bit stateless compression enabled
local  IP address XXX
remote IP address YYY

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         YYYYYYYYYYY     0.0.0.0         UG    0      0        0 ppp0
0.0.0.0         10.0.25.1       0.0.0.0         UG    203    0        0 eth0
ZZZZZZZZZZ      10.0.25.1       255.255.255.255 UGH   0      0        0 eth0
YYYYYYYYYYY     0.0.0.0         255.255.255.255 UH    0      0        0 ppp0
10.0.25.0       0.0.0.0         255.255.255.0   U     203    0        0 eth0
127.0.0.0       127.0.0.1       255.0.0.0       UG    0      0        0 lo

Notice - 
* no error message after downgrade: either "to" is duplicate, or "uid" is a garbage;
* an extra line in routing table (marked as ZZZZ).
Comment 1 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2017-11-29 18:47:28 UTC
Can you please trace the exact ip command that is being run?
Comment 2 MarisN 2017-11-30 20:58:18 UTC
This bug also has hit FC26: https://bugzilla.redhat.com/show_bug.cgi?id=1476496

Calls to ip are:
/bin/ip route get 5.179.xxx.xxx 
/bin/ip route replace 5.179.xxx.xxx via 10.0.25.1 dev eth0 src 10.0.25.2

With sys-apps/iproute2-4.9.0 there is no error message, with sys-apps/iproute2-4.14.1-r1, after second ip call I get infamous "Error: either "to" is duplicate, or "uid" is a garbage" and my routing table is missing one entry:
5.179.xxx.xxx      10.0.25.1       255.255.255.255 UGH   0      0        0 eth0
Comment 3 MarisN 2017-11-30 21:08:48 UTC
(In reply to MarisN from comment #2)
> Calls to ip are:
> /bin/ip route get 5.179.xxx.xxx 
> /bin/ip route replace 5.179.xxx.xxx via 10.0.25.1 dev eth0 src 10.0.25.2
Mea culpa. This is output from sys-apps/iproute2-4.9.0

With sys-apps/iproute2-4.14.1-r1 it looks like this (no idea if it makes difference):
/bin/ip route get 5.179.0.66 
/bin/ip route replace 5.179.0.66 via 10.0.25.1 dev eth0 src 10.0.25.102 uid 0
Error: either "to" is duplicate, or "uid" is a garbage.

Both outputs are generated by patching iproute2:
diff --git a/ip/ip.c b/ip/ip.c
index b15e6b66..f3289bea 100644
--- a/ip/ip.c
+++ b/ip/ip.c
@@ -179,9 +179,14 @@ int main(int argc, char **argv)
 	else
 		basename++;
 
-	while (argc > 1) {
+	for (int i = 0; i < argc; i++) {
+        fprintf(stderr, "%s ", argv[i]);
+    }
+    fprintf(stderr, "\n");
+    
+    while (argc > 1) {
 		char *opt = argv[1];
-
+        
 		if (strcmp(opt, "--") == 0) {
 			argc--; argv++;
 			break;
Comment 4 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2017-11-30 21:18:03 UTC
ppp should NOT be passing 'uid NUMBER' to the replace command. It's only valid in 'get', not add/del/change/append/replace.

Rather than route -n output, can you please get me the output of 'ip -4 route' with both 4.9.0 and >=4.10?

Open questions:
1. Why does PPP add it now?
2. If UID is meaningful for 'get', why isn't it meaningful for the add/replace 
   etc.

Theory:
The field was always there, but is only being shown now, and ppp is copying it blindly.
Comment 5 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2017-12-02 20:30:08 UTC
Ok, in researching this, it's from ppp blindly copying route output.

iproute2-4.10 added a 'uid' output on some routes, but it's only valid in output & get requests, and NOT to add/change/delete routes.

ppp needs to be patches to do something meaningful with the uid line.
Comment 6 MarisN 2017-12-02 21:11:41 UTC
Created attachment 507778 [details, diff]
Discard uid part of iproute2 ip route get

This patch fixes the issue.
Tested with iproute2-4.9.0 and iproute2-4.14.1-r1 on ~AMD64.
Comment 7 MarisN 2017-12-02 21:17:05 UTC
(In reply to MarisN from comment #6)
> Created attachment 507778 [details, diff] [details, diff]
> Discard uid part of iproute2 ip route get
Ah. File name is not visible. This patch is for net-dialup/pptpclient (I have net-dialup/pptpclient-1.8.0 but should work as well with 1.7.x and 1.9.0 too).
Comment 8 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2017-12-04 03:37:38 UTC
That patch is hazardous: You're simply truncating at the point you see 'uid'.

If there is another argument after uid in future, you're going to lose it.
Here's a rough patch that I'm just writing in the comment box for a better way to do it: replacing 'uid XXXX' with whitespace.

---
   route = strdup(buf);
+  /* Starting with iproute2 4.10.0, call to 'ip route get' will contain uid value.
+   * Still uid should not be used in other calls (i.e. replace, delete). 
+   * So we overwrite uid & the value with spaces.
+   */
+  uidStart = strstr(buf, " uid");
+  if (uidStart) {
+    const char * uidParamEnd = strstr(uidStart+4+1, " ");
+    if(!uidParamEnd)
+      uidParamEnd = strlen(buf);
+     // Find first space AFTER ' uid X'
+    for(const char* tmp = uidStart; tmp <= uidParamEnd; tmp++)
+      *tmp = ' ';
+  }
---

You wrote this patch was for pptpclient? What about net-dialup/ppp. Was your initial report wrong?
Comment 9 MarisN 2017-12-04 14:26:48 UTC
(In reply to Robin Johnson from comment #8)
> That patch is hazardous: You're simply truncating at the point you see 'uid'.
> If there is another argument after uid in future, you're going to lose it.
And then it will be necessary to explore this new argument use case (should or should not it be passed on to add/del etc. calls).
Feel free to submit your patch upstream (they already accepted my hazardous approach and it works fine for me): https://sourceforge.net/p/pptpclient/git/ci/master/tree/

> You wrote this patch was for pptpclient? What about net-dialup/ppp. Was your
> initial report wrong?
It seems so – I call pppd and thus I assumed it to be at fault, but actually pppd is calling pptp client and thus the failure in pptp client is causing pppd connection misconfiguration.
Now I know about pppd and pptp client more than I ever wanted to know.
Comment 10 bugs 2017-12-24 11:10:31 UTC
*** Bug 641972 has been marked as a duplicate of this bug. ***
Comment 11 Jeroen Roovers (RETIRED) gentoo-dev 2019-02-04 10:06:54 UTC
(In reply to MarisN from comment #9)
> > You wrote this patch was for pptpclient? What about net-dialup/ppp. Was your
> > initial report wrong?
> It seems so – I call pppd and thus I assumed it to be at fault, but actually
> pppd is calling pptp client and thus the failure in pptp client is causing
> pppd connection misconfiguration.
> Now I know about pppd and pptp client more than I ever wanted to know.