can-gw: add a variable limit for CAN frame routings
Subsystems (2)
Oliver Hartkopp
maintainerPATCH v3 1/1 can-gw: add a variable limit for CAN frame routings
To prevent a possible misconfiguration (e.g. circular CAN frame routings) limit the number of routings of a single CAN frame to a small variable value.
The limit can be specified by the module parameter 'max_hops' (1..6). The default value is 1 (one hop), according to the original can-gw behaviour.
---
Having the possibility of only a single CAN frame routing (one hop) hinders use-cases for some complex application setups. To enable more than one CAN frame routing process with a single CAN frame (skb) a counter needed to be implemented to prevent an endless frame processing (e.g. due to some kind of misconfiguration).
As the skb control buffer (cb) potentially gets modified by net/sched in the tx path the csum element for IP checksums is re-used for the counter, as CAN frame skbs (ARPHRD_CAN) never contain any kind of checksums (see src comment).
v2: use clamp_t() function from kernel.h to sanitize the new module parameter
v3: use __stringify() to code value definitions only once and use pr_info()
include/uapi/linux/can/gw.h +1 -0
@@ -44,6 +44,7 @@ enum {CGW_SRC_IF ,/* ifindex of source network interface */ CGW_DST_IF ,/* ifindex of destination network interface */ CGW_FILTER ,/* specify struct can_filter on source CAN device */ +CGW_DELETED ,/* number of deleted CAN frames (see max_hops param) */ __CGW_MAX };
net/can/gw.c +50 -16
119 lines not on this page · raw message
Oliver Hartkopp
maintainerHello Marc,
once you applied this patch to your can-next tree, please tell me the git URL before asking Dave to pull it.
I turned out that this extension for can-gw hops enables an additional configuration possibility, i would like to add for the pull request too.
Tnx,
Oliver
Quoted 10 lines · Oliver Hartkopp
To prevent a possible misconfiguration (e.g. circular CAN frame routings) limit the number of routings of a single CAN frame to a small variable value.
The limit can be specified by the module parameter '
max_hops' (1..6). The default value is 1 (one hop), according to the original can-gw behaviour.Signed-off-by Oliver Hartkopp <[email protected]>---
(..)
Oliver Hartkopp
maintainerIt fits in the original patch and context very well (only 4 lines more).
I'll send a v4 instead after testing.
Sorry for the noise.
Oliver
Quoted 31 lines · Oliver Hartkopp
Hello Marc,
once you applied this patch to your can-next tree, please tell me the git URL before asking Dave to pull it.
I turned out that this extension for can-gw hops enables an additional configuration possibility, i would like to add for the pull request too.
Tnx,
OliverQuoted 10 lines · Oliver Hartkopp
To prevent a possible misconfiguration (e.g. circular CAN frame routings) limit the number of routings of a single CAN frame to a small variable value.
The limit can be specified by the module parameter '
max_hops' (1..6). The default value is 1 (one hop), according to the original can-gw behaviour.Signed-off-by Oliver Hartkopp <[email protected]>---
(..)
--
To unsubscribe from this list: send the line "unsubscribe linux-can" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html