WAN: new PPP code for generic HDLC
Subsystems (3)
Krzysztof Halasa
maintainerHi,
I'll follow up with a patch for generic HDLC PPP code.
Current status of generic HDLC is:
- up to 2.6.22 - working.
- 2.6.23.* and 2.6.24.* - Frame Relay and PPP protocols panic instantly, breakage caused by a change to netdev code that I overlooked.
- 2.6.25-git - Frame Relay is already fixed, PPP still panics.
The fix to FR was simple (983e23041b28abb113862b2935a85cfb9aab4f5a).
PPP has been using syncppp.c implementation for years, meaning working as a mid-layer between hardware drivers and syncppp. This situation is increasingly hard to maintain, and I've decided to write a dedicated PPP implementation for generic HDLC.
Rationale:
- syncppp assumes no mid-layer between itself and hw drivers - dirty hacks must be used to work around this
- syncppp doesn't even try to implement PPP correctly, it looks like it was written to work with another specific implementation and then left in this state for *teen years
- every protocol (LCP and IPCP) uses different state machine code.
- lack of IPv6 support and adding it is non-trivial.
- I've considered using the generic PPP stack, however it's oriented towards async tty and requires the pppd daemon - I guess code to interface to it would be more complicated than the new PPP code.
The PPP state machine is distributed over many functions and this is extremely hard to maintain or even understand. No wonder it's not very standard-compliant.
Instead my new implementation has:
- a single state machine code for all control protocols (LCP, IPCP, IPV6CP, and whatever is needed)
- it's modelled after STD-51
- even more minimalistic than syncppp (no "magic number"), though adding optional support (if needed) is simple.
- can actually be maintained.
I have positively tested it on i686 and big-endian ARM, against itself and against syncppp.c. I can't test it against any other device due to -ENOHW, so I expect some bugs/problems in/with this code, though I hope it's better than the current brokenness.
I guess it should go into 2.6.25, not sure about "stable" series. I will appreciate any feedback, review and/or test results.
Signature · 1 line
Krzysztof Halasa
Krzysztof Halasa
maintainerNew synchronous PPP implementation for generic HDLC.
drivers/net/wan/Makefile +1 -1
@@ -14,7 +14,7 @@ obj-$(CONFIG_HDLC_RAW) += hdlc_raw.o obj-$(CONFIG_HDLC_RAW_ETH) += hdlc_raw_eth.o obj-$(CONFIG_HDLC_CISCO) += hdlc_cisco.o obj-$(CONFIG_HDLC_FR) += hdlc_fr.o -obj-$(CONFIG_HDLC_PPP) += hdlc_ppp.o syncppp.o +obj-$(CONFIG_HDLC_PPP) += hdlc_ppp.o obj-$(CONFIG_HDLC_X25) += hdlc_x25.o pc300-y := pc300_drv.o
drivers/net/wan/hdlc_ppp.c +599 -48
730 lines not on this page · raw message
drivers/net/wan/hdlc_ppp.c line 63
Quoted 13 lines
drivers/net/wan/hdlc_ppp.c +12
-0+struct hdlc_header { +u8 address; +u8 control; +__be16 protocol; +} __attribute__ ((packed)); + +struct cp_header { +u8 code; +u8 id; +__be16 len; +} __attribute__ ((packed)); +
If I remember correctly, the packed is unnecessary for structures like this and causes GCC to generate worse code.
Krzysztof Halasa
maintainerQuoted 7 lines · Stephen Hemminger
Quoted 7 lines
drivers/net/wan/hdlc_ppp.c +7
-0+struct hdlc_header { +u8 address; +u8 control; +__be16 protocol; +} __attribute__ ((packed)); + +struct cp_header {
Quoted 8 lines
drivers/net/wan/hdlc_ppp.c line 63
Quoted 5 lines
drivers/net/wan/hdlc_ppp.c +5
-0+u8 code; +u8 id; +__be16 len; +} __attribute__ ((packed)); +If I remember correctly, the packed is unnecessary for structures like this and causes GCC to generate worse code.
Interesting. Gcc obviously will do the right thing without "packed", at least on "current" architectures, but I don't know what the C standard says. I will remove it, thanks.
Signature · 1 line
Krzysztof Halasa
Review
Quoted 5 lines · Krzysztof Halasa
(quoted diff) +5
-0+ /* LCP only */ + if (pid == PID_LCP) + switch (cp->code) { + case LCP_PROTO_REJ: + pid = ntohs(*(__be16*)skb->data);
What if skb->data happens to be unaligned (can that even happen?)
BTW, here are some consts:
drivers/net/wan/hdlc_ppp.c +4 -4
@@ -40,7 +40,7 @@ enum {CP_CONF_REQ = 1, CP_CONF_ACK, CP_CONF_NAK, CP_CONF_REJ, CP_TERM_REQ,CP_TERM_ACK ,CP_CODE_REJ ,LCP_PROTO_REJ ,LCP_ECHO_REQ ,LCP_ECHO_REPLY , LCP_DISC_REQ, CP_CODES};#if DEBUG_CP -static const char *code_names[CP_CODES ] = {"0" ,"ConfReq" ,"ConfAck" , +static const char *const code_names[] = {"0" ,"ConfReq" ,"ConfAck" ,"ConfNak" ,"ConfRej" ,"TermReq" ,"TermAck" ,"CodeRej" ,"ProtoRej" ,"EchoReq" ,"EchoReply" ,"Discard" };
@@ -90,10 +90,10 @@ enum {INV = 0x10, IRC = 0x20, ZRC = 0x40, SCR = 0x80, SCA = 0x100, SCN = 0x200, STR = 0x400, STA = 0x800, SCJ = 0x1000};#if DEBUG_STATE -static const char *state_names[STATES ] = {"Closed" ,"Stopped" ,"Stopping" , +static const char *const state_names[] = {"Closed" ,"Stopped" ,"Stopping" ,"ReqSent" ,"AckRecv" ,"AckSent" ,"Opened" }; -static const char *event_names[EVENTS ] = {"Start" ,"Stop" ,"TO+" ,"TO-" , +static const char *const event_names[] = {"Start" ,"Stop" ,"TO+" ,"TO-" ,"RCR+" ,"RCR-" ,"RCA" ,"RCN" ,"RTR" ,"RTA" ,"RUC" ,"RXJ+" ,"RXJ-" };#endif
@@ -374,7 +374,7 @@ static void ppp_cp_event(struct net_device *dev, u16 pid, u16 event, u8 code,static void ppp_cp_parse_cr (struct net_device *dev,u16 pid,u8 id,unsigned int len,u8 *data) { -static u8 valid_accm[6 ] = {LCP_OPTION_ACCM ,6 ,0 ,0 ,0 ,0 }; +static const u8 valid_accm[] = {LCP_OPTION_ACCM ,6 ,0 ,0 ,0 ,0 };u8 *opt, *out;unsigned int nak_len =0 , rej_len =0 ;
Krzysztof Halasa
maintainerQuoted 7 lines · Jan Engelhardt
Review
Quoted 5 lines
(quoted diff) +5
-0+ /* LCP only */ + if (pid == PID_LCP) + switch (cp->code) { + case LCP_PROTO_REJ: + pid = ntohs(*(__be16*)skb->data);What if
skb->datahappens to be unaligned (can that even happen?)
It can't if the hdlc header is 32-bit aligned... however, I can now see the above is buggy, skb->data doesn't point to the protocol field. Unused code paths :-(
drivers/net/wan/hdlc_ppp.c enum {CP_CONF_REQ = 1, CP_CONF_ACK, CP_CONF_NAK, CP_CONF_REJ, CP_TERM_REQ, · line 46
Quoted 5 lines
drivers/net/wan/hdlc_ppp.c +1
-1-static const char *code_names[CP_CODES ] = {"0" ,"ConfReq" ,"ConfAck" , +static const char *const code_names[] = {"0" ,"ConfReq" ,"ConfAck" ,"ConfNak" ,"ConfRej" ,"TermReq" ,"TermAck" ,"CodeRej" ,"ProtoRej" ,"EchoReq" ,"EchoReply" ,"Discard" };
The explicit sizes are there as a prevention.
Thanks.
Signature · 1 line
Krzysztof Halasa
Quoted 8 lines · Krzysztof Halasa
drivers/net/wan/hdlc_ppp.c enum {CP_CONF_REQ = 1, CP_CONF_ACK, CP_CONF_NAK, CP_CONF_REJ, CP_TERM_REQ, · line 46
Quoted 6 lines
drivers/net/wan/hdlc_ppp.c +1
-1-static const char *code_names[CP_CODES ] = {"0" ,"ConfReq" ,"ConfAck" , +static const char *const code_names[] = {"0" ,"ConfReq" ,"ConfAck" ,"ConfNak" ,"ConfRej" ,"TermReq" ,"TermAck" ,"CodeRej" ,"ProtoRej" ,"EchoReq" ,"EchoReply" ,"Discard" };The explicit sizes are there as a prevention.
You can keep them if you need, the main issue was const anyway.
Krzysztof Halasa
maintainerQuoted 3 lines · Krzysztof Halasa
It can't if the hdlc header is 32-bit aligned... however, I can now see the above is buggy,
skb->datadoesn't point to the protocol field. Unused code paths :-(
Actually I was wrong, the code is correct and skb->data points to the proto ID.
PATCH v2 is on the way.
Signature · 1 line
Krzysztof Halasa
Krzysztof Halasa
maintainerNew synchronous PPP implementation for generic HDLC.
drivers/net/wan/Makefile | 2 +- drivers/net/wan/hdlc_ppp.c | 649 ++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 602 insertions(+), 49 deletions(-)
drivers/net/wan/Makefile +1 -1
@@ -14,7 +14,7 @@ obj-$(CONFIG_HDLC_RAW) += hdlc_raw.o obj-$(CONFIG_HDLC_RAW_ETH) += hdlc_raw_eth.o obj-$(CONFIG_HDLC_CISCO) += hdlc_cisco.o obj-$(CONFIG_HDLC_FR) += hdlc_fr.o -obj-$(CONFIG_HDLC_PPP) += hdlc_ppp.o syncppp.o +obj-$(CONFIG_HDLC_PPP) += hdlc_ppp.o obj-$(CONFIG_HDLC_X25) += hdlc_x25.o pc300-y := pc300_drv.o
drivers/net/wan/hdlc_ppp.c +601 -48
732 lines not on this page · raw message
Krzysztof Halasa
maintainerHi,
Quoted 1 line · I wrote:
New synchronous PPP implementation for generic HDLC.
So are we leaving the generic-HDLC+PPP in broken state for 2.6.25, aren't we?
If we do, perhaps a "|| BROKEN" in drivers/net/wan/Kconfig would make sense? Any attempt to use it will cause kernel panic immediately (PPP with generic HDLC only; drivers using syncppp.c directly are not affected). I can make that trivial Kconfig patch of course.
Signature · 1 line
Krzysztof Halasa
Quoted 6 lines · Krzysztof Halasa
Hi,
Quoted 1 line · I wrote:
New synchronous PPP implementation for generic HDLC.
Quoted 7 lines
So are we leaving the generic-HDLC+PPP in broken state for 2.6.25, aren't we?
If we do, perhaps a "|| BROKEN" in
drivers/net/wan/Kconfigwould make sense? Any attempt to use it will cause kernel panic immediately (PPP with generic HDLC only; drivers usingsyncppp.cdirectly are not affected). I can make that trivialKconfigpatch of course.
In your original email you said
I guess it should go into 2.6.25, not sure about "stable" series. I will appreciate any feedback, review and/or test results.
At the time of the posting 2.6.25-rc6 had already been released, which seems like an inappropriate time for all that new code, which has been given so little exposure to real world testing.
Certainly your original message said PPP panics, but without even minimal testing how do we know that your new code doesn't have equally problematic issues?
So quite honestly a CONFIG_BROKEN patch might indeed be more appropriate since generic HDLC works with Frame Relay at least...
Comments? IMO the current code is a known risk (PPP panic, FR works) whereas the new code is an unknown risk very late in 2.6.25-rc -- but with a good chance to make HDLC+PPP work again.
Jeff
Krzysztof Halasa
maintainerQuoted 3 lines · Jeff Garzik
I guess it should go into 2.6.25, not sure about "stable" series. I will appreciate any feedback, review and/or test results.
Right. Perhaps I should care a bit more about the stable series...
Quoted 3 lines
At the time of the posting 2.6.25-rc6 had already been released, which seems like an inappropriate time for all that new code, which has been given so little exposure to real world testing.
Sure.
Quoted 3 lines
Certainly your original message said PPP panics, but without even minimal testing how do we know that your new code doesn't have equally problematic issues?
Well, there was something like "minimal testing", and it doesn't panic 100% like the old code does. But the probability that it won't work correctly is quite high.
IOW: the new version is certainly better than the old one, though it's not the normal quality (in terms of testing) I'd like to see.
Quoted 2 lines
So quite honestly a
CONFIG_BROKENpatch might indeed be more appropriate since generic HDLC works with Frame Relay at least...
Actually Frame Relay and other protocols are not affected, the PPP patch doesn't change them a bit, it's a different module. The new code only affect PPP protocol.
I'm fine with the Kconfig patch, actually I'm not sure what is better at this time - a known broken module marked as such or a new module with some small chances that it will crash the machine and with much bigger chances that it won't work with a certain PPP implementation on the other end.
Something like that?
Untested :-)
drivers/net/wan/Kconfig +5 -1
@@ -150,9 +150,13 @@ config HDLC_FR config HDLC_PPP tristate "Synchronous Point-to-Point Protocol (PPP) support" - depends on HDLC + depends on HDLC && BROKEN help Generic HDLC driver supporting PPP over WAN connections. + This module is currently broken and will cause a kernel panic + when a device configured in PPP mode is activated. + + It will be replaced by new PPP implementation in Linux 2.6.26. If unsure, say N.
David Miller
maintainerFrom: Krzysztof Halasa <[email protected]>
Date: Tue, 25 Mar 2008 15:39:49 +0100
Quoted 4 lines
Quoted 1 line
New synchronous PPP implementation for generic HDLC.
So are we leaving the generic-HDLC+PPP in broken state for 2.6.25, aren't we?
Kyzysztof, this is the way you behave every time your patches don't get looked at as quickly as you would like them to.
And this behavior does not trigger us maintainers to stop everything we're doing and apply your patches.
In fact it makes us want to review your patches even less.
Sending a healthy ping asking if your patches need to be resent, etc., is one thing. But this isn't what you're doing here.
Krzysztof Halasa
maintainerQuoted 7 lines · David Miller
Kyzysztof, this is the way you behave every time your patches don't get looked at as quickly as you would like them to.
And this behavior does not trigger us maintainers to stop everything we're doing and apply your patches.
Quoted 6 lines
In fact it makes us want to review your patches even less.
Sending a healthy ping asking if your patches need to be resent, etc., is one thing. But this isn't what you're doing here.
I don't know what are you talking about.
- someone broke my drivers, happens from time to time
- I asked about related change and was told about some "out of tree" drivers instead
- I had two modules to fix, one took 15 minutes and for the other one I had no time at the moment.
- I finally rewrote the other module
- got feedback, corrected it, resent.
- asked if we are including it in 2.6.25 or if we are to make temporary Kconfig change instead
What exactly don't you like in my "behaviour"? I didn't invent synchronous serial devices. Actually, I'm doing it all in my free time, and I'm sure I can find better things to do in that time.
I accept I may use not the best wording from time to time, I'm not native English writter.
What is your problem about me?
I'd appreciate it if you point out the precise things I'm doing wrong.
Thanks.
Signature · 1 line
Krzysztof Halasa
Krzysztof Halasa
maintainerQuoted 2 lines · Jeff Garzik
So quite honestly a
CONFIG_BROKENpatch might indeed be more appropriate since generic HDLC works with Frame Relay at least...
Actually my question was intended for Andrew as he has already queued the PPP patch - I probably should have rearranged To/Cc:
headers, sorry about that.
The question still stands: I guess it's fair enough to have either patch in 2.6.25 (new PPP or "BROKEN" in Kconfig) but I think we shouldn't leave it as is.
Signature · 1 line
Krzysztof Halasa
Krzysztof Halasa
maintainerHi,
Quoted 5 lines · I wrote:
So are we leaving the generic-HDLC+PPP in broken state for 2.6.25, aren't we?
If we do, perhaps a "|| BROKEN" in
drivers/net/wan/Kconfigwould make sense?
Linus just made 2.6.25-rclast (I hope), I understand 2.6.25 will have broken drivers/net/wan/hdlc_ppp, any chance to apply the temporary Kconfig ("depends on BROKEN") patch?
Would you like me to resend it?
TIA.
Signature · 1 line
Krzysztof Halasa
Quoted 7 lines · On Fri, 11 Apr 2008 23:35:23 +0200 Krzysztof Halasa <[email protected]> wrote:
Hi,
Quoted 3 lines · I wrote:
So are we leaving the generic-HDLC+PPP in broken state for 2.6.25, aren't we?
Quoted 8 lines
Quoted 2 lines
If we do, perhaps a "|| BROKEN" in
drivers/net/wan/Kconfigwould make sense?Linus just made 2.6.25-rclast (I hope), I understand 2.6.25 will have broken
drivers/net/wan/hdlc_ppp, any chance to apply the temporaryKconfig("depends on BROKEN") patch?Would you like me to resend it?
It never hurts to resend. It was 6000 patches ago and my mind is a blank.
Krzysztof Halasa
maintainerQuoted 1 line · Andrew Morton
It never hurts to resend. It was 6000 patches ago and my mind is a blank.
Sure, here is it. Some description, well:
PPP support in generic HDLC in Linux 2.6.25 is broken and will cause a kernel panic when a device configured in PPP mode is activated.
It will be replaced by new PPP implementation after Linux 2.6.25 is released.
This affects only PPP support in generic HDLC (mostly Hitachi SCA and SCA-II based drivers, wanxl, and few others). Standalone syncppp and async PPP support are not affected.
Untested :-)
drivers/net/wan/Kconfig +5 -1
@@ -150,9 +150,13 @@ config HDLC_FR config HDLC_PPP tristate "Synchronous Point-to-Point Protocol (PPP) support" - depends on HDLC + depends on HDLC && BROKEN help Generic HDLC driver supporting PPP over WAN connections. + This module is currently broken and will cause a kernel panic + when a device configured in PPP mode is activated. + + It will be replaced by new PPP implementation in Linux 2.6.26. If unsure, say N.
Jeff Garzik
AppliedQuoted 6 lines · Krzysztof Halasa
drivers/net/wan/Kconfig +0
-0@@ -150,9 +150,13 @@ config HDLC_FR config HDLC_PPP tristate "Synchronous Point-to-Point Protocol (PPP) support"
drivers/net/wan/Kconfig config HDLC_FR · line 161
Quoted 10 lines
drivers/net/wan/Kconfig +5
-1- depends on HDLC + depends on HDLC && BROKEN help Generic HDLC driver supporting PPP over WAN connections. + This module is currently broken and will cause a kernel panic + when a device configured in PPP mode is activated. + + It will be replaced by new PPP implementation in Linux 2.6.26. If unsure, say N.
applied
Jeff Garzik
AppliedQuoted 13 lines · Krzysztof Halasa
New synchronous PPP implementation for generic HDLC.
Signed-off-by Krzysztof Halasa <[email protected]>drivers/net/wan/Makefile | 2 +- drivers/net/wan/hdlc_ppp.c | 649 ++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 602 insertions(+), 49 deletions(-)drivers/net/wan/Makefile +0
-0
drivers/net/wan/Makefile obj-$(CONFIG_HDLC_RAW) += hdlc_raw.o · line 18
Quoted 6 lines
drivers/net/wan/Makefile +1
-1@@ -14,7 +14,7 @@ obj-$(CONFIG_HDLC_RAW) += hdlc_raw.o obj-$(CONFIG_HDLC_RAW_ETH) += hdlc_raw_eth.o obj-$(CONFIG_HDLC_CISCO) += hdlc_cisco.o obj-$(CONFIG_HDLC_FR) += hdlc_fr.o -obj-$(CONFIG_HDLC_PPP) += hdlc_ppp.o syncppp.o +obj-$(CONFIG_HDLC_PPP) += hdlc_ppp.o obj-$(CONFIG_HDLC_X25) += hdlc_x25.o
applied
Quoted 11 lines · On Sat, 12 Apr 2008 10:10:40 +0200 Krzysztof Halasa <[email protected]> wrote:
Quoted 1 line · Andrew Morton
It never hurts to resend. It was 6000 patches ago and my mind is a blank.
Sure, here is it. Some description, well:
PPP support in generic HDLC in Linux 2.6.25 is broken and will cause a kernel panic when a device configured in PPP mode is activated.
It will be replaced by new PPP implementation after Linux 2.6.25 is released.
Thats a pretty bad regression. Surely the correct fix is to revert the change series that caused the breakage then re-merge that and fixes for HDLC PPP for 2.6.26, not just leave it broken ?
Krzysztof Halasa
maintainerQuoted 1 line · Jeff Garzik
applied
[two of them]
Great, thanks.
Signature · 1 line
Krzysztof Halasa
Krzysztof Halasa
maintainerQuoted 9 lines · Alan Cox
Quoted 5 lines
PPP support in generic HDLC in Linux 2.6.25 is broken and will cause a kernel panic when a device configured in PPP mode is activated.
It will be replaced by new PPP implementation after Linux 2.6.25 is released.
Thats a pretty bad regression. Surely the correct fix is to revert the change series that caused the breakage then re-merge that and fixes for HDLC PPP for 2.6.26, not just leave it broken ?
It's not that simple - it was broken between 2.6.22 and 2.6.23 (2.6.23 was already broken), I just haven't noticed (I don't use PPP myself, except for tests).
author Peter P Waskiewicz Jr <[email protected]>
Fri, 6 Jul 2007 20:36:20 +0000 (13:36 -0700)
commit f25f4e44808f0f6c9875d94ef1c41ef86c288eb2
[CORE] Stack changes to add multiqueue hardware support API Add the multiqueue hardware device support API to the core network stack. Allow drivers to allocate multiple queues and manage them at the netdev level if they choose to do so.
Added a new field to sk_buff, namely queue_mapping, for drivers to know which tx_ring to select based on OS classification of the flow.
And it included:
include/linux/netdevice.h +1 -3
@@ -565,9 +578,7 @@ struct net_devicestatic inline void *netdev_priv (const struct net_device *dev) { -return (char *)dev + ((sizeof (struct net_device ) - +NETDEV_ALIGN_CONST ) - & ~NETDEV_ALIGN_CONST ); +return dev->priv; }#define SET_MODULE_OWNER (dev) do { } while (0)
HDLC PPP sits between hardware drivers and (in this case) syncppp.c, and it (hdlc_ppp module) was using netdev_priv() as a pointer to the memory allocated with (after) the netdev structure. dev->priv was used by syncppp.c.
HDLC FR was also broken by this change but the fix was easy because there is no external protocol module to interface to.
I didn't want to add to the HDLC PPP mess anymore and have rewritten it instead (in process, it turned out syncppp alone, and syncppp + HDLC have much more problems than I thought). Obviously I was way too late for 2.6.25 (past 2.6.25-rc5 and the new code wasn't much tested).
Yes, I could add another dirty "interface fix" to the HDLC + syncppp combo (hdlc_ppp), but I don't really see a sense, especially that I have the new implementation ready and working (my time resources are currently quite limited and if I have to choose between adding another glue fix and writing a better PPP replacement I pick the latter).
My original post: http://lkml.org/lkml/2008/3/12/277
Signature · 1 line
Krzysztof Halasa
Quoted 20 lines
It's not that simple - it was broken between 2.6.22 and 2.6.23 (2.6.23 was already broken), I just haven't noticed (I don't use PPP myself, except for tests).
author Peter P Waskiewicz Jr <[email protected]>
Fri, 6 Jul 2007 20:36:20 +0000 (13:36 -0700)commit
f25f4e44808f0f6c9875d94ef1c41ef86c288eb2[CORE] Stack changes to add multiqueue hardware support API Add the multiqueue hardware device support API to the core network stack. Allow drivers to allocate multiple queues and manage them at the netdev level if they choose to do so.
Added a new field to
sk_buff, namelyqueue_mapping, for drivers to know whichtx_ringto select based on OS classification of the flow.And it included:
include/linux/netdevice.h struct net_device · line 582
Quoted 8 lines
include/linux/netdevice.h +1
-3@@ -565,9 +578,7 @@ struct net_devicestatic inline void *netdev_priv (const struct net_device *dev) { -return (char *)dev + ((sizeof (struct net_device ) - +NETDEV_ALIGN_CONST ) - & ~NETDEV_ALIGN_CONST ); +return dev->priv; }
What I find a bit disturbing is I found my original patchsets I submitted to the list that were committed for this patchset. My original patches don't have this change in them at all. :-(
-PJ Waskiewicz
David Miller
maintainerFrom: "Waskiewicz Jr, Peter P" <[email protected]>
Date: Mon, 14 Apr 2008 12:16:55 -0700
Quoted 3 lines
What I find a bit disturbing is I found my original patchsets I submitted to the list that were committed for this patchset. My original patches don't have this change in them at all. :-(
Ummmm, if you remember we had to put that in because it was the only way to get your multiqueue changes to even work.
So don't even act as if that got slipped in behind your back, unknowingly. You were absolutely informed about this.
Krzysztof Halasa
maintainerUpdate:
Quoted 8 lines
Yes, I could add another dirty "interface fix" to the HDLC + syncppp combo (
hdlc_ppp), but I don't really see a sense, especially that I have the new implementation ready and working (my time resources are currently quite limited and if I have to choose between adding another glue fix and writing a better PPP replacement I pick the latter).My original post: http://lkml.org/lkml/2008/3/12/277
David doesn't want the new PPP, insisting that I fix existing hdlc_ppp.c + syncppp.c combo instead, and that there are related bugs in drivers using syncppp.c alone (not hdlc_ppp) which I have to fix as well.
Unfortunately I'm unable to do that. Even if I could add another workaround to hdlc_ppp to make it work with syncppp.c again, I can't fix the other drivers (if they are indeed broken) because of lack of hardware, and I can't really make significant changes to syncppp.c (to make them available to all drivers) because that could and would break those drivers.
Comments?
Signature · 1 line
Krzysztof Halasa
David Miller
maintainerFrom: Krzysztof Halasa <[email protected]>
Date: Fri, 18 Apr 2008 17:58:48 +0200
Quoted 1 line
Comments?
I'll fix it properly because I know you won't do the work. You don't need to keep making excuses.
Krzysztof Halasa
maintainerQuoted 1 line · David Miller
I'll fix it properly because I know you won't do the work.
Great to read that.
Just few friendly after all notes so that you don't waste your time learning that yourself:
- my patch didn't give us a third PPP implementation, we already have
three: generic PPP, syncppp and PPP for ISDN :-)
- of those, both generic PPP and (I think) ISDN PPP are in a good shape
- generic PPP is specialized for dial-up async devices and has the required features (in kernel and in userspace pppd) - auth, multi-line, compression etc. It's a "lets give /dev/ttyS* a network device" implementation.
- ISDN PPP does for ISDN cards basically the same as generic PPP does for terminals. They are completely different from syncppp as the needs are completely different. Fixed-line PPP must be small and fast, and self-contained.
Now syncppp.c and sync serial (HDLC) cards. We basically have three categories of hardware:
- mostly old ISA cards (cosa, cyclom-2x, z85230, s502/s508, personally I have c101 and n2 for tests, and PCI wanxl400). I think Alan maintains Zilog drivers, other "old" drivers are not maintained at all. They use syncppp.c directly (except c101, n2 and wanxl using generic HDLC).
The list was longer but few drivers have been removed recently.
- cards with in-kernel obsolete drivers and users encouraged to use manufacturers' driver - lmc.
- a bit more modern PCI cards such as pc300, pci200syn, synclinks, dscc4, farsync, some off-tree ones. They use generic HDLC.
- I have offered to port any remaining old driver to generic HDLC if I'm sent a hardware sample. Synclink, dscc4 and farsync have been ported by other people.
I would be surprised to find that the "old" drivers are still functional. Nevertheless syncppp.c is functional (though marginally) and I think there are no bugs related to dev->priv and netdev_priv() for those drivers.
The real problem with old drivers is the lack of hardware. Personally I suspect they may have 0 users worldwide.
Syncppp.c is the problem for newer cards:
- the support has been broken recently due to netdev_priv() changes (could be band-aided).
- it's missing IPv6 and adding it is not trivial
- it's not RFC/STD-compliant at all, i.e. breaks many "MUST" rules and doesn't work with some other compliant implementations, and fixing that would be a real PITA,
- the code is really hard to parse/understand/maintain, it looks a bit like it was written in some other language and then "compiled" into C machine code :-)
- the lack of hardware makes doing significant changes to the drivers and syncppp almost impossible, without breaking them (if they aren't already broken).
That's why I came to an idea that leaving syncppp and the old drivers in their current bit-rotting state which nobody can really fix, and using another (fourth, and third when syncppp eventually dies) PPP implementation is the only way out of this situation.
HTH.
Signature · 1 line
Krzysztof Halasa
Quoted 6 lines · Krzysztof Halasa
Quoted 1 line · David Miller
I'll fix it properly because I know you won't do the work.
Great to read that.
Quoted 10 lines
Just few friendly after all notes so that you don't waste your time learning that yourself:
- my patch didn't give us a third PPP implementation, we already have
three: generic PPP, syncppp and PPP for ISDN :-)
- of those, both generic PPP and (I think) ISDN PPP are in a good shape
- generic PPP is specialized for dial-up async devices and has the required features (in kernel and in userspace pppd) - auth, multi-line, compression etc. It's a "lets give/dev/ttyS*a network device" implementation.
Generic ppp isn't specialized at all, and it isn't limited to async serial devices. PPPoE, PPPoATM and L2TP use it.
Quoted 4 lines
- ISDN PPP does for ISDN cards basically the same as generic PPP does for terminals. They are completely different from syncppp as the needs are completely different. Fixed-line PPP must be small and fast, and self-contained.
<snip>
Quoted 4 lines
That's why I came to an idea that leaving syncppp and the old drivers in their current bit-rotting state which nobody can really fix, and using another (fourth, and third when syncppp eventually dies) PPP implementation is the only way out of this situation.
Can you elaborate on why the code that uses syncppp can't use the generic ppp code together with a userspace ppp control protocol implementation like pppd?
Signature · 4 lines
James Chapman Katalix Systems Ltd http://www.katalix.com Catalysts for your Embedded Linux software development
Krzysztof Halasa
maintainerQuoted 2 lines · James Chapman
Generic ppp isn't specialized at all, and it isn't limited to async serial devices. PPPoE, PPPoATM and L2TP use it.
Perhaps I should write "dial-up" and other non-fixed connections.
It's complex, I think kernel interface to generic HDLC would mean more code than PPP implementation required for fixed lines. Additional requirement - userspace daemon with additional plugin - may not be the best thing for fixed lines either.
That would break backward compatibility, too.
Personally I think it could be acceptable but it's not for me to decide.
Signature · 1 line
Krzysztof Halasa
Quoted 22 lines · Paul Fulghum
Quoted 6 lines · Krzysztof Halasa
It's complex, I think kernel interface to generic HDLC would mean more code than PPP implementation required for fixed lines. Additional requirement - userspace daemon with additional plugin - may not be the best thing for fixed lines either.
That would break backward compatibility, too.
I maintain both pppd and generic HDLC PPP interfaces for the synclink drivers.
I would like to have a single PPP implementation, but what Krzysztof writes about compatibility and complexity (both in coding and user configuration) is a real issue.Many customers who choose to use generic HDLC PPP are *dead* set against the added complexity and (user space) components of using pppd even though it has more features. I say that having tried to persuade such users to use pppd. The response is usually "support the simpler generic HDLC PPP way of doing things or we will go elsewhere". Others require the extra features of pppd.
Quoted 5 lines
I understand customer desires are not always rational or a primary concern when making these architectural decisions, but I know forcing the extra complexity and components of pppd on generic HDLC users will cause a lot of anger and defections.
The fact that Krzysztof's solution was _small_ and _clean_ and easily maintainable was the reason I merged it [into my tree].
IMO sometimes "one size fits all" is not the best solution.
Jeff
Quoted 6 lines · Krzysztof Halasa
It's complex, I think kernel interface to generic HDLC would mean more code than PPP implementation required for fixed lines. Additional requirement - userspace daemon with additional plugin - may not be the best thing for fixed lines either.
That would break backward compatibility, too.
I maintain both pppd and generic HDLC PPP interfaces for the synclink drivers.
I would like to have a single PPP implementation, but what Krzysztof writes about compatibility and complexity (both in coding and user configuration) is a real issue.
Many customers who choose to use generic HDLC PPP are *dead* set against the added complexity and (user space) components of using pppd even though it has more features. I say that having tried to persuade such users to use pppd. The response is usually "support the simpler generic HDLC PPP way of doing things or we will go elsewhere". Others require the extra features of pppd.
I understand customer desires are not always rational or a primary concern when making these architectural decisions, but I know forcing the extra complexity and components of pppd on generic HDLC users will cause a lot of anger and defections.
Signature · 2 lines
Paul Fulghum Microgate Systems, Ltd.
David Miller
maintainerFrom: Paul Fulghum <[email protected]>
Date: Tue, 22 Apr 2008 15:46:27 -0600
Quoted 2 lines
The response is usually "support the simpler generic HDLC PPP way of doing things or we will go elsewhere".
Users say this to strong-hand developers, it's not something you should ever take very seriously. And even if Linux may simply not be for them, well that's fine too, and implementing something as obscure as HDLC PPP one way or the other is not going to change that.
I mean, be realistic here.
Are we going to have three copies of code implementing the same thing because some HDLC PPP users threatened to defect? That's simply rediculious.
David Miller
maintainerFrom: Jeff Garzik <[email protected]>
Date: Tue, 22 Apr 2008 16:50:41 -0400
Quoted 4 lines
The fact that Krzysztof's solution was _small_ and _clean_ and easily maintainable was the reason I merged it [into my tree].
IMO sometimes "one size fits all" is not the best solution.
This is besides the point. We are discussing two things here:
1) How to "correctly" fix the syncppp private area bug.
2) How to, long term, support PPP properly in the kernel for various users.
The fact that non-HDLC users of syncppp got left broken is why I objected to the change you merged in Jeff. It simply duplicated the majority of syncppp into the HDLC PPP code, which is just rediculious.
That had nothing to do with whether we should, in the long term, use the generic PPP infrastructure we have now.
I would have been more than happy if syncppp was retained and fixed properly, instead of being abandoned and duplicated in one fell swoop. We don't do things like that Jeff.
Quoted 23 lines · Jeff Garzik
Quoted 22 lines · Paul Fulghum
Quoted 6 lines · Krzysztof Halasa
It's complex, I think kernel interface to generic HDLC would mean more code than PPP implementation required for fixed lines. Additional requirement - userspace daemon with additional plugin - may not be the best thing for fixed lines either.
That would break backward compatibility, too.
I maintain both pppd and generic HDLC PPP interfaces for the synclink drivers.
I would like to have a single PPP implementation, but what Krzysztof writes about compatibility and complexity (both in coding and user configuration) is a real issue.Many customers who choose to use generic HDLC PPP are *dead* set against the added complexity and (user space) components of using pppd even though it has more features. I say that having tried to persuade such users to use pppd. The response is usually "support the simpler generic HDLC PPP way of doing things or we will go elsewhere". Others require the extra features of pppd.
Quoted 5 lines
Quoted 5 lines
I understand customer desires are not always rational or a primary concern when making these architectural decisions, but I know forcing the extra complexity and components of pppd on generic HDLC users will cause a lot of anger and defections.
Are there technical reasons or is the complexity just a lack of familiarity?
Quoted 3 lines
The fact that Krzysztof's solution was _small_ and _clean_ and easily maintainable was the reason I merged it [into my tree].
IMO sometimes "one size fits all" is not the best solution.
I guess what caught my eye is a PPP control protocol implementation being in the kernel. I'd seen syncppp before but I assumed it was there for legacy reasons. A while ago there seemed to be strong desire to move control protocols such as bridge spanning tree into userspace. Is this no longer the case?
Signature · 4 lines
James Chapman Katalix Systems Ltd http://www.katalix.com Catalysts for your Embedded Linux software development
David Miller
maintainerFrom: James Chapman <[email protected]>
Date: Tue, 22 Apr 2008 23:23:31 +0100
Quoted 5 lines
I guess what caught my eye is a PPP control protocol implementation being in the kernel. I'd seen syncppp before but I assumed it was there for legacy reasons. A while ago there seemed to be strong desire to move control protocols such as bridge spanning tree into userspace. Is this no longer the case?
It is still the case, believe me :-)
Quoted 4 lines · David Miller
Users say this to strong-hand developers, it's not something you should ever take very seriously. And even if Linux may simply not be for them, well that's fine too, and implementing something as obscure as HDLC PPP one way or the other is not going to change that.
Certainly not a big deal for Linux, but more
significant for vendors of HDLC hardware :-)
Quoted 2 lines · David Miller
I would have been more than happy if syncppp was retained and fixed properly, instead of being abandoned and duplicated in one fell swoop.
I'd be happy with that also. I was responding to the suggestion of merging generic HDLC PPP with the pppd implementation. It's been suggested before, but doing so looks messy.
Quoted 7 lines · James Chapman
Quoted 3 lines · Paul Fulghum
Many customers who choose to use generic HDLC PPP are *dead* set against the added complexity and (user space) components of using pppd even though it has more features.
Are there technical reasons or is the complexity just a lack of familiarity?
From what I can tell it was an existing investment in scripts, training, tools, naming conventions, etc. Even when provided with new tools and scripts that do the same thing (as far as I could tell) the response was suprisingly vehement against change.
--
Paul
Krzysztof Halasa
maintainerQuoted 1 line · David Miller
The fact that non-HDLC users of syncppp got left broken
The fact is it isn't broken WRT dev->priv at least (I don't know about random unrelated breakage).
The drivers:
a) alloc a netdev
b) set dev->priv to some private kmalloced area
It was like that for years, and it worked. The commit in question changed netdev_priv() and the drivers don't use this function.
netdev_priv() was introduced at some point in time to allow alloc_netdev() to optionally allocate additional memory for internal use by the driver. It had nothing to do with dev->priv except "priv" name. The drivers don't use it passing size 0.
This is probably suboptimal (two+ allocations instead of one), if the drivers had maintainers with access to hardware I guess it would be optimized, but it has nothing to do with the regression.
The regression is present in HDLC PPP only, becase HDLC PPP actually used netdev_priv() (unlike non-HDLC PPP cases) as a means of addressing the area following net_device struct and not for retrieving dev->priv, and then the semantics suddenly changed.
Quoted 2 lines
I would have been more than happy if syncppp was retained and fixed properly, instead of being abandoned and duplicated in one fell swoop.
I would be happy as well. The problem is that nobody shown any idea how to do it.
I have offered: I will port any existing sync serial driver to generic HDLC if I'm sent a free hardware sample. That includes old ISA cards (I still have an old 2*PII-333 ISA test machine), and porting PC300 T1/E1 code to pc300too.
If some driver/hw has no users I think there is no point in keeping it on life support here. The same goes for syncppp - if/when the number of drivers using it drops to zero, we can let it go.
Signature · 1 line
Krzysztof Halasa
David Miller
maintainerFrom: Krzysztof Halasa <[email protected]>
Date: Wed, 23 Apr 2008 19:02:22 +0200
Quoted 4 lines
netdev_priv()was introduced at some point in time to allowalloc_netdev()to optionally allocate additional memory for internal use by the driver. It had nothing to do withdev->privexcept "priv" name. The drivers don't use it passing size 0.
No, it was added as an optimization since the private area was allocated together with the struct netdev, and thus at a constant offset computable a compile time.
It was never meant to provide a facility to have two private areas associated with a device, but unfortunately some broken stuff decided to use it that way.
Krzysztof Halasa
maintainerQuoted 3 lines · David Miller
No, it was added as an optimization since the private area was allocated together with the struct netdev, and thus at a constant offset computable a compile time.
That's essentially what I meant. And it has changed, call it whatever you wish.
Signature · 1 line
Krzysztof Halasa
David Miller
maintainerFrom: Krzysztof Halasa <[email protected]>
Date: Thu, 24 Apr 2008 02:48:29 +0200
Quoted 8 lines
Quoted 3 lines · David Miller
No, it was added as an optimization since the private area was allocated together with the struct netdev, and thus at a constant offset computable a compile time.
That's essentially what I meant. And it has changed, call it whatever you wish.
The core kernel code sets dev->priv to the alloc_netdev() allocated memory region.
It doesn't do that just for fun.
Any code which overrides that setting is asking for trouble. What if the code kernel code that set it, needed to use it during device release for some reason?
Krzysztof Halasa
maintainerQuoted 8 lines · David Miller
The core kernel code sets
dev->privto thealloc_netdev()allocated memory region.It doesn't do that just for fun.
Any code which overrides that setting is asking for trouble. What if the code kernel code that set it, needed to use it during device release for some reason?
You are right, the point is Linux is a moving target, and I try to write code as good as I can in given circumstances but never better. I accept occasional breakage in obscure cases like syncppp+hdlc, but I also need a way to fix it and/or remove the obscureness (or whatever the right word is).
Historically we always have had two pointers:
- dev->priv
- first we had struct (net_)device *dev and by embedding it in larger structure we were able to have another private data area (even with Space.c)
- then netdev_alloc() and netdev_priv() came
- since 2.6.23 netdev_priv() returns dev->priv - one pointer is gone.
Anyway, I guess we should rather concentrate on what to do now with the thing. Perhaps you have some idea?
Signature · 1 line
Krzysztof Halasa
David Miller
maintainerFrom: Krzysztof Halasa <[email protected]>
Date: Thu, 24 Apr 2008 15:12:17 +0200
Quoted 2 lines
Anyway, I guess we should rather concentrate on what to do now with the thing. Perhaps you have some idea?
My current plan is to add an "official" mid-layer pointer for these purposes. So that the bug can have a simple fix while we think about how better to handle this longer term.
Krzysztof Halasa
maintainerQuoted 3 lines · David Miller
My current plan is to add an "official" mid-layer pointer for these purposes. So that the bug can have a simple fix while we think about how better to handle this longer term.
That would be great first step.
Though we will have to abandon syncppp use anyway, at least for generic HDLC (I don't care much about the old ISA drivers).
Signature · 1 line
Krzysztof Halasa
David Miller
maintainerFrom: Krzysztof Halasa <[email protected]>
Date: Thu, 24 Apr 2008 15:39:47 +0200
Quoted 2 lines
Though we will have to abandon syncppp use anyway, at least for generic HDLC (I don't care much about the old ISA drivers).
That, I still don't understand.
I would rather see you add small extensions to syncppp to provide for HDLC's needs, rather than reimplement it.
Krzysztof Halasa
maintainerQuoted 2 lines · David Miller
I would rather see you add small extensions to syncppp to provide for HDLC's needs, rather than reimplement it.
It's not about extensions, syncppp is just unmaintainable. It's implementation of two protocols - Cisco HDLC and (sync) PPP intermixed together.
What would be needed is a) splitting them into two files (including protocol selection in drivers - somehow), b) replacing existing broken syncppp state machines distributed all over the place with a single sane state machine, c) perhaps adding IPv6, people want it,
d) packet flow from hw drivers would need to be upgraded as well (*_type_trans() and fast path for IP/IPv6 and perhaps IPX, though I don't know anyone ever using IPX with sync PPP).
I guess then you'd get generic HDLC.
I think it's easier to a) simply remove syncppp.c, b) apply my patch with new PPP, c) blindly port the old drivers to generic HDLC,
d) hope for the best, with a bit of luck nobody would notice.
Alternative c) simply remove the old drivers (d) unchanged).
I don't want the breakage resulting from either action thus I think syncppp.c should stay there (basically unchanged, though we could at last remove those variables used only by the original FreeBSD code in 1994).
If the new implementation is my patch or if it uses generic PPP is debatable. I think simplicity is a good thing, the interface to generic PPP would be bigger than the whole sync-only PPP. But I'm not against using generic PPP, it's (AFAICS) clean and *working* and *maintained* (and I'm not worried about backward compatibility and certainly not about users' visions).
Signature · 1 line
Krzysztof Halasa
Krzysztof Halasa
maintainerQuoted 4 lines
But I'm not
against using generic PPP, it's (AFAICS) clean and *working* and *maintained* (and I'm not worried about backward compatibility and certainly not about users' visions).
IOW I value correctness over backward compatibility and users' visions, obviously I try to keep compatibility and meet users' needs when it actually makes sense.
Signature · 1 line
Krzysztof Halasa
Quoted 3 lines
I think it's easier to a) simply remove
syncppp.c, b) apply my patch with new PPP, c) blindly port the old drivers to generic HDLC,
d) hope for the best, with a bit of luck nobody would notice.
I would agree with this. There isn't a sane way to sort out the old kernel side syncppp (which is useless for todays networks as it doesn't do compression, IPv6 or auth protocols) except by going to user space.
Krzysztof Halasa
maintainerQuoted 3 lines · Alan Cox
I would agree with this. There isn't a sane way to sort out the old kernel side syncppp (which is useless for todays networks as it doesn't do compression, IPv6 or auth protocols) except by going to user space.
Well, I never used compression or auth on fixed line, and that would require generic PPP. Perhaps we should use it, I don't know.
Signature · 1 line
Krzysztof Halasa
David Miller
maintainerFrom: Alan Cox <[email protected]>
Date: Thu, 24 Apr 2008 21:44:57 +0100
Quoted 7 lines
Quoted 3 lines
I think it's easier to a) simply remove
syncppp.c, b) apply my patch with new PPP, c) blindly port the old drivers to generic HDLC,
d) hope for the best, with a bit of luck nobody would notice.I would agree with this. There isn't a sane way to sort out the old kernel side syncppp (which is useless for todays networks as it doesn't do compression, IPv6 or auth protocols) except by going to user space.
Ok, but what we have in the tree should at least not be a crashing mess that has to be marked BROKEN meanwhile :-)
This patch should address that issue.
Longer term I hope someone works on the infrastructure necessary that would allow us to delete this and use generic PPP kernel+userspace over these links.
Scanning over some of these older WAN drivers was truly scary. No locking at all over the HDLC protocol list, yikes!
commit 4951704b4e23d71b99ac933d8e6993bc6225ac13
Author: David S. Miller <[email protected]> Date: Mon May 12 03:29:11 2008 -0700
syncppp: Fix crashes.
The syncppp layer wants a mid-level netdev private pointer.
It was using netdev->priv but that only worked by accident, and thus this scheme was broken when the device private allocation strategy changed.
Add a proper mid-layer private pointer for uses like this, update syncppp and all users, and remove the HDLC_PPP broken tag from drivers/net/wan/Kconfig
drivers/net/wan/Kconfig +1 -3
@@ -150,11 +150,9 @@ config HDLC_FR config HDLC_PPP tristate "Synchronous Point-to-Point Protocol (PPP) support" - depends on HDLC && BROKEN + depends on HDLC help Generic HDLC driver supporting PPP over WAN connections. - This module is currently broken and will cause a kernel panic - when a device configured in PPP mode is activated. It will be replaced by new PPP implementation in Linux 2.6.26.
drivers/net/wan/cosa.c +7 -7
@@ -629,7 +629,7 @@ static void sppp_channel_init(struct channel_data *chan) d->base_addr = chan->cosa->datareg; d->irq = chan->cosa->irq; d->dma = chan->cosa->dma; - d->priv = chan; + d->ml_priv = chan;sppp_attach (&chan->pppdev);if (register_netdev (d)) {printk (KERN_WARNING "%s: register_netdev failed.\n" , d->name);
@@ -650,7 +650,7 @@ static void sppp_channel_delete(struct channel_data *chan)static int cosa_sppp_open (struct net_device *d) { -struct channel_data *chan = d->priv; +struct channel_data *chan = d->ml_priv;int err;unsigned long flags;
@@ -690,7 +690,7 @@ static int cosa_sppp_open(struct net_device *d)static int cosa_sppp_tx (struct sk_buff *skb,struct net_device *dev) { -struct channel_data *chan = dev->priv; +struct channel_data *chan = dev->ml_priv;netif_stop_queue (dev);
@@ -701,7 +701,7 @@ static int cosa_sppp_tx(struct sk_buff *skb, struct net_device *dev)static void cosa_sppp_timeout (struct net_device *dev) { -struct channel_data *chan = dev->priv; +struct channel_data *chan = dev->ml_priv;if (test_bit (RXBIT , &chan->cosa->rxtx)) { chan->stats.rx_errors++;
@@ -720,7 +720,7 @@ static void cosa_sppp_timeout(struct net_device *dev)static int cosa_sppp_close (struct net_device *d) { -struct channel_data *chan = d->priv; +struct channel_data *chan = d->ml_priv;unsigned long flags;netif_stop_queue (d);
@@ -800,7 +800,7 @@ static int sppp_tx_done(struct channel_data *chan, int size)static struct net_device_stats *cosa_net_stats (struct net_device *dev) { -struct channel_data *chan = dev->priv; +struct channel_data *chan = dev->ml_priv;return &chan->stats; }
@@ -1217,7 +1217,7 @@ static int cosa_sppp_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) {int rv; -struct channel_data *chan = dev->priv; +struct channel_data *chan = dev->ml_priv; rv =cosa_ioctl_common (chan->cosa, chan, cmd, (unsigned long )ifr->ifr_data);if (rv == -ENOIOCTLCMD ) {return sppp_do_ioctl (dev, ifr, cmd);
drivers/net/wan/hdlc_ppp.c +1 -1
@@ -45,7 +45,7 @@ static int ppp_open(struct net_device *dev)int (*old_ioctl)(struct net_device *,struct ifreq *,int );int result; - dev->priv = &state (hdlc)->syncppp_ptr; + dev->ml_priv = &state (hdlc)->syncppp_ptr;state (hdlc)->syncppp_ptr = &state (hdlc)->pppdev;state (hdlc)->pppdev.dev = dev;
drivers/net/wan/hostess_sv11.c +6 -6
@@ -75,7 +75,7 @@ static void hostess_input(struct z8530_channel *c, struct sk_buff *skb)static int hostess_open (struct net_device *d) { -struct sv11_device *sv11=d->priv; +struct sv11_device *sv11=d->ml_priv;int err =-1 ;/*
@@ -128,7 +128,7 @@ static int hostess_open(struct net_device *d)static int hostess_close (struct net_device *d) { -struct sv11_device *sv11=d->priv; +struct sv11_device *sv11=d->ml_priv;/* * Discard new frames */
@@ -159,14 +159,14 @@ static int hostess_close(struct net_device *d)static int hostess_ioctl (struct net_device *d,struct ifreq *ifr,int cmd) { -/* struct sv11_device *sv11=d->priv; +/* struct sv11_device *sv11=d->ml_priv; z8530_ioctl(d,&sv11->sync.chanA,ifr,cmd) */ return sppp_do_ioctl (d, ifr,cmd); }static struct net_device_stats *hostess_get_stats (struct net_device *d) { -struct sv11_device *sv11=d->priv; +struct sv11_device *sv11=d->ml_priv;if (sv11)return z8530_get_stats (&sv11->sync.chanA);else
@@ -179,7 +179,7 @@ static struct net_device_stats *hostess_get_stats(struct net_device *d)static int hostess_queue_xmit (struct sk_buff *skb,struct net_device *d) { -struct sv11_device *sv11=d->priv; +struct sv11_device *sv11=d->ml_priv;return z8530_queue_xmit (&sv11->sync.chanA, skb); }
@@ -325,6 +325,7 @@ static struct sv11_device *sv11_init(int iobase, int irq)/* * Initialise the PPP components */ + d->ml_priv = sv;sppp_attach (&sv->netdev);/*
@@ -333,7 +334,6 @@ static struct sv11_device *sv11_init(int iobase, int irq) d->base_addr = iobase; d->irq = irq; - d->priv = sv;if (register_netdev (d)) {
drivers/net/wan/lmc/lmc_main.c +1 -0
@@ -891,6 +891,7 @@ static int __devinit lmc_init_one(struct pci_dev *pdev,/* Initialize the sppp layer */ /* An ioctl can cause a subsequent detach for raw frame interface */ + dev->ml_priv = sc; sc->if_type =LMC_PPP ; sc->check =0xBEAFCAFE ; dev->base_addr =pci_resource_start (pdev,0 );
drivers/net/wan/sealevel.c +1 -0
@@ -241,6 +241,7 @@ static inline struct slvl_device *slvl_alloc(int iobase, int irq)return NULL ; sv = d->priv; + d->ml_priv = sv; sv->if_ptr = &sv->pppdev; sv->pppdev.dev = d; d->base_addr = iobase;
include/linux/netdevice.h +3 -0
@@ -715,6 +715,9 @@ struct net_devicestruct net *nd_net;#endif +/* mid-layer private */ +void *ml_priv; +/* bridge stuff */ struct net_bridge_port *br_port;/* macvlan */
include/net/syncppp.h +1 -1
@@ -59,7 +59,7 @@ struct ppp_devicestatic inline struct sppp *sppp_of (struct net_device *dev) { -struct ppp_device **ppp = dev->priv; +struct ppp_device **ppp = dev->ml_priv;BUG_ON ((*ppp)->dev != dev);return &(*ppp)->sppp; }
Krzysztof Halasa
maintainerQuoted 2 lines · David Miller
No
locking at all over the HDLC protocol list, yikes!
Right, I didn't think about ioctl() vs insmod/rmmod races. Will fix when I'm back home and can test it, in few days.
Signature · 1 line
Krzysztof Halasa
Krzysztof Halasa
maintainerBTW: The dev->ml_priv addition is obviously a good step but I guess you don't need the dev->priv hackery duplicated with dev->ml_priv.
Can't test it at the moment but I'd leave dev->priv alone and only get rid of the syncppp_ptr here. Then I'd simply use dev->ml_priv as syncppp_ptr and dev->priv would be a private driver pointer, as usual. Generic HDLC uses dev->priv for itself but the relevant hw drivers use hdlc->priv instead so it's not a problem.
When syncppp.c is removed we can use dev->ml_priv for HDLC layer, dev->priv for hw driver, and hdlc->priv would be no longer needed.
I mean the following:
include/net/syncppp.h struct ppp_device · line 65
Quoted 11 lines · David Miller
include/net/syncppp.h +1
-1@@ -59,7 +59,7 @@ struct ppp_devicestatic inline struct sppp *sppp_of (struct net_device *dev) { -struct ppp_device **ppp = dev->priv; +struct ppp_device **ppp = dev->ml_priv;BUG_ON ((*ppp)->dev != dev);return &(*ppp)->sppp; }
would become:
static inline struct sppp *sppp_of(struct net_device *dev)
{
return dev->ml_priv;
}The changes are not automatic, I'll look at it when able.
Signature · 1 line
Krzysztof Halasa
Krzysztof Halasa
maintainerPATCH 1/1 WAN: protect HDLC proto list while insmod/rmmod
In reply to Krzysztof HalasaWAN: protect protocol list in hdlc.c with RTNL.
drivers/net/wan/hdlc.c +11 -8
@@ -42,8 +42,7 @@ static const char* version = "HDLC support module revision 1.22";#undef DEBUG_LINK -static struct hdlc_proto *first_proto =NULL ; - +static struct hdlc_proto *first_proto;static int hdlc_change_mtu (struct net_device *dev,int new_mtu) {
@@ -313,21 +312,25 @@ void detach_hdlc_protocol(struct net_device *dev)void register_hdlc_protocol (struct hdlc_proto *proto) { +rtnl_lock (); proto->next = first_proto; first_proto = proto; +rtnl_unlock (); }void unregister_hdlc_protocol (struct hdlc_proto *proto) { -struct hdlc_proto **p = &first_proto; -while (*p) { -if (*p == proto) { - *p = proto->next; -return ; - } +struct hdlc_proto **p; + +rtnl_lock (); + p = &first_proto; +while (*p != proto) { +BUG_ON (!*p); p = &((*p)->next); } + *p = proto->next; +rtnl_unlock (); }
Re: [PATCH] WAN: protect HDLC proto list while insmod/rmmod
From: Krzysztof Halasa <[email protected]>
Date: Mon, 19 May 2008 19:00:51 +0200
Quoted 3 lines
WAN: protect protocol list in
hdlc.cwith RTNL.Signed-off-by Krzysztof Hałasa <[email protected]>
Jeff Garzik
AppliedRe: [PATCH] WAN: protect HDLC proto list while insmod/rmmod
In reply to Krzysztof HalasaQuoted 3 lines · Krzysztof Halasa
WAN: protect protocol list in
hdlc.cwith RTNL.Signed-off-by Krzysztof Hałasa <[email protected]>
applied