aboutsummaryrefslogtreecommitdiffstats
path: root/net/openvswitch/vport.c
diff options
context:
space:
mode:
authorWenyu Zhang <wenyuz@vmware.com>2014-11-06 09:51:24 -0500
committerPravin B Shelar <pshelar@nicira.com>2014-11-09 21:58:44 -0500
commit8f0aad6f35f7e8b3118b7b8a65e8e76b135cc4cb (patch)
tree5f3dd8374c3c1584cb2b516f4191e70b82472f68 /net/openvswitch/vport.c
parent9ba559d9ca3711940be3e7207dac13c4f0654d43 (diff)
openvswitch: Extend packet attribute for egress tunnel info
OVS vswitch has extended IPFIX exporter to export tunnel headers to improve network visibility. To export this information userspace needs to know egress tunnel for given packet. By extending packet attributes datapath can export egress tunnel info for given packet. So that userspace can ask for egress tunnel info in userspace action. This information is used to build IPFIX data for given flow. Signed-off-by: Wenyu Zhang <wenyuz@vmware.com> Acked-by: Romain Lenglet <rlenglet@vmware.com> Acked-by: Ben Pfaff <blp@nicira.com> Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Diffstat (limited to 'net/openvswitch/vport.c')
-rw-r--r--net/openvswitch/vport.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c
index 4b5dd18953a6..630e81984b65 100644
--- a/net/openvswitch/vport.c
+++ b/net/openvswitch/vport.c
@@ -573,3 +573,64 @@ void ovs_vport_deferred_free(struct vport *vport)
573 call_rcu(&vport->rcu, free_vport_rcu); 573 call_rcu(&vport->rcu, free_vport_rcu);
574} 574}
575EXPORT_SYMBOL_GPL(ovs_vport_deferred_free); 575EXPORT_SYMBOL_GPL(ovs_vport_deferred_free);
576
577int ovs_tunnel_get_egress_info(struct ovs_tunnel_info *egress_tun_info,
578 struct net *net,
579 const struct ovs_tunnel_info *tun_info,
580 u8 ipproto,
581 u32 skb_mark,
582 __be16 tp_src,
583 __be16 tp_dst)
584{
585 const struct ovs_key_ipv4_tunnel *tun_key;
586 struct rtable *rt;
587 struct flowi4 fl;
588
589 if (unlikely(!tun_info))
590 return -EINVAL;
591
592 tun_key = &tun_info->tunnel;
593
594 /* Route lookup to get srouce IP address.
595 * The process may need to be changed if the corresponding process
596 * in vports ops changed.
597 */
598 memset(&fl, 0, sizeof(fl));
599 fl.daddr = tun_key->ipv4_dst;
600 fl.saddr = tun_key->ipv4_src;
601 fl.flowi4_tos = RT_TOS(tun_key->ipv4_tos);
602 fl.flowi4_mark = skb_mark;
603 fl.flowi4_proto = IPPROTO_GRE;
604
605 rt = ip_route_output_key(net, &fl);
606 if (IS_ERR(rt))
607 return PTR_ERR(rt);
608
609 ip_rt_put(rt);
610
611 /* Generate egress_tun_info based on tun_info,
612 * saddr, tp_src and tp_dst
613 */
614 __ovs_flow_tun_info_init(egress_tun_info,
615 fl.saddr, tun_key->ipv4_dst,
616 tun_key->ipv4_tos,
617 tun_key->ipv4_ttl,
618 tp_src, tp_dst,
619 tun_key->tun_id,
620 tun_key->tun_flags,
621 tun_info->options,
622 tun_info->options_len);
623
624 return 0;
625}
626EXPORT_SYMBOL_GPL(ovs_tunnel_get_egress_info);
627
628int ovs_vport_get_egress_tun_info(struct vport *vport, struct sk_buff *skb,
629 struct ovs_tunnel_info *info)
630{
631 /* get_egress_tun_info() is only implemented on tunnel ports. */
632 if (unlikely(!vport->ops->get_egress_tun_info))
633 return -EINVAL;
634
635 return vport->ops->get_egress_tun_info(vport, skb, info);
636}