-
- if (is_internal_dev(rt_dst(rt).dev)) {
- struct sw_flow_key flow_key;
- struct tbl_node *flow_node;
- struct vport *dst_vport;
- struct sk_buff *skb;
- bool is_frag;
- int err;
-
- dst_vport = internal_dev_get_vport(rt_dst(rt).dev);
- if (!dst_vport)
- goto done;
-
- skb = alloc_skb(cache->len, GFP_ATOMIC);
- if (!skb)
- goto done;
-
- __skb_put(skb, cache->len);
- memcpy(skb->data, get_cached_header(cache), cache->len);
-
- err = flow_extract(skb, dst_vport->port_no, &flow_key, &is_frag);
-
- kfree_skb(skb);
- if (err || is_frag)
- goto done;
-
- flow_node = tbl_lookup(rcu_dereference(dst_vport->dp->table),
- &flow_key, flow_hash(&flow_key),
- flow_cmp);
- if (flow_node) {
- struct sw_flow *flow = flow_cast(flow_node);
-
- cache->flow = flow;
- flow_hold(flow);
- }
- }
-
-done:
- assign_cache_rcu(vport, cache);
-
-unlock:
- spin_unlock_bh(&tnl_vport->cache_lock);
-
- return cache;
-}
-
-static struct rtable *find_route(struct vport *vport,
- const struct tnl_mutable_config *mutable,
- u8 tos, struct tnl_cache **cache)
-{
- struct tnl_vport *tnl_vport = tnl_vport_priv(vport);
- struct tnl_cache *cur_cache = rcu_dereference(tnl_vport->cache);
-
- *cache = NULL;
- tos = RT_TOS(tos);
-
- if (likely(tos == mutable->tos && check_cache_valid(cur_cache, mutable))) {
- *cache = cur_cache;
- return cur_cache->rt;
- } else {
- struct rtable *rt;
- struct flowi fl = { .nl_u = { .ip4_u =
- { .daddr = mutable->daddr,
- .saddr = mutable->saddr,
- .tos = tos } },
- .proto = tnl_vport->tnl_ops->ipproto };
-
- if (unlikely(ip_route_output_key(&init_net, &rt, &fl)))
- return NULL;
-
- if (likely(tos == mutable->tos))
- *cache = build_cache(vport, mutable, rt);
-
- return rt;
- }
-}
-
-static struct sk_buff *check_headroom(struct sk_buff *skb, int headroom)
-{
- if (skb_headroom(skb) < headroom || skb_header_cloned(skb)) {
- struct sk_buff *nskb = skb_realloc_headroom(skb, headroom + 16);
- if (unlikely(!nskb)) {
- kfree_skb(skb);
- return ERR_PTR(-ENOMEM);
- }
-
- set_skb_csum_bits(skb, nskb);
-
- if (skb->sk)
- skb_set_owner_w(nskb, skb->sk);
-
- kfree_skb(skb);
- return nskb;
- }
-
- return skb;