Change-Id: I3425b1533b3d31210166e7b3798685464ad1c489
Signed-off-by: Florin Coras <fcoras@cisco.com>
return (ip46_address->as_u64[0] == 0 && ip46_address->as_u64[1] == 1);
}
return (ip46_address->as_u64[0] == 0 && ip46_address->as_u64[1] == 1);
}
+u8
+ip4_is_local_host (ip4_address_t * ip4_address)
+{
+ return (ip4_address->as_u8[0] == 127);
+}
+
+u8
+ip6_is_local_host (ip6_address_t * ip6_address)
+{
+ return (ip6_address->as_u64[0] == 0 && ip6_address->as_u64[1] == 1);
+}
+
/**
* Checks that an ip is local to the requested fib
*/
/**
* Checks that an ip is local to the requested fib
*/
u8 ip_is_zero (ip46_address_t * ip46_address, u8 is_ip4);
u8 ip_is_local_host (ip46_address_t * ip46_address, u8 is_ip4);
u8 ip_is_zero (ip46_address_t * ip46_address, u8 is_ip4);
u8 ip_is_local_host (ip46_address_t * ip46_address, u8 is_ip4);
+u8 ip4_is_local_host (ip4_address_t * ip4_address);
+u8 ip6_is_local_host (ip6_address_t * ip6_address);
u8 ip_is_local (u32 fib_index, ip46_address_t * ip46_address, u8 is_ip4);
u8 ip_interface_has_address (u32 sw_if_index, ip46_address_t * ip, u8 is_ip4);
void ip_copy (ip46_address_t * dst, ip46_address_t * src, u8 is_ip4);
u8 ip_is_local (u32 fib_index, ip46_address_t * ip46_address, u8 is_ip4);
u8 ip_interface_has_address (u32 sw_if_index, ip46_address_t * ip, u8 is_ip4);
void ip_copy (ip46_address_t * dst, ip46_address_t * src, u8 is_ip4);
* Zero out the ip. Logic is that connect to local ips, say
* 127.0.0.1:port, can match 0.0.0.0:port
*/
* Zero out the ip. Logic is that connect to local ips, say
* 127.0.0.1:port, can match 0.0.0.0:port
*/
- kv4.key[0] = 0;
- rv = clib_bihash_search_inline_16_8 (&st->v4_session_hash, &kv4);
- if (rv == 0)
- return kv4.value;
+ if (ip4_is_local_host (&sep->ip.ip4))
+ {
+ kv4.key[0] = 0;
+ rv = clib_bihash_search_inline_16_8 (&st->v4_session_hash, &kv4);
+ if (rv == 0)
+ return kv4.value;
+ }
+ else
+ {
+ kv4.key[0] = 0;
+ }
/*
* Zero out the port and check if we have proxy
/*
* Zero out the port and check if we have proxy
/*
* Zero out the ip. Same logic as above.
*/
/*
* Zero out the ip. Same logic as above.
*/
- kv6.key[0] = kv6.key[1] = 0;
- rv = clib_bihash_search_inline_48_8 (&st->v6_session_hash, &kv6);
- if (rv == 0)
- return kv6.value;
+
+ if (ip6_is_local_host (&sep->ip.ip6))
+ {
+ kv6.key[0] = kv6.key[1] = 0;
+ rv = clib_bihash_search_inline_48_8 (&st->v6_session_hash, &kv6);
+ if (rv == 0)
+ return kv6.value;
+ }
+ else
+ {
+ kv6.key[0] = kv6.key[1] = 0;
+ }
/*
* Zero out the port. Same logic as above.
/*
* Zero out the port. Same logic as above.
return SESSION_INVALID_HANDLE;
}
return SESSION_INVALID_HANDLE;
}
-static stream_session_t *
+static inline stream_session_t *
session_lookup_listener4_i (session_table_t * st, ip4_address_t * lcl,
session_lookup_listener4_i (session_table_t * st, ip4_address_t * lcl,
- u16 lcl_port, u8 proto)
+ u16 lcl_port, u8 proto, u8 use_wildcard)
{
session_kv4_t kv4;
int rv;
{
session_kv4_t kv4;
int rv;
/*
* Zero out the lcl ip and check if any 0/0 port binds have been done
*/
/*
* Zero out the lcl ip and check if any 0/0 port binds have been done
*/
- kv4.key[0] = 0;
- rv = clib_bihash_search_inline_16_8 (&st->v4_session_hash, &kv4);
- if (rv == 0)
- return session_manager_get_listener (session_type, (u32) kv4.value);
+ if (use_wildcard)
+ {
+ kv4.key[0] = 0;
+ rv = clib_bihash_search_inline_16_8 (&st->v4_session_hash, &kv4);
+ if (rv == 0)
+ return session_manager_get_listener (session_type, (u32) kv4.value);
+ }
+ else
+ {
+ kv4.key[0] = 0;
+ }
/*
* Zero out port and check if we have a proxy set up for our ip
/*
* Zero out port and check if we have a proxy set up for our ip
st = session_table_get_for_fib_index (FIB_PROTOCOL_IP4, fib_index);
if (!st)
return 0;
st = session_table_get_for_fib_index (FIB_PROTOCOL_IP4, fib_index);
if (!st)
return 0;
- return session_lookup_listener4_i (st, lcl, lcl_port, proto);
+ return session_lookup_listener4_i (st, lcl, lcl_port, proto, 0);
}
static stream_session_t *
session_lookup_listener6_i (session_table_t * st, ip6_address_t * lcl,
}
static stream_session_t *
session_lookup_listener6_i (session_table_t * st, ip6_address_t * lcl,
- u16 lcl_port, u8 proto)
+ u16 lcl_port, u8 proto, u8 ip_wildcard)
{
session_kv6_t kv6;
int rv;
{
session_kv6_t kv6;
int rv;
return session_manager_get_listener (session_type, (u32) kv6.value);
/* Zero out the lcl ip */
return session_manager_get_listener (session_type, (u32) kv6.value);
/* Zero out the lcl ip */
- kv6.key[0] = kv6.key[1] = 0;
- rv = clib_bihash_search_inline_48_8 (&st->v6_session_hash, &kv6);
- if (rv == 0)
- return session_manager_get_listener (session_type, (u32) kv6.value);
+ if (ip_wildcard)
+ {
+ kv6.key[0] = kv6.key[1] = 0;
+ rv = clib_bihash_search_inline_48_8 (&st->v6_session_hash, &kv6);
+ if (rv == 0)
+ return session_manager_get_listener (session_type, (u32) kv6.value);
+ }
+ else
+ {
+ kv6.key[0] = kv6.key[1] = 0;
+ }
make_v6_proxy_kv (&kv6, lcl, proto);
rv = clib_bihash_search_inline_48_8 (&st->v6_session_hash, &kv6);
make_v6_proxy_kv (&kv6, lcl, proto);
rv = clib_bihash_search_inline_48_8 (&st->v6_session_hash, &kv6);
st = session_table_get_for_fib_index (FIB_PROTOCOL_IP6, fib_index);
if (!st)
return 0;
st = session_table_get_for_fib_index (FIB_PROTOCOL_IP6, fib_index);
if (!st)
return 0;
- return session_lookup_listener6_i (st, lcl, lcl_port, proto);
+ return session_lookup_listener6_i (st, lcl, lcl_port, proto, 1);
+/**
+ * Lookup listener, exact or proxy (inaddr_any:0) match
+ */
stream_session_t *
session_lookup_listener (u32 table_index, session_endpoint_t * sep)
{
stream_session_t *
session_lookup_listener (u32 table_index, session_endpoint_t * sep)
{
return 0;
if (sep->is_ip4)
return session_lookup_listener4_i (st, &sep->ip.ip4, sep->port,
return 0;
if (sep->is_ip4)
return session_lookup_listener4_i (st, &sep->ip.ip4, sep->port,
+ sep->transport_proto, 0);
else
return session_lookup_listener6_i (st, &sep->ip.ip6, sep->port,
else
return session_lookup_listener6_i (st, &sep->ip.ip6, sep->port,
+ sep->transport_proto, 0);
/*
* If nothing is found, check if any listener is available
*/
/*
* If nothing is found, check if any listener is available
*/
- s = session_lookup_listener4_i (st, lcl, lcl_port, proto);
+ s = session_lookup_listener4_i (st, lcl, lcl_port, proto, 1);
if (s)
return tp_vfts[proto].get_listener (s->connection_index);
if (s)
return tp_vfts[proto].get_listener (s->connection_index);
/*
* If nothing is found, check if any listener is available
*/
/*
* If nothing is found, check if any listener is available
*/
- s = session_lookup_listener4_i (st, lcl, lcl_port, proto);
+ s = session_lookup_listener4_i (st, lcl, lcl_port, proto, 1);
if (s)
return tp_vfts[proto].get_listener (s->connection_index);
if (s)
return tp_vfts[proto].get_listener (s->connection_index);
/*
* If nothing is found, check if any listener is available
*/
/*
* If nothing is found, check if any listener is available
*/
- if ((s = session_lookup_listener4_i (st, lcl, lcl_port, proto)))
+ if ((s = session_lookup_listener4_i (st, lcl, lcl_port, proto, 1)))
}
/* If nothing is found, check if any listener is available */
}
/* If nothing is found, check if any listener is available */
- s = session_lookup_listener6_i (st, lcl, lcl_port, proto);
+ s = session_lookup_listener6_i (st, lcl, lcl_port, proto, 1);
if (s)
return tp_vfts[proto].get_listener (s->connection_index);
if (s)
return tp_vfts[proto].get_listener (s->connection_index);
}
/* If nothing is found, check if any listener is available */
}
/* If nothing is found, check if any listener is available */
- s = session_lookup_listener6 (fib_index, lcl, lcl_port, proto);
+ s = session_lookup_listener6_i (st, lcl, lcl_port, proto, 1);
if (s)
return tp_vfts[proto].get_listener (s->connection_index);
if (s)
return tp_vfts[proto].get_listener (s->connection_index);
}
/* If nothing is found, check if any listener is available */
}
/* If nothing is found, check if any listener is available */
- if ((s = session_lookup_listener6_i (st, lcl, lcl_port, proto)))
+ if ((s = session_lookup_listener6_i (st, lcl, lcl_port, proto, 1)))