Skip to content

Commit

Permalink
Print explanations for the various symbols used in flow utility and in
Browse files Browse the repository at this point in the history
route utility

Closes BUG: #1415549

Change-Id: Iae6deb701949febcc8df1a626a65f6c73eae0710
  • Loading branch information
anandhk-juniper committed Jan 29, 2015
1 parent 0c159c4 commit 73dbb50
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 11 deletions.
6 changes: 6 additions & 0 deletions include/vr_utils.h
Expand Up @@ -19,6 +19,12 @@ struct vn_if {
unsigned int if_flags;
};

struct vr_util_flags {
unsigned int vuf_flag;
unsigned char *vuf_flag_symbol;
unsigned char *vuf_flag_string;
};

#ifdef __cplusplus
}
#endif
Expand Down
14 changes: 14 additions & 0 deletions utils/flow.c
Expand Up @@ -119,6 +119,19 @@ flow_get_drop_reason(uint8_t drop_code)
return NULL;
}

static void
dump_legend(void)
{
printf("Action:F=Forward, D=Drop ");
printf("N=NAT(S=SNAT, D=DNAT, Ps=SPAT, Pd=DPAT, ");
printf("L=Link Local Port)\n");

printf(" Other:K(nh)=Key_Nexthop, S(nh)=RPF_Nexthop\n");
printf("\n");

return;
}

static void
dump_table(struct flow_table *ft)
{
Expand All @@ -130,6 +143,7 @@ dump_table(struct flow_table *ft)
struct in_addr in_src, in_dest;

printf("Flow table\n\n");
dump_legend();
printf(" Index Source:Port Destination:Port \tProto(V)\n");
printf("-----------------------------------------------------------------");
printf("--------\n");
Expand Down
51 changes: 49 additions & 2 deletions utils/rt.c
Expand Up @@ -68,6 +68,51 @@ static void usage_internal(void);
#define BRIDGE_FAMILY_STRING "bridge"
#define INET6_FAMILY_STRING "inet6"

struct vr_util_flags inet_flags[] = {
{VR_RT_LABEL_VALID_FLAG, "L", "Label Valid" },
{VR_RT_ARP_PROXY_FLAG, "P", "Proxy ARP" },
{VR_RT_ARP_TRAP_FLAG, "T", "Trap ARP" },
{VR_RT_ARP_FLOOD_FLAG, "F", "Flood ARP" },
};

struct vr_util_flags bridge_flags[] = {
{VR_RT_LABEL_VALID_FLAG, "L", "Label Valid" },
};

static void
dump_legend(int family)
{
unsigned int i, array_size;
struct vr_util_flags *rt_flags;

switch (family) {
case AF_INET:
case AF_INET6:
array_size = sizeof(inet_flags) / sizeof(inet_flags[0]);
rt_flags = inet_flags;
break;

case AF_BRIDGE:
array_size = sizeof(bridge_flags) / sizeof(bridge_flags[0]);
rt_flags = bridge_flags;
break;

default:
return;
}

printf("Flags: ");
for (i = 0; i < array_size; i++) {
printf("%s=%s", rt_flags[i].vuf_flag_symbol,
rt_flags[i].vuf_flag_string);
if (i != (array_size - 1))
printf(", ");
}

printf("\n\n");
return;
}

static int
family_string_to_id(char *fname)
{
Expand Down Expand Up @@ -377,10 +422,12 @@ vr_route_op(void)

if (cmd_op == SANDESH_OP_DUMP) {
if ((cmd_family_id == AF_INET) || (cmd_family_id == AF_INET6)) {
printf("Kernel IP routing table %d/%d/unicast\n", req->rtr_rid, cmd_vrf_id);
printf("Kernel IP routing table %d/%d/unicast\n\n", req->rtr_rid, cmd_vrf_id);
dump_legend(cmd_family_id);
printf("Destination PPL Flags Label Nexthop Stitched MAC\n");
} else {
printf("Kernel L2 Bridge table %d/%d\n", req->rtr_rid, cmd_vrf_id);
printf("Kernel L2 Bridge table %d/%d\n\n", req->rtr_rid, cmd_vrf_id);
dump_legend(cmd_family_id);
printf("DestMac Vrf Label/VNID Nexthop\n");
}
}
Expand Down
14 changes: 5 additions & 9 deletions utils/vif.c
Expand Up @@ -71,11 +71,7 @@ static struct ether_addr *mac_opt;

static void Usage(void);

static struct vr_intf_flags {
unsigned int vif_flag;
unsigned char *vif_flag_symbol;
unsigned char *vif_flag_string;
} flag_metadata[] = {
static struct vr_util_flags flag_metadata[] = {
{VIF_FLAG_POLICY_ENABLED, "P", "Policy" },
{VIF_FLAG_XCONNECT, "X", "Cross Connect" },
{VIF_FLAG_SERVICE_IF, "S", "Service Chain" },
Expand Down Expand Up @@ -160,8 +156,8 @@ vr_if_flags(int flags)

array_size = sizeof(flag_metadata) / sizeof(flag_metadata[0]);
for (i = 0; i < array_size; i++) {
if (flags & flag_metadata[i].vif_flag)
strcat(flag_string, flag_metadata[i].vif_flag_symbol);
if (flags & flag_metadata[i].vuf_flag)
strcat(flag_string, flag_metadata[i].vuf_flag_symbol);
}

return flag_string;
Expand All @@ -184,8 +180,8 @@ vr_interface_print_header(void)
else
printf(", ");
}
printf("%s=%s", flag_metadata[i].vif_flag_symbol,
flag_metadata[i].vif_flag_string);
printf("%s=%s", flag_metadata[i].vuf_flag_symbol,
flag_metadata[i].vuf_flag_string);
}

printf("\n\n");
Expand Down

0 comments on commit 73dbb50

Please sign in to comment.