blob: d486505260f9f5b41704e876b670241bcc2685b4 [file] [log] [blame]
Ben Menchaca84f36632014-02-28 20:57:38 +00001/*
2 **************************************************************************
Murat Sezgin5dae8832015-12-03 14:23:19 -08003 * Copyright (c) 2014-2016 The Linux Foundation. All rights reserved.
Ben Menchaca84f36632014-02-28 20:57:38 +00004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all copies.
7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
13 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14 **************************************************************************
15 */
16
17/*
Ben Menchaca84f36632014-02-28 20:57:38 +000018 * struct ecm_interface_route
19 * An ecm route supports either v4 or v6 routing information
20 */
21struct ecm_interface_route {
22 struct dst_entry *dst; /* Both ipv4 and v6 have a common dst entry */
23 union {
24 struct rtable *rtv4; /* IPv4 route */
25 struct rt6_info *rtv6; /* IPv6 route */
26 } rt;
27 bool v4_route; /* True when a v4 route, false when v6 */
28};
29
30/*
Shyam Sunder6358b862015-05-04 15:06:24 +053031 * Netdev Index value for a Loopback device
32 */
33#define ECM_INTERFACE_LOOPBACK_DEV_INDEX 1
34
35/*
Ben Menchaca84f36632014-02-28 20:57:38 +000036 * External defined functions
37 */
38extern struct net_device *bond_get_tx_dev(struct sk_buff *skb, uint8_t *src_mac,
39 uint8_t *dst_mac, void *src,
40 void *dst, uint16_t protocol,
Suman Ghoshfb8e7702015-08-20 15:27:57 +053041 struct net_device *bond_dev,
42 __be16 *layer4hdr);
Murat Sezgin5dae8832015-12-03 14:23:19 -080043bool ecm_interface_mac_addr_get_no_route(struct net_device *dev, ip_addr_t ip_addr, uint8_t *mac_addr);
Ben Menchaca84f36632014-02-28 20:57:38 +000044bool ecm_interface_mac_addr_get(ip_addr_t addr, uint8_t *mac_addr, bool *on_link, ip_addr_t gw_addr);
45bool ecm_interface_find_route_by_addr(ip_addr_t addr, struct ecm_interface_route *ecm_rt);
46void ecm_interface_route_release(struct ecm_interface_route *rt);
Murat Sezgin188b4a32015-06-03 10:58:59 -070047#ifdef ECM_IPV6_ENABLE
48void ecm_interface_send_neighbour_solicitation(struct net_device *dev, ip_addr_t addr);
49#endif
50void ecm_interface_send_arp_request(struct net_device *dest_dev, ip_addr_t dest_addr, bool on_link, ip_addr_t gw_addr);
Xiaoping Fanc7735462015-08-09 18:57:26 -070051struct neighbour *ecm_interface_ipv4_neigh_get(ip_addr_t addr);
52#ifdef ECM_IPV6_ENABLE
53struct neighbour *ecm_interface_ipv6_neigh_get(ip_addr_t addr);
54#endif
Shyam Sunder23f2e542015-09-28 14:56:49 +053055bool ecm_interface_skip_pptp(struct sk_buff *skb, const struct net_device *out);
56bool ecm_interface_skip_l2tp_packet_by_version(struct sk_buff *skb, const struct net_device *out, int ver);
Xiaoping Fan80e406b2015-01-29 16:15:31 -080057bool ecm_interface_skip_l2tp_pptp(struct sk_buff *skb, const struct net_device *out);
ratheesh kannotha32fdd12015-09-09 08:02:58 +053058struct ecm_db_iface_instance *ecm_interface_establish_and_ref(struct ecm_front_end_connection_instance *feci, struct net_device *dev, struct sk_buff *skb);
Shyam Sunder6358b862015-05-04 15:06:24 +053059
60#ifdef ECM_MULTICAST_ENABLE
Shyam Sundera2e08ee2015-06-18 21:32:13 +053061int32_t ecm_interface_multicast_heirarchy_construct_routed(struct ecm_front_end_connection_instance *feci, struct ecm_db_iface_instance *interfaces, struct net_device *in_dev, ip_addr_t packet_src_addr, ip_addr_t packet_dest_addr, uint8_t maxvif, uint32_t *dst_dev, uint32_t *to_interface_first, bool mfc_update, __be16 *layer4hdr, struct sk_buff *skb);
Shyam Sunder6358b862015-05-04 15:06:24 +053062
ratheesh kannotha32fdd12015-09-09 08:02:58 +053063int32_t ecm_interface_multicast_heirarchy_construct_bridged(struct ecm_front_end_connection_instance *feci, struct ecm_db_iface_instance *interfaces, struct net_device *br_dev, ip_addr_t src_addr, ip_addr_t dest_addr, uint8_t mc_max_dst, int32_t *mc_dst_dev, uint32_t *to_interface_first, uint8_t *src_node_addr, __be16 *layer4hdr, struct sk_buff *skb);
Shyam Sunder6358b862015-05-04 15:06:24 +053064
65void ecm_interface_multicast_stats_update(struct ecm_db_connection_instance *ci, uint32_t from_tx_packets, uint32_t from_tx_bytes, uint32_t from_rx_packets, uint32_t from_rx_bytes, uint32_t to_tx_packets, uint32_t to_tx_bytes, uint32_t to_rx_packets, uint32_t to_rx_bytes);
66
67bool ecm_interface_multicast_find_updates_to_iface_list(struct ecm_db_connection_instance *ci, struct ecm_multicast_if_update *, uint32_t flags, bool is_br_snooper, uint32_t *dst_dev, uint32_t max_to_dev);
68
69bool ecm_interface_multicast_check_for_br_dev(uint32_t dest_if[], uint8_t max_if);
Shyam Sundera2e08ee2015-06-18 21:32:13 +053070
71int32_t ecm_interface_multicast_check_for_src_ifindex(int32_t mc_if_index[], int32_t max_if_index, int32_t if_num);
Murat Sezgin5dae8832015-12-03 14:23:19 -080072int32_t ecm_interface_multicast_from_heirarchy_construct(struct ecm_front_end_connection_instance *feci,
Murat Sezgin91c5d712015-06-12 15:16:22 -070073 struct ecm_db_iface_instance *interfaces[],
Murat Sezgin188b4a32015-06-03 10:58:59 -070074 ip_addr_t packet_src_addr, ip_addr_t packet_dest_addr,
75 int ip_version, int packet_protocol,
76 struct net_device *given_dest_dev, bool is_routed,
77 struct net_device *given_src_dev,
Suman Ghoshfb8e7702015-08-20 15:27:57 +053078 uint8_t *dest_node_addr, uint8_t *src_node_addr,
ratheesh kannotha32fdd12015-09-09 08:02:58 +053079 __be16 *layer4hdr, struct sk_buff *skb);
Murat Sezgin5dae8832015-12-03 14:23:19 -080080#endif
81
82int32_t ecm_interface_heirarchy_construct(struct ecm_front_end_connection_instance *feci,
83 struct ecm_db_iface_instance *interfaces[],
84 struct net_device *const_if, struct net_device *other_if,
85 ip_addr_t packet_src_addr,
86 ip_addr_t packet_dest_addr,
87 int ip_version, int packet_protocol,
88 struct net_device *given_dest_dev,
89 bool is_routed, struct net_device *given_src_dev,
90 uint8_t *dest_node_addr, uint8_t *src_node_addr,
91 __be16 *layer4hdr, struct sk_buff *skb);
Murat Sezgin188b4a32015-06-03 10:58:59 -070092void ecm_interface_stats_update(struct ecm_db_connection_instance *ci, uint32_t from_tx_packets, uint32_t from_tx_bytes, uint32_t from_rx_packets, uint32_t from_rx_bytes, uint32_t to_tx_packets, uint32_t to_tx_bytes, uint32_t to_rx_packets, uint32_t to_rx_bytes);
Gareth Williams46f4b5f2014-06-01 23:35:23 +010093struct net_device *ecm_interface_dev_find_by_addr(ip_addr_t addr, bool *from_local_addr);
Shyam Sunder6358b862015-05-04 15:06:24 +053094void ecm_interface_stats_update(struct ecm_db_connection_instance *ci, uint32_t from_tx_packets, uint32_t from_tx_bytes, uint32_t from_rx_packets, uint32_t from_rx_bytes, uint32_t to_tx_packets, uint32_t to_tx_bytes, uint32_t to_rx_packets, uint32_t to_rx_bytes);
95
Murat Sezginb3731e82014-11-26 12:20:59 -080096struct net_device *ecm_interface_get_and_hold_dev_master(struct net_device *dev);
Tushar Mathurcccbf282015-01-13 01:22:44 +053097void ecm_interface_dev_regenerate_connections(struct net_device *dev);
ratheesh kannotha32fdd12015-09-09 08:02:58 +053098struct net_device *ecm_interface_dev_find_by_local_addr(ip_addr_t addr);
Murat Sezgin5dae8832015-12-03 14:23:19 -080099bool ecm_interface_find_gateway(ip_addr_t addr, ip_addr_t gw_addr);