Skip to content

Commit

Permalink
In case of Static Mirroring, need to set Destination network with Mir…
Browse files Browse the repository at this point in the history
…roring flag

so that insted of  choosing VRF NH for VXLAN, will choose composite Interface NH.
For creating compositeNH, registerd for Vminterface creation notification upon
receving the notification will attach each interface NH to the composite list
and inturn will program the vrouter.

partial-bug: #1592049

In the case of Static Mirroring Case, need to set Destination network
with  Mirroring flag so that insted of  choosing VRF NH for VXLAN
will choose composite Interface NH.
partial-bug: #1592049

(submitting on behalf of Jayaram Satya)

Change-Id: Idc2672666561484ae4bcd96696daa3baccc30560
  • Loading branch information
haripk committed Jul 26, 2016
1 parent 7165c0d commit 306d40e
Show file tree
Hide file tree
Showing 7 changed files with 216 additions and 38 deletions.
3 changes: 3 additions & 0 deletions src/schema/vnc_cfg.xsd
Expand Up @@ -1161,6 +1161,9 @@ targetNamespace="http://www.contrailsystems.com/2012/VNC-CONFIG/0">
<!-- Enable or disable unicast RPF for virtual-network -->
<xsd:element name='rpf' type='RpfModeType' required='optional'
description='Flag used to diable Reverse Path Forwarding(RPF) check for this network'/>
<!-- Enable or disable Mirroring for virtual-network -->
<xsd:element name='mirror-destination' type="xsd:boolean" default="false" required='optional'
description='Flag to mark the virtual network as mirror destination network'/>
</xsd:all>
</xsd:complexType>

Expand Down
5 changes: 5 additions & 0 deletions src/vnsw/agent/oper/operdb_init.cc
Expand Up @@ -179,6 +179,7 @@ void OperDB::CreateDBTables(DB *db) {
assert(vxlan_table);
agent_->set_vxlan_table(vxlan_table);
vxlan_table->set_agent(agent_);
vxlan_table->Initialize();

QosQueueTable *qos_queue_table;
qos_queue_table =
Expand Down Expand Up @@ -325,6 +326,10 @@ void OperDB::Shutdown() {
agent()->mirror_table()->Shutdown();
}

if (agent()->vxlan_table()) {
agent()->vxlan_table()->Shutdown();
}

profile_.reset();
}

Expand Down
28 changes: 20 additions & 8 deletions src/vnsw/agent/oper/vn.cc
Expand Up @@ -96,7 +96,8 @@ VnEntry::VnEntry(Agent *agent, uuid id) :
admin_state_(true), table_label_(0), enable_rpf_(true),
flood_unknown_unicast_(false), old_vxlan_id_(0),
forwarding_mode_(Agent::L2_L3),
route_resync_walker_(new AgentRouteResync(agent)) {
route_resync_walker_(new AgentRouteResync(agent)), mirror_destination_(false)
{
route_resync_walker_.get()->
set_walkable_route_tables((1 << Agent::INET4_UNICAST) |
(1 << Agent::INET6_UNICAST));
Expand Down Expand Up @@ -343,7 +344,8 @@ bool VnTable::RebakeVxlan(VnEntry *vn, bool op_del) {
if (vxlan) {
vn->old_vxlan_id_ = vxlan;
vn->vxlan_id_ref_ = table->Locate(vxlan, vn->uuid_, vn->vrf_->GetName(),
vn->flood_unknown_unicast_);
vn->flood_unknown_unicast_,
vn->mirror_destination_);
}

return (old_vxlan != vn->vxlan_id_ref_.get());
Expand Down Expand Up @@ -578,6 +580,12 @@ bool VnTable::ChangeHandler(DBEntry *entry, const DBRequest *req) {
ret = true;
}

if (vn->mirror_destination_ != data->mirror_destination_) {
vn->mirror_destination_ = data->mirror_destination_;
rebake_vxlan = true;
ret = true;
}

if (rebake_vxlan) {
ret |= RebakeVxlan(vn, false);
}
Expand Down Expand Up @@ -684,7 +692,8 @@ int VnTable::ComputeCfgVxlanId(IFMapNode *node) {

void VnTable::CfgForwardingFlags(IFMapNode *node, bool *l2, bool *l3,
bool *rpf, bool *flood_unknown_unicast,
Agent::ForwardingMode *forwarding_mode) {
Agent::ForwardingMode *forwarding_mode,
bool *mirror_destination) {
*rpf = true;

VirtualNetwork *cfg = static_cast <VirtualNetwork *> (node->GetObject());
Expand All @@ -695,7 +704,7 @@ void VnTable::CfgForwardingFlags(IFMapNode *node, bool *l2, bool *l3,
}

*flood_unknown_unicast = cfg->flood_unknown_unicast();

*mirror_destination = properties.mirror_destination;
//dervived forwarding mode is resultant of configured VN forwarding and global
//configure forwarding mode. It is then used to setup the VN forwarding
//mode.
Expand Down Expand Up @@ -832,16 +841,18 @@ VnData *VnTable::BuildData(IFMapNode *node) {
bool layer3_forwarding;
bool enable_rpf;
bool flood_unknown_unicast;
bool mirror_destination;
Agent::ForwardingMode forwarding_mode;
CfgForwardingFlags(node, &bridging, &layer3_forwarding, &enable_rpf,
&flood_unknown_unicast, &forwarding_mode);
&flood_unknown_unicast, &forwarding_mode,
&mirror_destination);
return new VnData(agent(), node, node->name(), acl_uuid, vrf_name,
mirror_acl_uuid, mirror_cfg_acl_uuid, vn_ipam,
vn_ipam_data, cfg->properties().vxlan_network_identifier,
GetCfgVnId(cfg), bridging, layer3_forwarding,
cfg->id_perms().enable, enable_rpf,
flood_unknown_unicast, forwarding_mode,
qos_config_uuid);
qos_config_uuid, mirror_destination);
}

bool VnTable::IFNodeToUuid(IFMapNode *node, boost::uuids::uuid &u) {
Expand Down Expand Up @@ -888,13 +899,15 @@ void VnTable::AddVn(const uuid &vn_uuid, const string &name,
const VnData::VnIpamDataMap &vn_ipam_data, int vn_id,
int vxlan_id, bool admin_state, bool enable_rpf,
bool flood_unknown_unicast) {
bool mirror_destination = false;
DBRequest req;
VnKey *key = new VnKey(vn_uuid);
VnData *data = new VnData(agent(), NULL, name, acl_id, vrf_name, nil_uuid(),
nil_uuid(), ipam, vn_ipam_data,
vn_id, vxlan_id, true, true,
admin_state, enable_rpf,
flood_unknown_unicast, Agent::NONE, nil_uuid());
flood_unknown_unicast, Agent::NONE, nil_uuid(),
mirror_destination);

req.oper = DBRequest::DB_ENTRY_ADD_CHANGE;
req.key.reset(key);
Expand Down Expand Up @@ -1182,7 +1195,6 @@ bool VnEntry::DBEntrySandesh(Sandesh *sresp, std::string &name) const {
data.set_admin_state(admin_state());
data.set_enable_rpf(enable_rpf());
data.set_flood_unknown_unicast(flood_unknown_unicast());

std::vector<VnSandeshData> &list =
const_cast<std::vector<VnSandeshData>&>(resp->get_vn_list());
list.push_back(data);
Expand Down
14 changes: 11 additions & 3 deletions src/vnsw/agent/oper/vn.h
Expand Up @@ -94,15 +94,16 @@ struct VnData : public AgentOperDBData {
int vxlan_id, int vnid, bool bridging,
bool layer3_forwarding, bool admin_state, bool enable_rpf,
bool flood_unknown_unicast, Agent::ForwardingMode forwarding_mode,
const boost::uuids::uuid &qos_config_uuid) :
const boost::uuids::uuid &qos_config_uuid, bool mirror_destination) :
AgentOperDBData(agent, node), name_(name), vrf_name_(vrf_name),
acl_id_(acl_id), mirror_acl_id_(mirror_acl_id),
mirror_cfg_acl_id_(mc_acl_id), ipam_(ipam), vn_ipam_data_(vn_ipam_data),
vxlan_id_(vxlan_id), vnid_(vnid), bridging_(bridging),
layer3_forwarding_(layer3_forwarding), admin_state_(admin_state),
enable_rpf_(enable_rpf),
flood_unknown_unicast_(flood_unknown_unicast),
forwarding_mode_(forwarding_mode), qos_config_uuid_(qos_config_uuid) {
forwarding_mode_(forwarding_mode), qos_config_uuid_(qos_config_uuid),
mirror_destination_(mirror_destination){
};
virtual ~VnData() { }

Expand All @@ -122,6 +123,7 @@ struct VnData : public AgentOperDBData {
bool flood_unknown_unicast_;
Agent::ForwardingMode forwarding_mode_;
boost::uuids::uuid qos_config_uuid_;
bool mirror_destination_;
};

class VnEntry : AgentRefCount<VnEntry>, public AgentOperDBEntry {
Expand Down Expand Up @@ -192,6 +194,10 @@ class VnEntry : AgentRefCount<VnEntry>, public AgentOperDBEntry {
return qos_config_.get();
}

const bool mirror_destination() const {
return mirror_destination_;
}

private:
friend class VnTable;

Expand All @@ -217,6 +223,7 @@ class VnEntry : AgentRefCount<VnEntry>, public AgentOperDBEntry {
Agent::ForwardingMode forwarding_mode_;
boost::scoped_ptr<AgentRouteResync> route_resync_walker_;
AgentQosConfigConstRef qos_config_;
bool mirror_destination_;
DISALLOW_COPY_AND_ASSIGN(VnEntry);
};

Expand Down Expand Up @@ -246,7 +253,8 @@ class VnTable : public AgentOperDBTable {
int ComputeCfgVxlanId(IFMapNode *node);
void CfgForwardingFlags(IFMapNode *node, bool *l2, bool *l3, bool *rpf,
bool *flood_unknown_unicast,
Agent::ForwardingMode *forwarding_mode);
Agent::ForwardingMode *forwarding_mode,
bool *mirror_destination);


static DBTableBase *CreateTable(DB *db, const std::string &name);
Expand Down

0 comments on commit 306d40e

Please sign in to comment.