netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin Schiller <ms@dev.tdt.de>
To: andrew.hendry@gmail.com, davem@davemloft.net, khc@pm.waw.pl,
	isdn@linux-pingi.de
Cc: edumazet@google.com, linux-x25@vger.kernel.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Martin Schiller <ms@dev.tdt.de>
Subject: [PATCH 4/4] isdn/i4l: Call notifiers before and after changing device type
Date: Wed,  3 Apr 2019 07:01:18 +0200	[thread overview]
Message-ID: <20190403050118.12785-4-ms@dev.tdt.de> (raw)
In-Reply-To: <20190403050118.12785-1-ms@dev.tdt.de>

Signed-off-by: Martin Schiller <ms@dev.tdt.de>
---
 drivers/isdn/i4l/isdn_net.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c
index c138f66f2659..3016cbcc719a 100644
--- a/drivers/isdn/i4l/isdn_net.c
+++ b/drivers/isdn/i4l/isdn_net.c
@@ -2692,8 +2692,12 @@ isdn_net_setcfg(isdn_net_ioctl_cfg *cfg)
 			       p->dev->name);
 			return -EINVAL;
 #else
+			rtnl_lock();
+			call_netdevice_notifiers(NETDEV_PRE_TYPE_CHANGE, p->dev);
 			p->dev->type = ARPHRD_PPP;	/* change ARP type */
+			call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE, p->dev);
 			p->dev->addr_len = 0;
+			rtnl_unlock();
 #endif
 			break;
 		case ISDN_NET_ENCAP_X25IFACE:
@@ -2702,16 +2706,27 @@ isdn_net_setcfg(isdn_net_ioctl_cfg *cfg)
 			       p->dev->name);
 			return -EINVAL;
 #else
+			rtnl_lock();
+			call_netdevice_notifiers(NETDEV_PRE_TYPE_CHANGE, p->dev);
 			p->dev->type = ARPHRD_X25;	/* change ARP type */
+			call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE, p->dev);
 			p->dev->addr_len = 0;
+			rtnl_unlock();
 #endif
 			break;
 		case ISDN_NET_ENCAP_CISCOHDLCK:
 			break;
 		default:
 			if (cfg->p_encap >= 0 &&
-			    cfg->p_encap <= ISDN_NET_ENCAP_MAX_ENCAP)
+			    cfg->p_encap <= ISDN_NET_ENCAP_MAX_ENCAP) {
+				rtnl_lock();
+				call_netdevice_notifiers(NETDEV_PRE_TYPE_CHANGE, p->dev);
+				p->dev->type = ARPHRD_ETHER;	/* change ARP type */
+				call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE, p->dev);
+				p->dev->addr_len = ETH_ALEN;
+				rtnl_unlock();
 				break;
+			}
 			printk(KERN_WARNING
 			       "%s: encapsulation protocol %d not supported\n",
 			       p->dev->name, cfg->p_encap);
-- 
2.11.0


      parent reply	other threads:[~2019-04-03  5:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-03  5:01 [PATCH 1/4] net/x25: call skb_reset_network_header where needed Martin Schiller
2019-04-03  5:01 ` [PATCH 2/4] wan/hdlc_x25: fix skb handling Martin Schiller
2019-04-05  0:32   ` David Miller
2019-04-05  6:56     ` Martin Schiller
2019-04-05 19:15       ` David Miller
2019-04-08  6:07         ` Martin Schiller
2019-04-03  5:01 ` [PATCH 3/4] isdn/i4l/isdn_x25iface: call skb_reset_network_header Martin Schiller
2019-04-03  5:01 ` Martin Schiller [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190403050118.12785-4-ms@dev.tdt.de \
    --to=ms@dev.tdt.de \
    --cc=andrew.hendry@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=isdn@linux-pingi.de \
    --cc=khc@pm.waw.pl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-x25@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).