Introduce new configuration flag CGW_FLAGS_CAN_IIF_TX_OK to configure if a CAN sk_buff that has been routed with can-gw is allowed to be send back to the originating CAN interface.
Unified · Split
| @@ -51,6 +51,7 @@ enum { · 50 unmodified lines | ||
| 51 | 51 | |
| 52 | 52 | #define CGW_FLAGS_CAN_ECHO 0x01 |
| 53 | 53 | #define CGW_FLAGS_CAN_SRC_TSTAMP 0x02 |
| 54 | +#define CGW_FLAGS_CAN_IIF_TX_OK 0x04 | |
| 54 | 55 | |
| 55 | 56 | #define CGW_MOD_FUNCS 4 /* AND OR XOR SET */ |
| 56 | 57 | |
| @@ -52,6 +52,7 @@ · 51 unmodified lines | ||
| 52 | 52 | #include <linux/skbuff.h> |
| 53 | 53 | #include <linux/can.h> |
| 54 | 54 | #include <linux/can/core.h> |
| 55 | +#include <linux/can/skb.h> | |
| 55 | 56 | #include <linux/can/gw.h> |
| 56 | 57 | #include <net/rtnetlink.h> |
| 57 | 58 | #include <net/net_namespace.h> |
| @@ -347,6 +348,13 @@ static void can_can_gw_rcv(struct sk_buff *skb, void *data) · 289 unmodified lines | ||
| 347 | 348 | return; |
| 348 | 349 | } |
| 349 | 350 | |
| 351 | + /* is sending the skb back to the incoming interface not allowed? */ | |
| 352 | + if (!(gwj->flags & CGW_FLAGS_CAN_IIF_TX_OK) && | |
| 353 | + skb_headroom(skb) == sizeof(struct can_skb_priv) && | |
| 354 | + (((struct can_skb_priv *)(skb->head))->ifindex == | |
| 355 | + gwj->dst.dev->ifindex)) | |
| 356 | + return; | |
| 357 | + | |
| 350 | 358 | /* |
| 351 | 359 | * clone the given skb, which has not been done in can_rcv() |
| 352 | 360 | * |