net/x25: netdev event handling
Subsystems (3)
Martin Schiller
maintainerv3 cover net/x25: netdev event handling
---
Changes to v2:
o restructure complete patch-set
o keep netdev event handling in layer3 (X.25)
o add patch to fix lapb_connect_request() for DCE
o add patch to handle carrier loss correctly in lapb
o drop patch for x25_neighbour param handling
this may need fixes/cleanup and will be resubmitted later.
Changes to v1:
o fix 'subject_prefix' and 'checkpatch' warnings
---
Martin Schiller (6):
net/x25: handle additional netdev events net/lapb: fix lapb_connect_request() for DCE net/lapb: handle carrier loss correctly net/lapb: fix t1 timer handling for DCE net/x25: fix restart request/confirm handling net/x25: remove x25_kill_by_device()
include/net/x25.h | 2 + net/lapb/lapb_iface.c | 22 +++++++++-- net/lapb/lapb_timer.c | 11 +++++- net/x25/af_x25.c | 66 +++++++++++++++++++++++-------- net/x25/x25_link.c | 90 ++++++++++++++++++++++++++++++++++++------- net/x25/x25_route.c | 3 -- 6 files changed, 155 insertions(+), 39 deletions(-)
Signature · 1 line
2.20.1
Martin Schiller
maintainerPATCH v3 1/6 net/x25: handle additional netdev events
Add / remove x25_link_device by NETDEV_REGISTER/UNREGISTER and also by NETDEV_POST_TYPE_CHANGE/NETDEV_PRE_TYPE_CHANGE.
This change is needed so that the x25_neigh struct for an interface is already created when it shows up and is kept independently if the interface goes UP or DOWN.
This is used in an upcomming commit, where x25 params of an neighbour will get configurable through ioctls.
Additionally the NETDEV_CHANGE event makes it possible to handle carrier loss and detection.
--- include/net/x25.h | 2 ++ net/x25/af_x25.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ net/x25/x25_link.c | 45 +++++++++++++++++++++++++++++++++++++++------ 3 files changed, 85 insertions(+), 6 deletions(-)
include/net/x25.h +2 -0
@@ -231,6 +231,8 @@ int x25_backlog_rcv(struct sock *, struct sk_buff *);/* x25_link.c */ void x25_link_control (struct sk_buff *,struct x25_neigh *,unsigned short ); +void x25_link_device_add (struct net_device *dev); +void x25_link_device_remove (struct net_device *dev);void x25_link_device_up (struct net_device *);void x25_link_device_down (struct net_device *);void x25_link_established (struct x25_neigh *);
net/x25/af_x25.c +44 -0
64 lines not on this page · raw message
net/x25/x25_link.c +39 -6
76 lines not on this page · raw message
Signature · 1 line
2.20.1
Martin Schiller
maintainerPATCH v3 2/6 net/lapb: fix lapb_connect_request() for DCE
In reply to Martin SchillerFor a DTE interface we should change to state LAPB_STATE_1 and start sending SABM(E). But for DCE interfaces, we simply should start the timer t1.
--- net/lapb/lapb_iface.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
net/lapb/lapb_iface.c +7 -3
@@ -278,10 +278,14 @@ int lapb_connect_request(struct net_device *dev)if (lapb->state ==LAPB_STATE_3 || lapb->state ==LAPB_STATE_4 ) goto out_put; -lapb_establish_data_link (lapb); +if (lapb->mode &LAPB_DCE ) { +lapb_start_t1timer (lapb); + }else { +lapb_establish_data_link (lapb); -lapb_dbg (0 ,"(%p) S0 -> S1\n" , lapb->dev); - lapb->state =LAPB_STATE_1 ; +lapb_dbg (0 ,"(%p) S0 -> S1\n" , lapb->dev); + lapb->state =LAPB_STATE_1 ; + } rc =LAPB_OK ; out_put:
Signature · 1 line
2.20.1
Martin Schiller
maintainerPATCH v3 3/6 net/lapb: handle carrier loss correctly
In reply to Martin SchillerIn case of carrier loss, clear all queues, enter state LABB_STATE_0 and stop all timers.
By setting rc = LAPB_NOTCONNECTED, the upper layer is informed about the disconnect.
--- net/lapb/lapb_iface.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
net/lapb/lapb_iface.c +12 -0
@@ -303,6 +303,18 @@ int lapb_disconnect_request(struct net_device *dev)if (!lapb) goto out; +if (!netif_carrier_ok (dev)) { +lapb_dbg (0 ,"(%p) Carrier lost!\n" , lapb->dev); +lapb_dbg (0 ,"(%p) S%d -> S0\n" , lapb->dev, lapb->state); +lapb_clear_queues (lapb); + lapb->state =LAPB_STATE_0 ; + lapb->n2count =0 ; +lapb_stop_t1timer (lapb); +lapb_stop_t2timer (lapb); + rc =LAPB_NOTCONNECTED ; + goto out_put; + } +switch (lapb->state) {case LAPB_STATE_0 : rc =LAPB_NOTCONNECTED ;
Signature · 1 line
2.20.1
Martin Schiller
maintainerPATCH v3 4/6 net/lapb: fix t1 timer handling for DCE
In reply to Martin Schillerfix t1 timer handling for DCE in LAPB_STATE_0:
o DTE interface changes immediately to LAPB_STATE_1 and start sending SABM(E).
o DCE interface sends N2-times DM and changes to LAPB_STATE_1 afterwards if there is no response in the meantime.
--- net/lapb/lapb_timer.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
net/lapb/lapb_timer.c +9 -2
@@ -85,11 +85,18 @@ static void lapb_t1timer_expiry(struct timer_list *t)switch (lapb->state) {/* -* If we are a DCE, keep going DM .. DM .. DM +* If we are a DCE, send DM up to N2 times, then switch to +* STATE_1 and send SABM(E). */ case LAPB_STATE_0 : -if (lapb->mode &LAPB_DCE ) +if (lapb->mode &LAPB_DCE && + lapb->n2count != lapb->n2) { + lapb->n2count++;lapb_send_control (lapb,LAPB_DM ,LAPB_POLLOFF ,LAPB_RESPONSE ); + }else { + lapb->state =LAPB_STATE_1 ; +lapb_establish_data_link (lapb); + }break ;/*
Signature · 1 line
2.20.1
Martin Schiller
maintainerPATCH v3 5/6 net/x25: fix restart request/confirm handling
In reply to Martin SchillerWe have to take the actual link state into account to handle restart requests/confirms well.
Also, the T20 timer needs to be stopped, if the link is terminated.
--- net/x25/x25_link.c | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-)
net/x25/x25_link.c +37 -8
@@ -74,16 +74,43 @@ void x25_link_control(struct sk_buff *skb, struct x25_neigh *nb,switch (frametype) {case X25_RESTART_REQUEST : - confirm = !x25_t20timer_pending (nb); -x25_stop_t20timer (nb); - nb->state =X25_LINK_STATE_3 ; -if (confirm) +switch (nb->state) { +case X25_LINK_STATE_2 : + confirm = !x25_t20timer_pending (nb); +x25_stop_t20timer (nb); + nb->state =X25_LINK_STATE_3 ; +if (confirm) +x25_transmit_restart_confirmation (nb); +break ; +case X25_LINK_STATE_3 : +/* clear existing virtual calls */ +x25_kill_by_neigh (nb); +x25_transmit_restart_confirmation (nb); +break ; + }break ;case X25_RESTART_CONFIRMATION : -x25_stop_t20timer (nb); - nb->state =X25_LINK_STATE_3 ; +switch (nb->state) { +case X25_LINK_STATE_2 : +if (x25_t20timer_pending (nb)) { +x25_stop_t20timer (nb); + nb->state =X25_LINK_STATE_3 ; + }else { +x25_transmit_restart_request (nb); +x25_start_t20timer (nb); + } +break ; +case X25_LINK_STATE_3 : +/* clear existing virtual calls */ +x25_kill_by_neigh (nb); + +x25_transmit_restart_request (nb); + nb->state =X25_LINK_STATE_2 ; +x25_start_t20timer (nb); +break ; + }break ;case X25_DIAGNOSTIC :
@@ -214,8 +241,6 @@ void x25_link_established(struct x25_neigh *nb) {switch (nb->state) {case X25_LINK_STATE_0 : - nb->state =X25_LINK_STATE_2 ; -break ;case X25_LINK_STATE_1 :x25_transmit_restart_request (nb); nb->state =X25_LINK_STATE_2 ;
@@ -232,6 +257,10 @@ void x25_link_established(struct x25_neigh *nb)void x25_link_terminated (struct x25_neigh *nb) { nb->state =X25_LINK_STATE_0 ; + +if (x25_t20timer_pending (nb)) +x25_stop_t20timer (nb); +/* Out of order: clear existing virtual calls (X.25 03/93 4.6.3) */ x25_kill_by_neigh (nb); }
Signature · 1 line
2.20.1
Martin Schiller
maintainerPATCH v3 6/6 net/x25: remove x25_kill_by_device()
In reply to Martin SchillerRemove unnecessary function x25_kill_by_device().
Replace the call to x25_kill_by_device() by x25_kill_by_neigh().
Therefore, also remove the call to x25_clear_forward_by_dev() in x25_route_device_down(), as this is already called by x25_kill_by_neigh().
--- net/x25/af_x25.c | 22 +++++----------------- net/x25/x25_route.c | 3 --- 2 files changed, 5 insertions(+), 20 deletions(-)
net/x25/af_x25.c +5 -17
@@ -199,22 +199,6 @@ static void x25_remove_socket(struct sock *sk)write_unlock_bh (&x25_list_lock); } -/* -* Kill all bound sockets on a dropped device. -*/ -static void x25_kill_by_device (struct net_device *dev) -{ -struct sock *s; - -write_lock_bh (&x25_list_lock); - -sk_for_each (s, &x25_list) -if (x25_sk (s)->neighbour &&x25_sk (s)->neighbour->dev == dev) -x25_disconnect (s,ENETUNREACH ,0 ,0 ); - -write_unlock_bh (&x25_list_lock); -} -/* * Handle device status changes. */
@@ -260,7 +244,11 @@ static int x25_device_event(struct notifier_block *this, unsigned long event,case NETDEV_DOWN :pr_debug ("X.25: got event NETDEV_DOWN for device: %s\n" , dev->name); -x25_kill_by_device (dev); + nb =x25_get_neigh (dev); +if (nb) { +x25_kill_by_neigh (nb); +x25_neigh_put (nb); + }x25_route_device_down (dev);x25_link_device_down (dev);break ;
net/x25/x25_route.c +0 -3
@@ -115,9 +115,6 @@ void x25_route_device_down(struct net_device *dev)__x25_remove_route (rt); }write_unlock_bh (&x25_route_list_lock); - -/* Remove any related forwarding */ -x25_clear_forward_by_dev (dev); }/*
Signature · 1 line
2.20.1
Quoted 5 lines · Martin Schiller
---
Changes to v2:
o restructure complete patch-set
o keep netdev event handling in layer3 (X.25)
But... Won't it be better to handle L2 connections in L2 code?
For example, if we are running X.25 over XOT, we can decide in the XOT layer whether and when we reconnect in case the TCP connection is dropped. We can decide how long we wait for responses before we consider the TCP connection to be dropped.
If we still want "on-demand" connections in certain L2's, we can also implement it in that L2 without the need to change L3.
Every L2 has its own characteristics. It might be better to let different L2's handle their connections in their own way. This gives L2 the flexibility to handle their connections according to their actual link characteristics.
Letting L3 handle L2 connections also makes L2 code too related to / coupled with L3 code, which makes the logic complex.
Quoted 17 lines
o add patch to fix
lapb_connect_request()for DCE
o add patch to handle carrier loss correctly in lapb
o drop patch forx25_neighbourparam handling
this may need fixes/cleanup and will be resubmitted later.Changes to v1:
o fix 'subject_prefix' and 'checkpatch' warnings---
Martin Schiller (6):
net/x25: handle additional netdev events net/lapb: fixlapb_connect_request()for DCE net/lapb: handle carrier loss correctly net/lapb: fix t1 timer handling for DCE net/x25: fix restart request/confirm handling net/x25: removex25_kill_by_device()
Martin Schiller
maintainerQuoted 17 lines · Xie He
Quoted 5 lines · Martin Schiller
---
Changes to v2:
o restructure complete patch-set
o keep netdev event handling in layer3 (X.25)But... Won't it be better to handle L2 connections in L2 code?
For example, if we are running X.25 over XOT, we can decide in the XOT layer whether and when we reconnect in case the TCP connection is dropped. We can decide how long we wait for responses before we consider the TCP connection to be dropped.
If we still want "on-demand" connections in certain L2's, we can also implement it in that L2 without the need to change L3.
Quoted 7 lines
Every L2 has its own characteristics. It might be better to let different L2's handle their connections in their own way. This gives L2 the flexibility to handle their connections according to their actual link characteristics.
Letting L3 handle L2 connections also makes L2 code too related to / coupled with L3 code, which makes the logic complex.
OK, I will give it a try. But we need to keep the possibility to initiate and terminate the L2 connection from L3.
In the on demand scenario i mentioned, the L2 should be connected when the first L3 logical channel goes up and needs to be disconnected, when the last L3 logical channel on an interface is cleared.
Quoted 18 lines
Quoted 18 lines
o add patch to fix
lapb_connect_request()for DCE
o add patch to handle carrier loss correctly in lapb
o drop patch forx25_neighbourparam handling
this may need fixes/cleanup and will be resubmitted later.Changes to v1:
o fix 'subject_prefix' and 'checkpatch' warnings---
Martin Schiller (6):
net/x25: handle additional netdev events net/lapb: fixlapb_connect_request()for DCE net/lapb: handle carrier loss correctly net/lapb: fix t1 timer handling for DCE net/x25: fix restart request/confirm handling net/x25: removex25_kill_by_device()
Quoted 18 lines · Martin Schiller
Quoted 16 lines · Xie He
But... Won't it be better to handle L2 connections in L2 code?
For example, if we are running X.25 over XOT, we can decide in the XOT layer whether and when we reconnect in case the TCP connection is dropped. We can decide how long we wait for responses before we consider the TCP connection to be dropped.
If we still want "on-demand" connections in certain L2's, we can also implement it in that L2 without the need to change L3.
Every L2 has its own characteristics. It might be better to let different L2's handle their connections in their own way. This gives L2 the flexibility to handle their connections according to their actual link characteristics.
Quoted 5 lines
Quoted 2 lines
Letting L3 handle L2 connections also makes L2 code too related to / coupled with L3 code, which makes the logic complex.
OK, I will give it a try. But we need to keep the possibility to initiate and terminate the L2 connection from L3.
OK. Thanks so much!
Quoted 3 lines
In the on demand scenario i mentioned, the L2 should be connected when the first L3 logical channel goes up and needs to be disconnected, when the last L3 logical channel on an interface is cleared.
I see. Maybe we can do it this way:
When L3 wants to initiate the first L3 connection, it can check whether the L2 connection is established, and if it is not, it can instruct L2 to connect. This is the same as what the current code (before this series) does.
When the last L3 connection is terminated, we can let L3 use the one-byte header to "suggest" (rather than "instruct") L2 to terminate the L2 connection. L2 can choose to either terminate the connection or continue to keep it, based on whether it is in on-demand mode.