zoukankan      html  css  js  c++  java
  • OVS中的key解析

    OVS在处理每条流的时候,先根据每条流生产相应的key,然后根据key匹配相应的流表,根据流表中的action操作来处理每条流,本文对key的结构体进行分析,看看对于一条流会提出那些特征信息。对于key的描述在openvswitch源码中的flow.h文件中。
    
    struct sw_flow_key {
    	u8 tun_opts[255];
    	u8 tun_opts_len;
    	struct ip_tunnel_key tun_key;  /* Encapsulating tunnel key. */
    	struct {
    		u32	priority;	/* Packet QoS priority. */
    		u32	skb_mark;	/* SKB mark. */
    		u16	in_port;	/* Input switch port (or DP_MAX_PORTS). */
    	} __packed phy; /* Safe when right after 'tun_key'. */
    	u8 mac_proto;			/* MAC layer protocol (e.g. Ethernet). */
    	u8 tun_proto;                   /* Protocol of encapsulating tunnel. */
    	u32 ovs_flow_hash;		/* Datapath computed hash value.  */
    	u32 recirc_id;			/* Recirculation ID.  */
    	struct {
    		u8     src[ETH_ALEN];	/* Ethernet source address. */
    		u8     dst[ETH_ALEN];	/* Ethernet destination address. */
    		struct vlan_head vlan;
    		struct vlan_head cvlan;
    		__be16 type;		/* Ethernet frame type. */
    	} eth;
    	/* Filling a hole of two bytes. */
    	u8 ct_state;
    	u8 ct_orig_proto;		/* CT original direction tuple IP
    					 * protocol.
    					 */
    	union {
    		struct {
    			__be32 top_lse;	/* top label stack entry */
    		} mpls;
    		struct {
    			u8     proto;	/* IP protocol or lower 8 bits of ARP opcode. */
    			u8     tos;	    /* IP ToS. */
    			u8     ttl;	    /* IP TTL/hop limit. */
    			u8     frag;	/* One of OVS_FRAG_TYPE_*. */
    		} ip;
    	};
    	u16 ct_zone;			/* Conntrack zone. */
    	struct {
    		__be16 src;		/* TCP/UDP/SCTP source port. */
    		__be16 dst;		/* TCP/UDP/SCTP destination port. */
    		__be16 flags;		/* TCP flags. */
    	} tp;
    	union {
    		struct {
    			struct {
    				__be32 src;	/* IP source address. */
    				__be32 dst;	/* IP destination address. */
    			} addr;
    			union {
    				struct {
    					__be32 src;
    					__be32 dst;
    				} ct_orig;	/* Conntrack original direction fields. */
    				struct {
    					u8 sha[ETH_ALEN];	/* ARP source hardware address. */
    					u8 tha[ETH_ALEN];	/* ARP target hardware address. */
    				} arp;
    			};
    		} ipv4;
    		struct {
    			struct {
    				struct in6_addr src;	/* IPv6 source address. */
    				struct in6_addr dst;	/* IPv6 destination address. */
    			} addr;
    			__be32 label;			/* IPv6 flow label. */
    			union {
    				struct {
    					struct in6_addr src;
    					struct in6_addr dst;
    				} ct_orig;	/* Conntrack original direction fields. */
    				struct {
    					struct in6_addr target;	/* ND target address. */
    					u8 sll[ETH_ALEN];	/* ND source link layer address. */
    					u8 tll[ETH_ALEN];	/* ND target link layer address. */
    				} nd;
    			};
    		} ipv6;
    	};
    	struct {
    		/* Connection tracking fields not packed above. */
    		struct {
    			__be16 src;	/* CT orig tuple tp src port. */
    			__be16 dst;	/* CT orig tuple tp dst port. */
    		} orig_tp;
    		u32 mark;
    		struct ovs_key_ct_labels labels;
    	} ct;
    
    };
    
    struct ip_tunnel_key {
    	__be64			tun_id;
    	union {
    		struct {
    			__be32	src;
    			__be32	dst;
    		} ipv4;
    		struct {
    			struct in6_addr src;
    			struct in6_addr dst;
    		} ipv6;
    	} u;
    	__be16			tun_flags;
    	u8			tos;		/* TOS for IPv4, TC for IPv6 */
    	u8			ttl;		/* TTL for IPv4, HL for IPv6 */
    	__be32                  label;          /* Flow Label for IPv6 */
    	__be16			tp_src;
    	__be16			tp_dst;
    };
    

    (https://blog.csdn.net/yuzhihui_no1/article/details/39481745)[https://blog.csdn.net/yuzhihui_no1/article/details/39481745]

  • 相关阅读:
    <![CDATA[文本内容]]>
    Java对于表达式中的自动类型提升
    oracle循环语句
    Recastnavigation 创建 off-mesh link 的潜规则
    CritterAI 翻译 Configuration Parameters
    ndk-build 修改输出so位置 (change ndk-build output so lib file path )
    C# List<> Find相关接口学习
    C++ sizeof(struct) 的注意
    Unity使用Resources读取Resources路径下的二进制文件(Binary Data)必须使用 .bytes扩展名
    C++ ifstream ofstream 注意事项
  • 原文地址:https://www.cnblogs.com/xidongyu/p/9826709.html
Copyright © 2011-2022 走看看