Skip to content

Commit

Permalink
Merge "Flow logging improvement"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Apr 3, 2017
2 parents 51b7d5c + cd11745 commit ac6825e
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 62 deletions.
21 changes: 5 additions & 16 deletions src/vnsw/agent/pkt/flow_proto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,26 +187,15 @@ FlowHandler *FlowProto::AllocProtoHandler(PktInfoPtr info,
}

bool FlowProto::Validate(PktInfo *msg) {
if (msg->l3_forwarding && msg->ip == NULL && msg->ip6 == NULL &&
msg->type != PktType::MESSAGE) {
if (msg->family == Address::INET) {
if (msg->ip == NULL && msg->ip6 == NULL && msg->type != PktType::MESSAGE) {
if (msg->family == Address::INET || msg->family == Address::INET6) {
FLOW_TRACE(DetailErr, msg->agent_hdr.cmd_param,
msg->agent_hdr.ifindex,
msg->agent_hdr.vrf,
msg->ip_saddr.to_v4().to_ulong(),
msg->ip_daddr.to_v4().to_ulong(),
msg->ip_saddr.to_string(),
msg->ip_daddr.to_string(),
"Flow : Non-IP packet. Dropping",
msg->l3_forwarding, 0, 0, 0, 0);
} else if (msg->family == Address::INET6) {
uint64_t sip[2], dip[2];
Ip6AddressToU64Array(msg->ip_saddr.to_v6(), sip, 2);
Ip6AddressToU64Array(msg->ip_daddr.to_v6(), dip, 2);
FLOW_TRACE(DetailErr, msg->agent_hdr.cmd_param,
msg->agent_hdr.ifindex,
msg->agent_hdr.vrf, -1, -1,
"Flow : Non-IP packet. Dropping",
msg->l3_forwarding,
sip[0], sip[1], dip[0], dip[1]);
msg->l3_forwarding);
} else {
assert(0);
}
Expand Down
20 changes: 8 additions & 12 deletions src/vnsw/agent/pkt/pkt.sandesh
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,15 @@ response sandesh LinkLocalFlowInfoResp {
* @description: Trace message tap interface
* @severity: DEBUG
*/
trace sandesh TapErr {
traceobject sandesh TapErr {
1: string err;
}

/**
* @description: Trace message pkt0 interface
* @severity: DEBUG
*/
trace sandesh PktErr {
traceobject sandesh PktErr {
1: string err;
}

Expand Down Expand Up @@ -291,25 +291,21 @@ traceobject sandesh FlowTrace {
* @description: Trace message containing detailed error for flow entry
* @severity: DEBUG
*/
trace sandesh FlowDetailErr {
traceobject sandesh FlowDetailErr {
1: u32 flow_index;
2: u16 ifindex;
3: u16 vrf;
4: u32 sip;
5: u32 dip;
4: string sip;
5: string dip;
6: string error;
7: bool l3_flow;
8: u64 sip_upper;
9: u64 sip_lower;
10: u64 dip_upper;
11: u64 dip_lower;
}

/**
* @description: Trace message for flow entry
* @severity: DEBUG
*/
trace sandesh FlowErr {
traceobject sandesh FlowErr {
1: u32 flow_index;
2: string error;
}
Expand All @@ -318,7 +314,7 @@ trace sandesh FlowErr {
* @description: Trace message for flow module
* @severity: DEBUG
*/
trace sandesh FlowModuleInfo {
traceobject sandesh FlowModuleInfo {
1: string info;
}

Expand Down Expand Up @@ -358,7 +354,7 @@ traceobject sandesh PktFlowTrace {
* @description: Trace message for pkt flow error
* @severity: DEBUG
*/
trace sandesh PktFlowErr {
traceobject sandesh PktFlowErr {
1: string error;
}

Expand Down
79 changes: 45 additions & 34 deletions src/vnsw/agent/pkt/pkt_flow_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,10 @@ const Ip4Address PktFlowInfo::kDefaultIpv4;
const Ip6Address PktFlowInfo::kDefaultIpv6;

static void LogError(const PktInfo *pkt, const char *str) {
if (pkt->family == Address::INET) {
if (pkt->family == Address::INET || pkt->family == Address::INET6) {
FLOW_TRACE(DetailErr, pkt->agent_hdr.cmd_param, pkt->agent_hdr.ifindex,
pkt->agent_hdr.vrf, pkt->ip_saddr.to_v4().to_ulong(),
pkt->ip_daddr.to_v4().to_ulong(), str, pkt->l3_forwarding,
0, 0, 0, 0);
} else if (pkt->family == Address::INET6) {
uint64_t sip[2], dip[2];
Ip6AddressToU64Array(pkt->ip_saddr.to_v6(), sip, 2);
Ip6AddressToU64Array(pkt->ip_daddr.to_v6(), dip, 2);
FLOW_TRACE(DetailErr, pkt->agent_hdr.cmd_param, pkt->agent_hdr.ifindex,
pkt->agent_hdr.vrf, -1, -1, str, pkt->l3_forwarding,
sip[0], sip[1], dip[0], dip[1]);
pkt->agent_hdr.vrf, pkt->ip_saddr.to_string(),
pkt->ip_daddr.to_string(), str, pkt->l3_forwarding);
} else {
assert(0);
}
Expand Down Expand Up @@ -1386,58 +1378,77 @@ bool PktFlowInfo::UnknownUnicastFlow(const PktInfo *pkt,
return ret;
}

bool PktFlowInfo::Process(const PktInfo *pkt, PktControlInfo *in,
PktControlInfo *out) {
in->intf_ = agent->interface_table()->FindInterface(pkt->agent_hdr.ifindex);
out->nh_ = in->nh_ = pkt->agent_hdr.nh;

// Basic config validations for the flow
bool PktFlowInfo::ValidateConfig(const PktInfo *pkt, PktControlInfo *in) {
if (agent->tsn_enabled()) {
short_flow = true;
short_flow_reason = FlowEntry::SHORT_FLOW_ON_TSN;
return false;
}

if (in->intf_ == NULL ||
(pkt->l3_forwarding == true &&
in->intf_->type() == Interface::VM_INTERFACE &&
in->intf_->ip_active(pkt->family) == false) ||
(pkt->l3_forwarding == false &&
in->intf_->l2_active() == false)) {
in->intf_ = NULL;
LogError(pkt, "Invalid or Inactive ifindex");
if (in->intf_ == NULL) {
LogError(pkt, "Invalid interface");
short_flow = true;
short_flow_reason = FlowEntry::SHORT_UNAVIALABLE_INTERFACE;
return false;
}

if (in->intf_->type() == Interface::VM_INTERFACE) {
const VmInterface *vm_intf =
static_cast<const VmInterface *>(in->intf_);
if (pkt->l3_forwarding && vm_intf->layer3_forwarding() == false) {
LogError(pkt, "ipv4 service not enabled for ifindex");
const VmInterface *vm_intf = dynamic_cast<const VmInterface *>(in->intf_);
if (pkt->l3_forwarding == true) {
if (vm_intf && in->intf_->ip_active(pkt->family) == false) {
in->intf_ = NULL;
LogError(pkt, "IP protocol inactive on interface");
short_flow = true;
short_flow_reason = FlowEntry::SHORT_UNAVIALABLE_INTERFACE;
return false;
}

if (vm_intf && vm_intf->layer3_forwarding() == false) {
LogError(pkt, "IP service not enabled for interface");
short_flow = true;
short_flow_reason = FlowEntry::SHORT_IPV4_FWD_DIS;
return false;
}
}

if (pkt->l3_forwarding == false) {
if (in->intf_->l2_active() == false) {
in->intf_ = NULL;
LogError(pkt, "L2 inactive on interface");
short_flow = true;
short_flow_reason = FlowEntry::SHORT_UNAVIALABLE_INTERFACE;
return false;
}

if (pkt->l3_forwarding == false &&
vm_intf->bridging() == false) {
LogError(pkt, "Bridge service not enabled for ifindex");
if (vm_intf && vm_intf->bridging() == false) {
LogError(pkt, "Bridge service not enabled for interface");
short_flow = true;
short_flow_reason = FlowEntry::SHORT_IPV4_FWD_DIS;
return false;
}
}

in->vrf_ = agent->vrf_table()->FindVrfFromId(pkt->agent_hdr.vrf);
if (in->vrf_ == NULL || !in->vrf_->IsActive()) {
if (in->vrf_ == NULL || in->vrf_->IsActive() == false) {
in->vrf_ = NULL;
LogError(pkt, "Invalid or Inactive VRF");
short_flow = true;
short_flow_reason = FlowEntry::SHORT_UNAVIALABLE_VRF;
return false;
}

return true;
}

bool PktFlowInfo::Process(const PktInfo *pkt, PktControlInfo *in,
PktControlInfo *out) {
in->intf_ = agent->interface_table()->FindInterface(pkt->agent_hdr.ifindex);
out->nh_ = in->nh_ = pkt->agent_hdr.nh;
in->vrf_ = agent->vrf_table()->FindVrfFromId(pkt->agent_hdr.vrf);

if (ValidateConfig(pkt, in) == false) {
return false;
}

//By default assume destination vrf and source vrf to be same
dest_vrf = pkt->vrf;
// Compute direction of flow based on in-interface
Expand Down
1 change: 1 addition & 0 deletions src/vnsw/agent/pkt/pkt_flow_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class PktFlowInfo {
void Add(const PktInfo *pkt, PktControlInfo *in,
PktControlInfo *out);
bool Process(const PktInfo *pkt, PktControlInfo *in, PktControlInfo *out);
bool ValidateConfig(const PktInfo *pkt, PktControlInfo *in);
static bool GetIngressNwPolicyAclList(const Interface *intf,
const VnEntry *vn,
MatchPolicy *m_policy);
Expand Down

0 comments on commit ac6825e

Please sign in to comment.