Fwd: Re: min/max mtu field in struct net_device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Julia,

Would you have any ideas on how to solve the problem below. The problem
occurs with source files that have more than one struct net_device_ops
defined, which is the case for net/mac80211/iface.c for one. Obviously I
want the callback definition to be added only once.

Regards,
Arend

-------- Forwarded Message --------
Subject: Re: min/max mtu field in struct net_device
Date: Mon, 14 Nov 2016 11:46:01 +0100
From: Arend Van Spriel <arend.vanspriel@xxxxxxxxxxxx>
To: Johannes Berg <johannes@xxxxxxxxxxxxxxxx>, backports@xxxxxxxxxxxxxxx
<backports@xxxxxxxxxxxxxxx>

On 14-11-2016 10:30, Johannes Berg wrote:
> On Mon, 2016-11-14 at 09:49 +0100, Arend Van Spriel wrote:
>> Just wondering. Does anyone have any ideas on how to backport the two
>> patches below. The struct net_device now holds mtu range which
>> network subsystem checks. For a number of drivers and mac80211 it
>> means they no longer have .ndo_change_mtu callback. My guess is that
>> we need patches in backport of some sort to tackle this.
> 
> Yeah, I kinda saw this coming. Since in almost all cases using the new
> min/max the ndo_change_mtu was actually removed, perhaps we can come up
> with a way to spatch it back in?

Me too. This is what I got so far, but the callback is generated twice
for net/mac80211/iface.c for obvious reasons (data and monitor ops).
These are my first baby steps with spatch so not sure how to solve it.

Gr. AvS

@r1@
expression ndev, e1, e2;
identifier func;
@@
func(...) {
	<...
- 	ndev->min_mtu = e1;
- 	ndev->max_mtu = e2;
	...>
}
@@
expression r1.e1, r1.e2;
identifier OPS;
@@
+ static int __change_mtu(struct net_device *ndev, int new_mtu)
+ {
+	if (new_mtu < e1 || new_mtu > e2)
+ 		return -EINVAL;
+	ndev->mtu = new_mtu;
+ }
+
struct net_device_ops OPS = {
+ 	.ndo_change_mtu = __change_mtu,
	...
};

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux