Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 857e8a67 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'batman-hdlc'



Andrew Lunn says:

====================
Allow BATMAN to use hdlc-eth interfaces

BATMAN works over Ethernet like interfaces. hdlc-eth provides the need
requirements. However, hdlc devices are often created as raw hdlc
devices, which batman cannot use, and are then be transmuted into
other types using sethdlc(1). Have the HDLC code emit
NETDEV_*_TYPE_CHANGE events when the type changes, and have BATMAN
react on these events.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 2141eaf0 a1a66b11
Loading
Loading
Loading
Loading
+18 −3
Original line number Diff line number Diff line
@@ -266,8 +266,8 @@ struct net_device *alloc_hdlcdev(void *priv)
void unregister_hdlc_device(struct net_device *dev)
{
	rtnl_lock();
	unregister_netdevice(dev);
	detach_hdlc_protocol(dev);
	unregister_netdevice(dev);
	rtnl_unlock();
}

@@ -276,7 +276,11 @@ void unregister_hdlc_device(struct net_device *dev)
int attach_hdlc_protocol(struct net_device *dev, struct hdlc_proto *proto,
			 size_t size)
{
	detach_hdlc_protocol(dev);
	int err;

	err = detach_hdlc_protocol(dev);
	if (err)
		return err;

	if (!try_module_get(proto->module))
		return -ENOSYS;
@@ -289,15 +293,24 @@ int attach_hdlc_protocol(struct net_device *dev, struct hdlc_proto *proto,
		}
	}
	dev_to_hdlc(dev)->proto = proto;

	return 0;
}


void detach_hdlc_protocol(struct net_device *dev)
int detach_hdlc_protocol(struct net_device *dev)
{
	hdlc_device *hdlc = dev_to_hdlc(dev);
	int err;

	if (hdlc->proto) {
		err = call_netdevice_notifiers(NETDEV_PRE_TYPE_CHANGE, dev);
		err = notifier_to_errno(err);
		if (err) {
			netdev_err(dev, "Refused to change device type\n");
			return err;
		}

		if (hdlc->proto->detach)
			hdlc->proto->detach(dev);
		module_put(hdlc->proto->module);
@@ -306,6 +319,8 @@ void detach_hdlc_protocol(struct net_device *dev)
	kfree(hdlc->state);
	hdlc->state = NULL;
	hdlc_setup_dev(dev);

	return 0;
}


+1 −0
Original line number Diff line number Diff line
@@ -378,6 +378,7 @@ static int cisco_ioctl(struct net_device *dev, struct ifreq *ifr)
		spin_lock_init(&state(hdlc)->lock);
		dev->header_ops = &cisco_header_ops;
		dev->type = ARPHRD_CISCO;
		call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE, dev);
		netif_dormant_on(dev);
		return 0;
	}
+1 −0
Original line number Diff line number Diff line
@@ -1240,6 +1240,7 @@ static int fr_ioctl(struct net_device *dev, struct ifreq *ifr)
		}
		memcpy(&state(hdlc)->settings, &new_settings, size);
		dev->type = ARPHRD_FRAD;
		call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE, dev);
		return 0;

	case IF_PROTO_FR_ADD_PVC:
+1 −0
Original line number Diff line number Diff line
@@ -687,6 +687,7 @@ static int ppp_ioctl(struct net_device *dev, struct ifreq *ifr)
		dev->hard_header_len = sizeof(struct hdlc_header);
		dev->header_ops = &ppp_header_ops;
		dev->type = ARPHRD_PPP;
		call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE, dev);
		netif_dormant_on(dev);
		return 0;
	}
+1 −0
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ static int raw_ioctl(struct net_device *dev, struct ifreq *ifr)
			return result;
		memcpy(hdlc->state, &new_settings, size);
		dev->type = ARPHRD_RAWHDLC;
		call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE, dev);
		netif_dormant_off(dev);
		return 0;
	}
Loading