blob: dc50efa76cceec1ae1eede4b114e8f3e9e4fba9e [file] [log] [blame]
Dave Hudsondcd08fb2013-11-22 09:25:16 -06001/*
2 * sfe_ipv4.h
3 * Shortcut forwarding engine.
4 *
5 * XXX - fill in the appropriate GPL notice.
6 */
7
8/*
9 * IPv4 connection flags.
10 */
11#define SFE_IPV4_CREATE_FLAG_NO_SEQ_CHECK 0x1
12 /* Indicates that we should not check sequence numbers */
13
14/*
15 * IPv4 connection creation structure.
16 */
17struct sfe_ipv4_create {
18 int protocol;
19 struct net_device *src_dev;
20 struct net_device *dest_dev;
Ben Menchaca0971b7a2014-01-10 14:43:02 -060021 struct sock *src_pppoe_sk;
22 struct sock *dest_pppoe_sk;
Dave Hudsondcd08fb2013-11-22 09:25:16 -060023 uint32_t flags;
24 uint32_t src_mtu;
25 uint32_t dest_mtu;
26 __be32 src_ip;
27 __be32 src_ip_xlate;
28 __be32 dest_ip;
29 __be32 dest_ip_xlate;
30 __be16 src_port;
31 __be16 src_port_xlate;
32 __be16 dest_port;
33 __be16 dest_port_xlate;
34 uint8_t src_mac[ETH_ALEN];
35 uint8_t src_mac_xlate[ETH_ALEN];
36 uint8_t dest_mac[ETH_ALEN];
37 uint8_t dest_mac_xlate[ETH_ALEN];
38 uint8_t src_td_window_scale;
39 uint32_t src_td_max_window;
40 uint32_t src_td_end;
41 uint32_t src_td_max_end;
42 uint8_t dest_td_window_scale;
43 uint32_t dest_td_max_window;
44 uint32_t dest_td_end;
45 uint32_t dest_td_max_end;
Matthew McClintockbe7b47d2013-11-27 13:26:23 -060046 uint32_t mark;
Dave Hudsondcd08fb2013-11-22 09:25:16 -060047};
48
49/*
50 * IPv4 connection destruction structure.
51 */
52struct sfe_ipv4_destroy {
53 int protocol;
54 __be32 src_ip;
55 __be32 dest_ip;
56 __be16 src_port;
57 __be16 dest_port;
58};
59
60/*
61 * Structure used to sync IPv4 connection stats/state back within the system.
62 *
63 * NOTE: The addresses here are NON-NAT addresses, i.e. the true endpoint addressing.
64 * 'src' is the creator of the connection.
65 */
66struct sfe_ipv4_sync {
67 int protocol; /* IP protocol number (IPPROTO_...) */
68 __be32 src_ip; /* Non-NAT source address, i.e. the creator of the connection */
69 __be16 src_port; /* Non-NAT source port */
Nicolas Costaac2979c2014-01-14 10:35:24 -060070 __be32 dest_ip; /* Non-NAT destination address, i.e. to whom the connection was created */
Dave Hudsondcd08fb2013-11-22 09:25:16 -060071 __be16 dest_port; /* Non-NAT destination port */
72 uint32_t src_td_max_window;
73 uint32_t src_td_end;
74 uint32_t src_td_max_end;
75 uint64_t src_packet_count;
76 uint64_t src_byte_count;
77 uint32_t dest_td_max_window;
78 uint32_t dest_td_end;
79 uint32_t dest_td_max_end;
80 uint64_t dest_packet_count;
81 uint64_t dest_byte_count;
82 uint64_t delta_jiffies; /* Time to be added to the current timeout to keep the connection alive */
83};
84
85/*
86 * Type used for a sync rule callback.
87 */
88typedef void (*sfe_ipv4_sync_rule_callback_t)(struct sfe_ipv4_sync *);
89
90extern int sfe_ipv4_recv(struct net_device *dev, struct sk_buff *skb);
Ben Menchaca0971b7a2014-01-10 14:43:02 -060091extern int sfe_pppoe_recv(struct net_device *dev, struct sk_buff *skb);
Dave Hudsondcd08fb2013-11-22 09:25:16 -060092extern void sfe_ipv4_create_rule(struct sfe_ipv4_create *sic);
93extern void sfe_ipv4_destroy_rule(struct sfe_ipv4_destroy *sid);
94extern void sfe_ipv4_destroy_all_rules_for_dev(struct net_device *dev);
95extern void sfe_ipv4_register_sync_rule_callback(sfe_ipv4_sync_rule_callback_t callback);
Nicolas Costa436926b2014-01-14 10:36:22 -060096extern void sfe_ipv4_update_rule(struct sfe_ipv4_create *sic);
Dave Hudsondcd08fb2013-11-22 09:25:16 -060097
Matthew McClintockbe7b47d2013-11-27 13:26:23 -060098/*
99 * IPv4 connection mark structure
100 */
101struct sfe_ipv4_mark {
102 int protocol;
103 __be32 src_ip;
104 __be32 dest_ip;
105 __be16 src_port;
106 __be16 dest_port;
107 uint32_t mark;
108};
109static void sfe_ipv4_mark_rule(struct sfe_ipv4_mark *mark);