lookup.saddr = saddr;
lookup.daddr = daddr;
- if (tunnel_type & TNL_T_KEY_EXACT) {
- lookup.in_key = key;
- lookup.tunnel_type = tunnel_type & ~TNL_T_KEY_MATCH;
-
- if (key_local_remote_ports) {
- vport = port_table_lookup(&lookup, mutable);
- if (vport)
- return vport;
- }
-
- if (key_remote_ports) {
- lookup.saddr = 0;
- vport = port_table_lookup(&lookup, mutable);
- if (vport)
- return vport;
-
- lookup.saddr = saddr;
- }
+ /* First try for exact match on in_key. */
+ lookup.in_key = key;
+ lookup.tunnel_type = tunnel_type | TNL_T_KEY_EXACT;
+ if (key_local_remote_ports) {
+ vport = port_table_lookup(&lookup, mutable);
+ if (vport)
+ return vport;
}
+ if (key_remote_ports) {
+ lookup.saddr = 0;
+ vport = port_table_lookup(&lookup, mutable);
+ if (vport)
+ return vport;
- if (tunnel_type & TNL_T_KEY_MATCH) {
- lookup.in_key = 0;
- lookup.tunnel_type = tunnel_type & ~TNL_T_KEY_EXACT;
-
- if (local_remote_ports) {
- vport = port_table_lookup(&lookup, mutable);
- if (vport)
- return vport;
- }
+ lookup.saddr = saddr;
+ }
- if (remote_ports) {
- lookup.saddr = 0;
- vport = port_table_lookup(&lookup, mutable);
- if (vport)
- return vport;
- }
+ /* Then try matches that wildcard in_key. */
+ lookup.in_key = 0;
+ lookup.tunnel_type = tunnel_type | TNL_T_KEY_MATCH;
+ if (local_remote_ports) {
+ vport = port_table_lookup(&lookup, mutable);
+ if (vport)
+ return vport;
+ }
+ if (remote_ports) {
+ lookup.saddr = 0;
+ vport = port_table_lookup(&lookup, mutable);
+ if (vport)
+ return vport;
}
return NULL;
/* These flags are only needed when calling tnl_find_port(). */
#define TNL_T_KEY_EXACT (1 << 10)
#define TNL_T_KEY_MATCH (1 << 11)
-#define TNL_T_KEY_EITHER (TNL_T_KEY_EXACT | TNL_T_KEY_MATCH)
/* Private flags not exposed to userspace in this form. */
#define TNL_F_IN_KEY_MATCH (1 << 16) /* Store the key in tun_id to match in flow table. */
goto out;
iph = ip_hdr(skb);
- vport = tnl_find_port(iph->daddr, iph->saddr, key,
- TNL_T_PROTO_CAPWAP | TNL_T_KEY_EITHER, &mutable);
+ vport = tnl_find_port(iph->daddr, iph->saddr, key, TNL_T_PROTO_CAPWAP,
+ &mutable);
if (unlikely(!vport)) {
icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
goto error;
if (tunnel_hdr_len < 0)
return;
- vport = tnl_find_port(iph->saddr, iph->daddr, key,
- TNL_T_PROTO_GRE | TNL_T_KEY_EITHER, &mutable);
+ vport = tnl_find_port(iph->saddr, iph->daddr, key, TNL_T_PROTO_GRE,
+ &mutable);
if (!vport)
return;
goto error;
iph = ip_hdr(skb);
- vport = tnl_find_port(iph->daddr, iph->saddr, key,
- TNL_T_PROTO_GRE | TNL_T_KEY_EITHER, &mutable);
+ vport = tnl_find_port(iph->daddr, iph->saddr, key, TNL_T_PROTO_GRE,
+ &mutable);
if (unlikely(!vport)) {
icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
goto error;