Skip to content

Commit e0f31d8

Browse files
Govindarajulu Varadarajandavem330
authored andcommitted
flow_keys: Record IP layer protocol in skb_flow_dissect()
skb_flow_dissect() dissects only transport header type in ip_proto. It dose not give any information about IPv4 or IPv6. This patch adds new member, n_proto, to struct flow_keys. Which records the IP layer type. i.e IPv4 or IPv6. This can be used in netdev->ndo_rx_flow_steer driver function to dissect flow. Adding new member to flow_keys increases the struct size by around 4 bytes. This causes BUILD_BUG_ON(sizeof(qcb->data) < sz); to fail in qdisc_cb_private_validate() So increase data size by 4 Signed-off-by: Govindarajulu Varadarajan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent eef9296 commit e0f31d8

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

include/net/flow_keys.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
#ifndef _NET_FLOW_KEYS_H
22
#define _NET_FLOW_KEYS_H
33

4+
/* struct flow_keys:
5+
* @src: source ip address in case of IPv4
6+
* For IPv6 it contains 32bit hash of src address
7+
* @dst: destination ip address in case of IPv4
8+
* For IPv6 it contains 32bit hash of dst address
9+
* @ports: port numbers of Transport header
10+
* port16[0]: src port number
11+
* port16[1]: dst port number
12+
* @thoff: Transport header offset
13+
* @n_proto: Network header protocol (eg. IPv4/IPv6)
14+
* @ip_proto: Transport header protocol (eg. TCP/UDP)
15+
* All the members, except thoff, are in network byte order.
16+
*/
417
struct flow_keys {
518
/* (src,dst) must be grouped, in the same way than in IP header */
619
__be32 src;
@@ -10,6 +23,7 @@ struct flow_keys {
1023
__be16 port16[2];
1124
};
1225
u16 thoff;
26+
u16 n_proto;
1327
u8 ip_proto;
1428
};
1529

include/net/sch_generic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ struct qdisc_skb_cb {
231231
unsigned int pkt_len;
232232
u16 slave_dev_queue_mapping;
233233
u16 _pad;
234-
unsigned char data[20];
234+
unsigned char data[24];
235235
};
236236

237237
static inline void qdisc_cb_private_validate(const struct sk_buff *skb, int sz)

net/core/flow_dissector.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ bool skb_flow_dissect(const struct sk_buff *skb, struct flow_keys *flow)
175175
break;
176176
}
177177

178+
flow->n_proto = proto;
178179
flow->ip_proto = ip_proto;
179180
flow->ports = skb_flow_get_ports(skb, nhoff, ip_proto);
180181
flow->thoff = (u16) nhoff;

0 commit comments

Comments
 (0)