diff mbox series

[net-next,v2,4/6] net/x25: support NETDEV_CHANGE notifier

Message ID 20201116135522.21791-5-ms@dev.tdt.de (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series netdev event handling + neighbour config | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 19 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Martin Schiller Nov. 16, 2020, 1:55 p.m. UTC
This makes it possible to handle carrier lost and detection.
In case of carrier lost, we shutdown layer 3 and flush all sessions.

Signed-off-by: Martin Schiller <ms@dev.tdt.de>
---

Change from v1:
fix 'subject_prefix' and 'checkpatch' warnings

---
 net/x25/af_x25.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Xie He Nov. 17, 2020, 11:41 a.m. UTC | #1
On Mon, Nov 16, 2020 at 6:00 AM Martin Schiller <ms@dev.tdt.de> wrote:
>
> This makes it possible to handle carrier lost and detection.
> In case of carrier lost, we shutdown layer 3 and flush all sessions.
>
> @@ -275,6 +275,19 @@ static int x25_device_event(struct notifier_block *this, unsigned long event,
>                                  dev->name);
>                         x25_link_device_remove(dev);
>                         break;
> +               case NETDEV_CHANGE:
> +                       pr_debug("X.25: got event NETDEV_CHANGE for device: %s\n",
> +                                dev->name);
> +                       if (!netif_carrier_ok(dev)) {
> +                               pr_debug("X.25: Carrier lost -> set link state down: %s\n",
> +                                        dev->name);
> +                               nb = x25_get_neigh(dev);
> +                               if (nb) {
> +                                       x25_link_terminated(nb);
> +                                       x25_neigh_put(nb);
> +                               }
> +                       }
> +                       break;
>                 }
>         }

I think L2 will notify L3 if the L2 connection is terminated. Is this
patch necessary?
Martin Schiller Nov. 17, 2020, 12:30 p.m. UTC | #2
On 2020-11-17 12:41, Xie He wrote:
> On Mon, Nov 16, 2020 at 6:00 AM Martin Schiller <ms@dev.tdt.de> wrote:
>> 
>> This makes it possible to handle carrier lost and detection.
>> In case of carrier lost, we shutdown layer 3 and flush all sessions.
>> 
>> @@ -275,6 +275,19 @@ static int x25_device_event(struct notifier_block 
>> *this, unsigned long event,
>>                                  dev->name);
>>                         x25_link_device_remove(dev);
>>                         break;
>> +               case NETDEV_CHANGE:
>> +                       pr_debug("X.25: got event NETDEV_CHANGE for 
>> device: %s\n",
>> +                                dev->name);
>> +                       if (!netif_carrier_ok(dev)) {
>> +                               pr_debug("X.25: Carrier lost -> set 
>> link state down: %s\n",
>> +                                        dev->name);
>> +                               nb = x25_get_neigh(dev);
>> +                               if (nb) {
>> +                                       x25_link_terminated(nb);
>> +                                       x25_neigh_put(nb);
>> +                               }
>> +                       }
>> +                       break;
>>                 }
>>         }
> 
> I think L2 will notify L3 if the L2 connection is terminated. Is this
> patch necessary?

Hmm... well I guess you're right. Admittedly, these patches were made
about 7 - 8 years ago and I have to keep thinking about them.
But I can't think of any situation where this patch should be necessary
at the moment.

I will drop this patch from the patch-set.
diff mbox series

Patch

diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index 25726120fcc7..6a95ca11694e 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -275,6 +275,19 @@  static int x25_device_event(struct notifier_block *this, unsigned long event,
 				 dev->name);
 			x25_link_device_remove(dev);
 			break;
+		case NETDEV_CHANGE:
+			pr_debug("X.25: got event NETDEV_CHANGE for device: %s\n",
+				 dev->name);
+			if (!netif_carrier_ok(dev)) {
+				pr_debug("X.25: Carrier lost -> set link state down: %s\n",
+					 dev->name);
+				nb = x25_get_neigh(dev);
+				if (nb) {
+					x25_link_terminated(nb);
+					x25_neigh_put(nb);
+				}
+			}
+			break;
 		}
 	}