2
0
mirror of https://github.com/openvswitch/ovs synced 2025-09-05 00:35:33 +00:00

tc: Add tc flower functions

Add tc helper functions to query and manipulate the flower classifier.

Signed-off-by: Paul Blakey <paulb@mellanox.com>
Co-authored-by: Roi Dayan <roid@mellanox.com>
Signed-off-by: Roi Dayan <roid@mellanox.com>
Acked-by: Flavio Leitner <fbl@sysclose.org>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
This commit is contained in:
Roi Dayan
2017-06-13 18:03:27 +03:00
committed by Simon Horman
parent 837f5250e8
commit f98e418fbd
2 changed files with 1103 additions and 0 deletions

998
lib/tc.c

File diff suppressed because it is too large Load Diff

105
lib/tc.h
View File

@@ -1,5 +1,6 @@
/*
* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 Nicira, Inc.
* Copyright (c) 2016 Mellanox Technologies, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,8 +21,21 @@
#include <linux/pkt_cls.h>
#include <linux/pkt_sched.h>
#include <linux/rtnetlink.h>
#include <netinet/in.h>
#include "lib/netlink-socket.h"
#include "odp-netlink.h"
#include "openvswitch/ofpbuf.h"
/* For backwards compatability with older kernels */
#ifndef TC_H_CLSACT
#define TC_H_CLSACT TC_H_INGRESS
#endif
#ifndef TC_H_MIN_INGRESS
#define TC_H_MIN_INGRESS 0xFFF2U
#endif
#define TC_INGRESS_PARENT TC_H_MAKE(TC_H_CLSACT, TC_H_MIN_INGRESS)
/* Returns tc handle 'major':'minor'. */
static inline unsigned int
tc_make_handle(unsigned int major, unsigned int minor)
@@ -48,4 +62,95 @@ struct tcmsg *tc_make_request(int ifindex, int type,
int tc_transact(struct ofpbuf *request, struct ofpbuf **replyp);
int tc_add_del_ingress_qdisc(int ifindex, bool add);
struct tc_cookie {
const void *data;
size_t len;
};
struct tc_flower_key {
ovs_be16 eth_type;
uint8_t ip_proto;
struct eth_addr dst_mac;
struct eth_addr src_mac;
ovs_be16 src_port;
ovs_be16 dst_port;
uint16_t vlan_id;
uint8_t vlan_prio;
ovs_be16 encap_eth_type;
union {
struct {
ovs_be32 ipv4_src;
ovs_be32 ipv4_dst;
} ipv4;
struct {
struct in6_addr ipv6_src;
struct in6_addr ipv6_dst;
} ipv6;
};
};
struct tc_flower {
uint32_t handle;
uint32_t prio;
struct tc_flower_key key;
struct tc_flower_key mask;
uint8_t vlan_pop;
uint16_t vlan_push_id;
uint8_t vlan_push_prio;
int ifindex_out;
struct ovs_flow_stats stats;
uint64_t lastused;
struct {
bool set;
ovs_be64 id;
ovs_be16 tp_src;
ovs_be16 tp_dst;
struct {
ovs_be32 ipv4_src;
ovs_be32 ipv4_dst;
} ipv4;
struct {
struct in6_addr ipv6_src;
struct in6_addr ipv6_dst;
} ipv6;
} set;
struct {
bool tunnel;
struct {
ovs_be32 ipv4_src;
ovs_be32 ipv4_dst;
} ipv4;
struct {
struct in6_addr ipv6_src;
struct in6_addr ipv6_dst;
} ipv6;
ovs_be64 id;
ovs_be16 tp_src;
ovs_be16 tp_dst;
} tunnel;
struct tc_cookie act_cookie;
};
int tc_replace_flower(int ifindex, uint16_t prio, uint32_t handle,
struct tc_flower *flower);
int tc_del_filter(int ifindex, int prio, int handle);
int tc_get_flower(int ifindex, int prio, int handle,
struct tc_flower *flower);
int tc_flush(int ifindex);
int tc_dump_flower_start(int ifindex, struct nl_dump *dump);
int parse_netlink_to_tc_flower(struct ofpbuf *reply,
struct tc_flower *flower);
#endif /* tc.h */