[Openvswitch] 0-Object

Source: Internet
Author: User
Openvswitch uses a lot of object-oriented ideas in implementation, such as classes. One of the most typical implementations is ofproto_class in the ofproto structure, which contains function pointers for processing functions of all major openflow objects. This struct is declared in the ofproto-provider.h and defined in the ofproto-dpif.c (in fact dpif_class is also closely related to it ). We pass through its declaration part (too long) and look at the definition directly.

const struct ofproto_class ofproto_dpif_class = {    enumerate_types,    enumerate_names,
//ofproto    del,    alloc,    construct,    destruct,    dealloc,    run,    run_fast,    wait,    flush,    get_features,    get_tables,
//ofport    port_alloc,    port_construct,    port_destruct,    port_dealloc,    port_modified,    port_reconfigured,    port_query_by_name,    port_add,    port_del,    port_get_stats,    port_dump_start,    port_dump_next,    port_dump_done,    port_poll,    port_poll_wait,    port_is_lacp_current,
//ofrule    NULL,                       /* rule_choose_table */    rule_alloc,    rule_construct,    rule_destruct,    rule_dealloc,    rule_get_stats,    rule_execute,    rule_modify_actions,
//others    set_frag_handling,    packet_out,    set_netflow,    get_netflow_ids,    set_sflow,    set_cfm,    get_cfm_fault,    get_cfm_remote_mpids,    get_cfm_health,    set_stp,    get_stp_status,    set_stp_port,    get_stp_port_status,    set_queues,    bundle_set,    bundle_remove,    mirror_set,    mirror_get_stats,    set_flood_vlans,    is_mirror_output_bundle,    forward_bpdu_changed,    set_mac_idle_time,    set_realdev,};

We can see that there are many different objects in this function set, and they are all included together. Standard Oo should be separated, but here for simplicity (?), Put all function pointers together. Let's take a look at all the objects in it:Ofproto (of prototype), ofport, rule, bundle, MirrorAnd some miscellaneous objects such as NetFlow and sFlow. And sub-concepts that belong to different objects, such as frag, STP, and CFM. As shown above, we provide the main processing functions and see the correspondingFive main objectsNext, we will analyze the main objects.

1. ofproto

It is the specific implementation of the openflow switch, which reflects the will of openflow. It mainly includes the concepts of ofport and ofrule. It is noted that ofrule is loaded with oftable here.

Struct ofproto {struct hmap_node;/* in global 'all _ ofprotos 'hmap. */const struct ofproto_class * ofproto_class; // the char * type of the function set we mentioned at the beginning;/* datapath type. */char * Name;/* datapath name. * // * settings. */uint64_t fallback_dpid;/* datapath ID if no better choice found. */uint64_t datapath_id;/* datapath ID. corresponding kernel dp id */unsigned flow_eviction_threshold;/* threshold at which T O begin flow * Table eviction. only affects the * ofproto-DPIF implementation */bool forward_bpdu;/* option to allow forwarding of BPDU frames * when normal action is invoked. generate tree messages * // manufacturers, parameters, and so on. Char * mfr_desc;/* manufacturer. */char * hw_desc;/* hardware. */char * sw_desc;/* software version. */char * serial_desc;/* serial number. */char * dp_desc;/* datapath description. */Enum ofp_config_flags frag_handling;/* One of ofpc _*. * // * datapath. use hmap to load all ports */struct hmap ports;/* contains "struct ofport" s. */struct Shash port_by_name;/* flow tables. here, the tables is an array, and the interior is the rule set of the hmap Index */struct oftable * Tables; int n_tables;/* openflow connections. the connection management structure may be from ovs-CTL or controller */struct connmgr * connmgr;/* flow table operation tracking. all operations to be completed are suspended on the pending list */INT state;/* internal state. */struct list pending;/* List of "struct ofopgroup" s. */unsigned int n_pending;/* list_size (& pending ). */struct hmap deletions;/* All ofoperation_delete "ofoperation" s. * // * Linux VLAN Device Support (e.g. "eth0.10" for VLAN 10 .) ** this is deprecated. it is only for compatibility with broken device * drivers in old versions of Linux that do not properly support VLANs when * VLAN devices are not used. when broken device drivers are no longer in * widespread use, we will delete these interfaces. */unsigned long int * vlan_bitmap;/* 4096-Bit Bitmap of in-use VLANs. */bool vlans_changed;/* true if new VLANs are in use. */INT min_mtu;/* Current MTU of non-internal ports. */};


2. ofport

/* An openflow port within a "struct ofproto". ** ofproto owns ofport, just like a bridge has a port. Ofport and port also have a ing relationship. They use the port ID through the interface * link. (Of course, netdev should also be equivalent) * with few limits tions, ofproto implementations may look at these fields but * shocould not modify them. */struct ofport {struct hmap_node;/* In struct ofproto's "ports" hmap. */struct ofproto * ofproto;/* The ofproto that contains this port. */struct netdev * netdev; struct ofputil_phy_port pp; uint16_t ofp_port;/* openflow port number. corresponds to ofp_port in iface */unsigned int change_seq; int MTU ;};


3. ofrule

/* An openflow flow within a "struct ofproto ". ** with few exceptions, ofproto implementations may look at these fields but * shocould not modify them. */struct rule {struct list ofproto_node;/* owned by ofproto base code. */struct ofproto * ofproto;/* The ofproto that contains this rule. * /// key structure cls_rule, which contains flow & flow_wildcards // It is used for stream matching. Note that it does not point to rule in reverse direction. You can only use container_of to obtain the rule pointer. Struct cls_rule CR;/* in owning ofproto's classifier. * // indicates whether the current rule is operated, like a lock (?) Struct ofoperation * pending;/* operation now in SS, if nonnull. * // It is written "may be used by the Controller" in the openflow protocol, but no relevant implementation is yet available. Useless. Ovs_be64 flow_cookie;/* controller-issued identifier. * /// various rule parameters long int created;/* creation time. */long int modified;/* time of last modification. */long int used;/* last use; time created if never used. */uint16_t hard_timeout;/* in seconds from-> modified. */uint16_t idle_timeout;/* in seconds from-> used. */uint8_t table_id;/* index in ofproto's 'table' array. */Bool send_flow_removed;/* Send a flow removed message? * // Overflow group: overflow when the traffic exceeds the limit. Optional. /* Eviction groups. */bool evictable;/* if false, prevents eviction. */struct heap_node evg_node;/* In eviction_group's "rules" heap. */struct eviction_group * eviction_group;/* null if not in any group. */Union ofp_action * actions;/* openflow actions. */INT n_actions;/* Number of elements in actions []. */};

4. Bundle

Is a set of vswitch ports. It can be a single port or a bound port.

/* Bundles. *//* Registers a "bundle" associated with client data pointer 'aux' in 'ofproto'. * A bundle is the same concept as a Port in OVSDB, that is, it consists of one * or more "slave" devices (Interfaces, in OVSDB) along with a VLAN * configuration plus, if there is more than one slave, a bonding * configuration. * * If 'aux' is already registered then this function updates its configuration * to 's'.  Otherwise, this function registers a new bundle. * * Bundles only affect the NXAST_AUTOPATH action and output to the OFPP_NORMAL * port. */
struct ofbundle {    struct hmap_node hmap_node; /* In struct ofproto's "bundles" hmap. */    struct ofproto_dpif *ofproto; /* Owning ofproto. */    void *aux;                  /* Key supplied by ofproto's client. */    char *name;                 /* Identifier for log messages. */    /* Configuration. */    struct list ports;          /* Contains "struct ofport"s. */    enum port_vlan_mode vlan_mode; /* VLAN mode */    int vlan;                   /* -1=trunk port, else a 12-bit VLAN ID. */    unsigned long *trunks;      /* Bitmap of trunked VLANs, if 'vlan' == -1.                                 * NULL if all VLANs are trunked. */    struct lacp *lacp;          /* LACP if LACP is enabled, otherwise NULL. */    struct bond *bond;          /* Nonnull iff more than one port. */    bool use_priority_tags;     /* Use 802.1p tag for frames in VLAN 0? */    /* Status. */    bool floodable;          /* True if no port has OFPUTIL_PC_NO_FLOOD set. */    /* Port mirroring info. */    mirror_mask_t src_mirrors;  /* Mirrors triggered when packet received. */    mirror_mask_t dst_mirrors;  /* Mirrors triggered when packet sent. */    mirror_mask_t mirror_out;   /* Mirrors that output to this bundle. */};


5. Mirror

struct mirror {    struct uuid uuid;           /* UUID of this "mirror" record in database. */    struct hmap_node hmap_node; /* In struct bridge's "mirrors" hmap. */    struct bridge *bridge;    char *name;    const struct ovsrec_mirror *cfg;};


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.