Skip to content

Commit fe80536

Browse files
Martindavem330
authored andcommitted
bareudp: Added attribute to enable & disable rx metadata collection
Metadata need not be collected in receive if the packet from bareudp device is not targeted to openvswitch. Signed-off-by: Martin <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8930449 commit fe80536

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

Documentation/networking/bareudp.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,7 @@ enabled.
4848
The bareudp device could be used along with OVS or flower filter in TC.
4949
The OVS or TC flower layer must set the tunnel information in SKB dst field before
5050
sending packet buffer to the bareudp device for transmission. On reception the
51-
bareudp device extracts and stores the tunnel information in SKB dst field before
52-
passing the packet buffer to the network stack.
51+
bareudp device decapsulates the udp header and passes the inner packet to the
52+
network stack. If RX_COLLECT_METADATA flag is enabled in the device the tunnel
53+
information will be stored in the SKB dst field before the packet buffer is
54+
passed to the network stack.

drivers/net/bareudp.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ struct bareudp_dev {
4646
__be16 port;
4747
u16 sport_min;
4848
bool multi_proto_mode;
49+
bool rx_collect_metadata;
4950
struct socket __rcu *sock;
5051
struct list_head next; /* bareudp node on namespace list */
5152
struct gro_cells gro_cells;
@@ -125,13 +126,14 @@ static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
125126
bareudp->dev->stats.rx_dropped++;
126127
goto drop;
127128
}
128-
129-
tun_dst = udp_tun_rx_dst(skb, family, TUNNEL_KEY, 0, 0);
130-
if (!tun_dst) {
131-
bareudp->dev->stats.rx_dropped++;
132-
goto drop;
129+
if (bareudp->rx_collect_metadata) {
130+
tun_dst = udp_tun_rx_dst(skb, family, TUNNEL_KEY, 0, 0);
131+
if (!tun_dst) {
132+
bareudp->dev->stats.rx_dropped++;
133+
goto drop;
134+
}
135+
skb_dst_set(skb, &tun_dst->dst);
133136
}
134-
skb_dst_set(skb, &tun_dst->dst);
135137
skb->dev = bareudp->dev;
136138
oiph = skb_network_header(skb);
137139
skb_reset_network_header(skb);
@@ -575,6 +577,9 @@ static int bareudp2info(struct nlattr *data[], struct bareudp_conf *conf,
575577
if (data[IFLA_BAREUDP_MULTIPROTO_MODE])
576578
conf->multi_proto_mode = true;
577579

580+
if (data[IFLA_BAREUDP_RX_COLLECT_METADATA])
581+
conf->rx_collect_metadata = true;
582+
578583
return 0;
579584
}
580585

@@ -612,6 +617,8 @@ static int bareudp_configure(struct net *net, struct net_device *dev,
612617
bareudp->ethertype = conf->ethertype;
613618
bareudp->sport_min = conf->sport_min;
614619
bareudp->multi_proto_mode = conf->multi_proto_mode;
620+
bareudp->rx_collect_metadata = conf->rx_collect_metadata;
621+
615622
err = register_netdevice(dev);
616623
if (err)
617624
return err;
@@ -669,6 +676,7 @@ static size_t bareudp_get_size(const struct net_device *dev)
669676
nla_total_size(sizeof(__be16)) + /* IFLA_BAREUDP_ETHERTYPE */
670677
nla_total_size(sizeof(__u16)) + /* IFLA_BAREUDP_SRCPORT_MIN */
671678
nla_total_size(0) + /* IFLA_BAREUDP_MULTIPROTO_MODE */
679+
nla_total_size(0) + /* IFLA_BAREUDP_RX_COLLECT_METADATA */
672680
0;
673681
}
674682

@@ -685,6 +693,9 @@ static int bareudp_fill_info(struct sk_buff *skb, const struct net_device *dev)
685693
if (bareudp->multi_proto_mode &&
686694
nla_put_flag(skb, IFLA_BAREUDP_MULTIPROTO_MODE))
687695
goto nla_put_failure;
696+
if (bareudp->rx_collect_metadata &&
697+
nla_put_flag(skb, IFLA_BAREUDP_RX_COLLECT_METADATA))
698+
goto nla_put_failure;
688699

689700
return 0;
690701

include/net/bareudp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ struct bareudp_conf {
1212
__be16 port;
1313
u16 sport_min;
1414
bool multi_proto_mode;
15+
bool rx_collect_metadata;
1516
};
1617

1718
struct net_device *bareudp_dev_create(struct net *net, const char *name,

include/uapi/linux/if_link.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,7 @@ enum {
600600
IFLA_BAREUDP_ETHERTYPE,
601601
IFLA_BAREUDP_SRCPORT_MIN,
602602
IFLA_BAREUDP_MULTIPROTO_MODE,
603+
IFLA_BAREUDP_RX_COLLECT_METADATA,
603604
__IFLA_BAREUDP_MAX
604605
};
605606

0 commit comments

Comments
 (0)