static void nh_dump_line(struct rtnl_nexthop *nh, struct nl_dump_params *dp) { struct nl_cache *link_cache; char buf[128]; link_cache = nl_cache_mngt_require("route/link"); nl_dump(dp, "via"); if (nh->ce_mask & NH_ATTR_GATEWAY) nl_dump(dp, " %s", nl_addr2str(nh->rtnh_gateway, buf, sizeof(buf))); if(nh->ce_mask & NH_ATTR_IFINDEX) { if (link_cache) { nl_dump(dp, " dev %s", rtnl_link_i2name(link_cache, nh->rtnh_ifindex, buf, sizeof(buf))); } else nl_dump(dp, " dev %d", nh->rtnh_ifindex); } nl_dump(dp, " "); }
static void bridge_dump_details(struct rtnl_link *link, struct nl_dump_params *p, void *data) { struct bridge_data *bd = data; nl_dump_line(p, " bridge: "); if (bd->ce_mask & BRIDGE_ATTR_PORT_STATE) nl_dump(p, "port-state %u ", bd->b_port_state); if (bd->ce_mask & BRIDGE_ATTR_PRIORITY) nl_dump(p, "prio %u ", bd->b_priority); if (bd->ce_mask & BRIDGE_ATTR_COST) nl_dump(p, "cost %u ", bd->b_cost); if (bd->ce_mask & BRIDGE_ATTR_PORT_VLAN) rtnl_link_bridge_dump_vlans(p, bd); if (bd->ce_mask & BRIDGE_ATTR_FLAGS) { char buf[256]; rtnl_link_bridge_flags2str(bd->b_flags & bd->b_flags_mask, buf, sizeof(buf)); nl_dump(p, "%s", buf); } nl_dump(p, "\n"); }
static void cgroup_dump_line(struct rtnl_cls *cls, struct nl_dump_params *p) { struct rtnl_cgroup *c = rtnl_cls_data(cls); if (c->cg_mask & CGROUP_ATTR_EMATCH) nl_dump(p, " ematch"); else nl_dump(p, " match-all"); }
static void mirred_dump_line(struct rtnl_tc *tc, void *data, struct nl_dump_params *p) { struct rtnl_mirred *u = data; if (!u) return; nl_dump(p, " index %u", u->m_parm.ifindex); if (u->m_parm.eaction == TCA_EGRESS_MIRROR) nl_dump(p, " egress mirror"); else if (u->m_parm.eaction == TCA_EGRESS_REDIR) nl_dump(p, " egress redirect"); switch(u->m_parm.action) { case TC_ACT_UNSPEC: nl_dump(p, " unspecified"); break; case TC_ACT_PIPE: nl_dump(p, " pipe"); break; case TC_ACT_STOLEN: nl_dump(p, " stolen"); break; case TC_ACT_SHOT: nl_dump(p, " shot"); break; case TC_ACT_QUEUED: nl_dump(p, " queued"); break; case TC_ACT_REPEAT: nl_dump(p, " repeat"); break; } }
static void rtnl_link_bridge_dump_vlans(struct nl_dump_params *p, struct bridge_data *bd) { nl_dump(p, "pvid %u", bd->vlan_info.pvid); nl_dump(p, " all vlans:"); dump_bitmap(p, bd->vlan_info.vlan_bitmap); nl_dump(p, " untagged vlans:"); dump_bitmap(p, bd->vlan_info.untagged_bitmap); }
static void dump_icmp(struct nl_dump_params *p, struct nfnl_exp *exp, int tuple) { if (nfnl_exp_test_icmp(exp, tuple)) { nl_dump(p, "icmp type %d ", nfnl_exp_get_icmp_type(exp, tuple)); nl_dump(p, "code %d ", nfnl_exp_get_icmp_code(exp, tuple)); nl_dump(p, "id %d ", nfnl_exp_get_icmp_id(exp, tuple)); } }
static void dump_icmp(struct nl_dump_params *p, struct nfnl_ct *ct, int reply) { if (nfnl_ct_test_icmp_type(ct, reply)) nl_dump(p, "icmp type %d ", nfnl_ct_get_icmp_type(ct, reply)); if (nfnl_ct_test_icmp_code(ct, reply)) nl_dump(p, "code %d ", nfnl_ct_get_icmp_code(ct, reply)); if (nfnl_ct_test_icmp_id(ct, reply)) nl_dump(p, "id %d ", nfnl_ct_get_icmp_id(ct, reply)); }
static void u32_dump_line(struct rtnl_cls *cls, struct nl_dump_params *p) { struct rtnl_u32 *u = rtnl_cls_data(cls); char buf[32]; if (u->cu_mask & U32_ATTR_DIVISOR) nl_dump(p, " divisor %u", u->cu_divisor); else if (u->cu_mask & U32_ATTR_CLASSID) nl_dump(p, " target %s", rtnl_tc_handle2str(u->cu_classid, buf, sizeof(buf))); }
static void print_selector(struct nl_dump_params *p, struct tc_u32_sel *sel, struct rtnl_u32 *u) { int i; struct tc_u32_key *key; if (sel->hmask || sel->hoff) { /* I guess this will never be used since the kernel only * exports the selector if no divisor is set but hash offset * and hash mask make only sense in hash filters with divisor * set */ nl_dump(p, " hash at %u & 0x%x", sel->hoff, sel->hmask); } if (sel->flags & (TC_U32_OFFSET | TC_U32_VAROFFSET)) { nl_dump(p, " offset at %u", sel->off); if (sel->flags & TC_U32_VAROFFSET) nl_dump(p, " variable (at %u & 0x%x) >> %u", sel->offoff, ntohs(sel->offmask), sel->offshift); } if (sel->flags) { int flags = sel->flags; nl_dump(p, " <"); #define PRINT_FLAG(f) if (flags & TC_U32_##f) { \ flags &= ~TC_U32_##f; nl_dump(p, #f "%s", flags ? "," : ""); } PRINT_FLAG(TERMINAL); PRINT_FLAG(OFFSET); PRINT_FLAG(VAROFFSET); PRINT_FLAG(EAT); #undef PRINT_FLAG nl_dump(p, ">"); } for (i = 0; i < sel->nkeys; i++) { key = &sel->keys[i]; nl_dump(p, "\n"); nl_dump_line(p, " match key at %s%u ", key->offmask ? "nexthdr+" : "", key->off); if (key->offmask) nl_dump(p, "[0x%u] ", key->offmask); nl_dump(p, "& 0x%08x == 0x%08x", ntohl(key->mask), ntohl(key->val)); if (p->dp_type == NL_DUMP_STATS && (u->cu_mask & U32_ATTR_PCNT)) { struct tc_u32_pcnt *pcnt = u->cu_pcnt->d_data; nl_dump(p, " successful %" PRIu64, pcnt->kcnts[i]); } } }
static void dump_addr(struct nl_dump_params *p, struct nl_addr *addr, int port) { char buf[64]; if (addr) nl_dump(p, "%s", nl_addr2str(addr, buf, sizeof(buf))); if (port) nl_dump(p, ":%u ", port); else if (addr) nl_dump(p, " "); }
static void netem_dump_line(struct rtnl_tc *tc, void *data, struct nl_dump_params *p) { struct rtnl_netem *netem = data; if (netem) { if (netem->qnm_mask & SCH_NETEM_ATTR_LIMIT && netem->qnm_limit > 0) nl_dump(p, " limit %dpkts", netem->qnm_limit); else nl_dump(p, " no limit"); } }
static void dump_bitmap(struct nl_dump_params *p, const uint32_t *b) { int i = -1, j, k; int start = -1, prev = -1; int done, found = 0; for (k = 0; k < RTNL_LINK_BRIDGE_VLAN_BITMAP_LEN; k++) { int base_bit; uint32_t a = b[k]; base_bit = k * 32; i = -1; done = 0; while (!done) { j = find_next_bit(i, a); if (j > 0) { /* first hit of any bit */ if (start < 0 && prev < 0) { start = prev = j - 1 + base_bit; goto next; } /* this bit is a continuation of prior bits */ if (j - 2 + base_bit == prev) { prev++; goto next; } } else done = 1; if (start >= 0) { found++; if (done && k < RTNL_LINK_BRIDGE_VLAN_BITMAP_LEN - 1) break; nl_dump(p, " %d", start); if (start != prev) nl_dump(p, "-%d", prev); if (done) break; } if (j > 0) start = prev = j - 1 + base_bit; next: i = j; } } if (!found) nl_dump(p, " <none>"); return; }
static void meta_dump(struct rtnl_ematch *e, struct nl_dump_params *p) { struct meta_data *m = rtnl_ematch_data(e); char buf[32]; nl_dump(p, "meta("); dump_value(m->left, p); nl_dump(p, " %s ", rtnl_ematch_opnd2txt(m->opnd, buf, sizeof(buf))); dump_value(m->right, p); nl_dump(p, ")"); }
static void cgroup_dump_line(struct rtnl_tc *tc, void *data, struct nl_dump_params *p) { struct rtnl_cgroup *c = data; if (!c) return; if (c->cg_mask & CGROUP_ATTR_EMATCH) nl_dump(p, " ematch"); else nl_dump(p, " match-all"); }
static void idiag_msg_dump_line(struct nl_object *a, struct nl_dump_params *p) { struct idiagnl_msg *msg = (struct idiagnl_msg *) a; char buf[64] = { 0 }; nl_dump_line(p, "family: %s ", nl_af2str(msg->idiag_family, buf, sizeof(buf))); nl_dump(p, "src: %s:%d ", nl_addr2str(msg->idiag_src, buf, sizeof(buf)), ntohs(msg->idiag_sport)); nl_dump(p, "dst: %s:%d ", nl_addr2str(msg->idiag_dst, buf, sizeof(buf)), ntohs(msg->idiag_dport)); nl_dump(p, "iif: %d ", msg->idiag_ifindex); nl_dump(p, "\n"); }
void tca_dump_details(struct rtnl_tc *tc, struct nl_dump_params *p) { nl_dump_line(p, " "); if (tc->ce_mask & TCA_ATTR_MTU) nl_dump(p, " mtu %u", tc->tc_mtu); if (tc->ce_mask & TCA_ATTR_MPU) nl_dump(p, " mput %u", tc->tc_mpu); if (tc->ce_mask & TCA_ATTR_OVERHEAD) nl_dump(p, " overhead %u", tc->tc_overhead); }
static void nbyte_dump(struct rtnl_ematch *e, struct nl_dump_params *p) { struct nbyte_data *n = rtnl_ematch_data(e); int i; nl_dump(p, "pattern(%u:[", n->cfg.len); for (i = 0; i < n->cfg.len; i++) { nl_dump(p, "%02x", n->pattern[i]); if (i+1 < n->cfg.len) nl_dump(p, " "); } nl_dump(p, "] at %s+%u)", layer_txt(&n->cfg), n->cfg.off); }
static void cls_dump_line(struct nl_object *obj, struct nl_dump_params *p) { char buf[32]; struct rtnl_cls *cls = (struct rtnl_cls *) obj; struct rtnl_cls_ops *cops; tca_dump_line((struct rtnl_tca *) cls, "cls", p); nl_dump(p, " prio %u protocol %s", cls->c_prio, nl_ether_proto2str(cls->c_protocol, buf, sizeof(buf))); cops = rtnl_cls_lookup_ops(cls); if (cops && cops->co_dump[NL_DUMP_LINE]) cops->co_dump[NL_DUMP_LINE](cls, p); nl_dump(p, "\n"); }
static void fw_dump_details(struct rtnl_cls *cls, struct nl_dump_params *p) { struct rtnl_fw *f = rtnl_cls_data(cls); if (f->cf_mask & FW_ATTR_INDEV) nl_dump(p, "indev %s ", f->cf_indev); }
static void netem_dump_line(struct rtnl_qdisc *qdisc, struct nl_dump_params *p) { struct rtnl_netem *netem = netem_qdisc(qdisc); if (netem) nl_dump(p, "limit %d", netem->qnm_limit); }
static void pfifo_dump_line(struct rtnl_qdisc *qdisc, struct nl_dump_params *p) { struct rtnl_fifo *fifo = fifo_qdisc(qdisc); if (fifo) nl_dump(p, " limit %u packets", fifo->qf_limit); }
static void netem_dump_line(struct rtnl_tc *tc, void *data, struct nl_dump_params *p) { struct rtnl_netem *netem = data; if (netem) nl_dump(p, "limit %d", netem->qnm_limit); }
static void htb_qdisc_dump_line(struct rtnl_tc *tc, void *data, struct nl_dump_params *p) { struct rtnl_htb_qdisc *htb = data; if (!htb) return; if (htb->qh_mask & SCH_HTB_HAS_RATE2QUANTUM) nl_dump(p, " r2q %u", htb->qh_rate2quantum); if (htb->qh_mask & SCH_HTB_HAS_DEFCLS) { char buf[64]; nl_dump(p, " default-class %s", rtnl_tc_handle2str(htb->qh_defcls, buf, sizeof(buf))); } }
static void cls_dump_line(struct rtnl_tc *tc, struct nl_dump_params *p) { struct rtnl_cls *cls = (struct rtnl_cls *) tc; char buf[32]; nl_dump(p, " prio %u protocol %s", cls->c_prio, nl_ether_proto2str(cls->c_protocol, buf, sizeof(buf))); }
static void dump_ematch_sequence(struct nl_list_head *head, struct nl_dump_params *p) { struct rtnl_ematch *match; nl_list_for_each_entry(match, head, e_list) { if (match->e_flags & TCF_EM_INVERT) nl_dump(p, "!"); if (match->e_kind == TCF_EM_CONTAINER) { nl_dump(p, "("); dump_ematch_sequence(&match->e_childs, p); nl_dump(p, ")"); } else if (!match->e_ops) { nl_dump(p, "[unknown ematch %d]", match->e_kind); } else { if (match->e_ops->eo_dump) match->e_ops->eo_dump(match, p); else nl_dump(p, "[data]"); } switch (match->e_flags & TCF_EM_REL_MASK) { case TCF_EM_REL_AND: nl_dump(p, " AND "); break; case TCF_EM_REL_OR: nl_dump(p, " OR "); break; default: /* end of first level ematch sequence */ return; } } }
static void nfnl_log_dump(struct nl_object *a, struct nl_dump_params *p) { struct nfnl_log *log = (struct nfnl_log *) a; char buf[64]; nl_new_line(p); if (log->ce_mask & LOG_ATTR_GROUP) nl_dump(p, "group=%u ", log->log_group); if (log->ce_mask & LOG_ATTR_COPY_MODE) nl_dump(p, "copy_mode=%s ", nfnl_log_copy_mode2str(log->log_copy_mode, buf, sizeof(buf))); if (log->ce_mask & LOG_ATTR_COPY_RANGE) nl_dump(p, "copy_range=%u ", log->log_copy_range); if (log->ce_mask & LOG_ATTR_FLUSH_TIMEOUT) nl_dump(p, "flush_timeout=%u ", log->log_flush_timeout); if (log->ce_mask & LOG_ATTR_ALLOC_SIZE) nl_dump(p, "alloc_size=%u ", log->log_alloc_size); if (log->ce_mask & LOG_ATTR_QUEUE_THRESHOLD) nl_dump(p, "queue_threshold=%u ", log->log_queue_threshold); nl_dump(p, "\n"); }
static void cell_dump(struct nl_object *obj, struct nl_dump_params *p) { struct nl_dect_cell *cell = nl_object_priv(obj); struct nl_cache *cluster_cache; unsigned int i; char buf[64]; if (cell->ce_mask & CELL_ATTR_NAME) nl_dump(p, "%u: DECT Cell %s", cell->c_index, cell->c_name); if (cell->ce_mask & CELL_ATTR_LINK) { cluster_cache = nl_cache_mngt_require("nl_dect/cluster"); if (cluster_cache != NULL) { nl_dect_cluster_i2name(cluster_cache, cell->c_link, buf, sizeof(buf)); nl_dump(p, "@%s", buf); } else nl_dump(p, "@%u", cell->c_link); } nl_dump(p, ":"); if (cell->ce_mask & CELL_ATTR_FLAGS) { nl_dect_cell_flags2str(cell->c_flags, buf, sizeof(buf)); nl_dump(p, " <%s>", buf); } nl_dump(p, "\n"); if (cell->ce_mask & CELL_ATTR_TRANSCEIVER) { for (i = 0; i < 16 && cell->c_transceiver[i] != NULL; i++) nl_dump(p, "\tTransceiver: %s\n", cell->c_transceiver[i]); } }
static void nh_dump_details(struct rtnl_nexthop *nh, struct nl_dump_params *dp) { struct nl_cache *link_cache; char buf[128]; link_cache = nl_cache_mngt_require("route/link"); nl_dump(dp, "nexthop"); if (nh->ce_mask & NH_ATTR_GATEWAY) nl_dump(dp, " via %s", nl_addr2str(nh->rtnh_gateway, buf, sizeof(buf))); if(nh->ce_mask & NH_ATTR_IFINDEX) { if (link_cache) { nl_dump(dp, " dev %s", rtnl_link_i2name(link_cache, nh->rtnh_ifindex, buf, sizeof(buf))); } else nl_dump(dp, " dev %d", nh->rtnh_ifindex); } if (nh->ce_mask & NH_ATTR_WEIGHT) nl_dump(dp, " weight %u", nh->rtnh_weight); if (nh->ce_mask & NH_ATTR_REALMS) nl_dump(dp, " realm %04x:%04x", RTNL_REALM_FROM(nh->rtnh_realms), RTNL_REALM_TO(nh->rtnh_realms)); if (nh->ce_mask & NH_ATTR_FLAGS) nl_dump(dp, " <%s>", rtnl_route_nh_flags2str(nh->rtnh_flags, buf, sizeof(buf))); }
void rtnl_ematch_tree_dump(struct rtnl_ematch_tree *tree, struct nl_dump_params *p) { if (!tree) BUG(); dump_ematch_sequence(&tree->et_list, p); nl_dump(p, "\n"); }
static void cmp_dump(struct rtnl_ematch *e, struct nl_dump_params *p) { struct tcf_em_cmp *cmp = rtnl_ematch_data(e); if (cmp->flags & TCF_EM_CMP_TRANS) nl_dump(p, "ntoh%c(", (cmp->align == TCF_EM_ALIGN_U32) ? 'l' : 's'); nl_dump(p, "%s at %s+%u", align_txt[cmp->align], layer_txt[cmp->layer], cmp->off); if (cmp->mask) nl_dump(p, " & 0x%x", cmp->mask); if (cmp->flags & TCF_EM_CMP_TRANS) nl_dump(p, ")"); nl_dump(p, " %s %u", operand_txt[cmp->opnd], cmp->val); }