• Home
  • Raw
  • Download

Lines Matching refs:rule

47 	struct rtnl_rule *rule = nl_object_priv(c);  in rule_free_data()  local
49 if (!rule) in rule_free_data()
52 nl_addr_put(rule->r_src); in rule_free_data()
53 nl_addr_put(rule->r_dst); in rule_free_data()
83 struct rtnl_rule *rule; in rule_msg_parser() local
88 rule = rtnl_rule_alloc(); in rule_msg_parser()
89 if (!rule) { in rule_msg_parser()
94 rule->ce_msgtype = n->nlmsg_type; in rule_msg_parser()
101 rule->r_family = family = r->rtm_family; in rule_msg_parser()
102 rule->r_type = r->rtm_type; in rule_msg_parser()
103 rule->r_dsfield = r->rtm_tos; in rule_msg_parser()
104 rule->r_src_len = r->rtm_src_len; in rule_msg_parser()
105 rule->r_dst_len = r->rtm_dst_len; in rule_msg_parser()
106 rule->r_table = r->rtm_table; in rule_msg_parser()
107 rule->ce_mask = (RULE_ATTR_FAMILY | RULE_ATTR_TYPE | RULE_ATTR_DSFIELD | in rule_msg_parser()
112 rule->r_prio = nla_get_u32(tb[RTA_PRIORITY]); in rule_msg_parser()
113 rule->ce_mask |= RULE_ATTR_PRIO; in rule_msg_parser()
117 if (!(rule->r_src = nl_addr_alloc_attr(tb[RTA_SRC], family))) in rule_msg_parser()
119 nl_addr_set_prefixlen(rule->r_src, r->rtm_src_len); in rule_msg_parser()
120 rule->ce_mask |= RULE_ATTR_SRC; in rule_msg_parser()
124 if (!(rule->r_dst = nl_addr_alloc_attr(tb[RTA_DST], family))) in rule_msg_parser()
126 nl_addr_set_prefixlen(rule->r_dst, r->rtm_dst_len); in rule_msg_parser()
127 rule->ce_mask |= RULE_ATTR_DST; in rule_msg_parser()
131 rule->r_mark = nla_get_u32(tb[RTA_PROTOINFO]); in rule_msg_parser()
132 rule->ce_mask |= RULE_ATTR_MARK; in rule_msg_parser()
136 nla_strlcpy(rule->r_iif, tb[RTA_IIF], IFNAMSIZ); in rule_msg_parser()
137 rule->ce_mask |= RULE_ATTR_IIF; in rule_msg_parser()
141 rule->r_realms = nla_get_u32(tb[RTA_FLOW]); in rule_msg_parser()
142 rule->ce_mask |= RULE_ATTR_REALMS; in rule_msg_parser()
146 rule->r_srcmap = nl_addr_alloc_attr(tb[RTA_GATEWAY], family); in rule_msg_parser()
147 if (!rule->r_srcmap) in rule_msg_parser()
149 rule->ce_mask |= RULE_ATTR_SRCMAP; in rule_msg_parser()
153 rule->r_table = nla_get_u32(tb[RTA_TABLE]); in rule_msg_parser()
154 rule->ce_mask |= RULE_ATTR_TABLE; in rule_msg_parser()
157 err = pp->pp_cb((struct nl_object *) rule, pp); in rule_msg_parser()
159 rtnl_rule_put(rule); in rule_msg_parser()
215 struct rtnl_rule *rule = (struct rtnl_rule *) obj; in rule_dump_details() local
220 if (rule->ce_mask & RULE_ATTR_SRCMAP) in rule_dump_details()
222 nl_addr2str(rule->r_srcmap, buf, sizeof(buf))); in rule_dump_details()
232 struct rtnl_rule *rule = (struct rtnl_rule *) obj; in rule_dump_env() local
235 nl_dump_line(p, "RULE_PRIORITY=%u\n", rule->r_prio); in rule_dump_env()
237 nl_af2str(rule->r_family, buf, sizeof(buf))); in rule_dump_env()
239 if (rule->ce_mask & RULE_ATTR_DST) in rule_dump_env()
241 nl_addr2str(rule->r_dst, buf, sizeof(buf))); in rule_dump_env()
243 if (rule->ce_mask & RULE_ATTR_DST_LEN) in rule_dump_env()
244 nl_dump_line(p, "RULE_DSTLEN=%u\n", rule->r_dst_len); in rule_dump_env()
246 if (rule->ce_mask & RULE_ATTR_SRC) in rule_dump_env()
248 nl_addr2str(rule->r_src, buf, sizeof(buf))); in rule_dump_env()
250 if (rule->ce_mask & RULE_ATTR_SRC_LEN) in rule_dump_env()
251 nl_dump_line(p, "RULE_SRCLEN=%u\n", rule->r_src_len); in rule_dump_env()
253 if (rule->ce_mask & RULE_ATTR_IIF) in rule_dump_env()
254 nl_dump_line(p, "RULE_IIF=%s\n", rule->r_iif); in rule_dump_env()
256 if (rule->ce_mask & RULE_ATTR_TABLE) in rule_dump_env()
257 nl_dump_line(p, "RULE_TABLE=%u\n", rule->r_table); in rule_dump_env()
259 if (rule->ce_mask & RULE_ATTR_REALMS) in rule_dump_env()
260 nl_dump_line(p, "RULE_REALM=%u\n", rule->r_realms); in rule_dump_env()
262 if (rule->ce_mask & RULE_ATTR_MARK) in rule_dump_env()
263 nl_dump_line(p, "RULE_MARK=0x%" PRIx64 "\n", rule->r_mark); in rule_dump_env()
265 if (rule->ce_mask & RULE_ATTR_DSFIELD) in rule_dump_env()
266 nl_dump_line(p, "RULE_DSFIELD=%u\n", rule->r_dsfield); in rule_dump_env()
268 if (rule->ce_mask & RULE_ATTR_TYPE) in rule_dump_env()
270 nl_rtntype2str(rule->r_type, buf, sizeof(buf))); in rule_dump_env()
272 if (rule->ce_mask & RULE_ATTR_SRCMAP) in rule_dump_env()
274 nl_addr2str(rule->r_srcmap, buf, sizeof(buf))); in rule_dump_env()
336 void rtnl_rule_put(struct rtnl_rule *rule) in rtnl_rule_put() argument
338 nl_object_put((struct nl_object *) rule); in rtnl_rule_put()
516 int rtnl_rule_build_delete_request(struct rtnl_rule *rule, int flags, in rtnl_rule_build_delete_request() argument
519 return build_rule_msg(rule, RTM_DELRULE, flags, result); in rtnl_rule_build_delete_request()
534 int rtnl_rule_delete(struct nl_sock *sk, struct rtnl_rule *rule, int flags) in rtnl_rule_delete() argument
539 if ((err = rtnl_rule_build_delete_request(rule, flags, &msg)) < 0) in rtnl_rule_delete()
557 void rtnl_rule_set_family(struct rtnl_rule *rule, int family) in rtnl_rule_set_family() argument
559 rule->r_family = family; in rtnl_rule_set_family()
560 rule->ce_mask |= RULE_ATTR_FAMILY; in rtnl_rule_set_family()
563 int rtnl_rule_get_family(struct rtnl_rule *rule) in rtnl_rule_get_family() argument
565 if (rule->ce_mask & RULE_ATTR_FAMILY) in rtnl_rule_get_family()
566 return rule->r_family; in rtnl_rule_get_family()
571 void rtnl_rule_set_prio(struct rtnl_rule *rule, int prio) in rtnl_rule_set_prio() argument
573 rule->r_prio = prio; in rtnl_rule_set_prio()
574 rule->ce_mask |= RULE_ATTR_PRIO; in rtnl_rule_set_prio()
577 int rtnl_rule_get_prio(struct rtnl_rule *rule) in rtnl_rule_get_prio() argument
579 if (rule->ce_mask & RULE_ATTR_PRIO) in rtnl_rule_get_prio()
580 return rule->r_prio; in rtnl_rule_get_prio()
585 void rtnl_rule_set_mark(struct rtnl_rule *rule, uint64_t mark) in rtnl_rule_set_mark() argument
587 rule->r_mark = mark; in rtnl_rule_set_mark()
588 rule->ce_mask |= RULE_ATTR_MARK; in rtnl_rule_set_mark()
591 uint64_t rtnl_rule_get_mark(struct rtnl_rule *rule) in rtnl_rule_get_mark() argument
593 if (rule->ce_mask & RULE_ATTR_MARK) in rtnl_rule_get_mark()
594 return rule->r_mark; in rtnl_rule_get_mark()
599 void rtnl_rule_set_table(struct rtnl_rule *rule, int table) in rtnl_rule_set_table() argument
601 rule->r_table = table; in rtnl_rule_set_table()
602 rule->ce_mask |= RULE_ATTR_TABLE; in rtnl_rule_set_table()
605 int rtnl_rule_get_table(struct rtnl_rule *rule) in rtnl_rule_get_table() argument
607 if (rule->ce_mask & RULE_ATTR_TABLE) in rtnl_rule_get_table()
608 return rule->r_table; in rtnl_rule_get_table()
613 void rtnl_rule_set_dsfield(struct rtnl_rule *rule, int dsfield) in rtnl_rule_set_dsfield() argument
615 rule->r_dsfield = dsfield; in rtnl_rule_set_dsfield()
616 rule->ce_mask |= RULE_ATTR_DSFIELD; in rtnl_rule_set_dsfield()
619 int rtnl_rule_get_dsfield(struct rtnl_rule *rule) in rtnl_rule_get_dsfield() argument
621 if (rule->ce_mask & RULE_ATTR_DSFIELD) in rtnl_rule_get_dsfield()
622 return rule->r_dsfield; in rtnl_rule_get_dsfield()
627 void rtnl_rule_set_src_len(struct rtnl_rule *rule, int len) in rtnl_rule_set_src_len() argument
629 rule->r_src_len = len; in rtnl_rule_set_src_len()
630 if (rule->ce_mask & RULE_ATTR_SRC) in rtnl_rule_set_src_len()
631 nl_addr_set_prefixlen(rule->r_src, len); in rtnl_rule_set_src_len()
632 rule->ce_mask |= RULE_ATTR_SRC_LEN; in rtnl_rule_set_src_len()
635 int rtnl_rule_get_src_len(struct rtnl_rule *rule) in rtnl_rule_get_src_len() argument
637 if (rule->ce_mask & RULE_ATTR_SRC_LEN) in rtnl_rule_get_src_len()
638 return rule->r_src_len; in rtnl_rule_get_src_len()
643 void rtnl_rule_set_dst_len(struct rtnl_rule *rule, int len) in rtnl_rule_set_dst_len() argument
645 rule->r_dst_len = len; in rtnl_rule_set_dst_len()
646 if (rule->ce_mask & RULE_ATTR_DST) in rtnl_rule_set_dst_len()
647 nl_addr_set_prefixlen(rule->r_dst, len); in rtnl_rule_set_dst_len()
648 rule->ce_mask |= RULE_ATTR_DST_LEN; in rtnl_rule_set_dst_len()
651 int rtnl_rule_get_dst_len(struct rtnl_rule *rule) in rtnl_rule_get_dst_len() argument
653 if (rule->ce_mask & RULE_ATTR_DST_LEN) in rtnl_rule_get_dst_len()
654 return rule->r_dst_len; in rtnl_rule_get_dst_len()
659 static inline int __assign_addr(struct rtnl_rule *rule, struct nl_addr **pos, in __assign_addr() argument
662 if (rule->ce_mask & RULE_ATTR_FAMILY) { in __assign_addr()
663 if (new->a_family != rule->r_family) in __assign_addr()
666 rule->r_family = new->a_family; in __assign_addr()
675 rule->ce_mask |= (flag | RULE_ATTR_FAMILY); in __assign_addr()
680 int rtnl_rule_set_src(struct rtnl_rule *rule, struct nl_addr *src) in rtnl_rule_set_src() argument
682 return __assign_addr(rule, &rule->r_src, src, &rule->r_src_len, in rtnl_rule_set_src()
686 struct nl_addr *rtnl_rule_get_src(struct rtnl_rule *rule) in rtnl_rule_get_src() argument
688 if (rule->ce_mask & RULE_ATTR_SRC) in rtnl_rule_get_src()
689 return rule->r_src; in rtnl_rule_get_src()
694 int rtnl_rule_set_dst(struct rtnl_rule *rule, struct nl_addr *dst) in rtnl_rule_set_dst() argument
696 return __assign_addr(rule, &rule->r_dst, dst, &rule->r_dst_len, in rtnl_rule_set_dst()
700 struct nl_addr *rtnl_rule_get_dst(struct rtnl_rule *rule) in rtnl_rule_get_dst() argument
702 if (rule->ce_mask & RULE_ATTR_DST) in rtnl_rule_get_dst()
703 return rule->r_dst; in rtnl_rule_get_dst()
708 int rtnl_rule_set_iif(struct rtnl_rule *rule, const char *dev) in rtnl_rule_set_iif() argument
713 strcpy(rule->r_iif, dev); in rtnl_rule_set_iif()
714 rule->ce_mask |= RULE_ATTR_IIF; in rtnl_rule_set_iif()
718 char *rtnl_rule_get_iif(struct rtnl_rule *rule) in rtnl_rule_get_iif() argument
720 if (rule->ce_mask & RULE_ATTR_IIF) in rtnl_rule_get_iif()
721 return rule->r_iif; in rtnl_rule_get_iif()
726 void rtnl_rule_set_action(struct rtnl_rule *rule, int type) in rtnl_rule_set_action() argument
728 rule->r_type = type; in rtnl_rule_set_action()
729 rule->ce_mask |= RULE_ATTR_TYPE; in rtnl_rule_set_action()
732 int rtnl_rule_get_action(struct rtnl_rule *rule) in rtnl_rule_get_action() argument
734 if (rule->ce_mask & RULE_ATTR_TYPE) in rtnl_rule_get_action()
735 return rule->r_type; in rtnl_rule_get_action()
740 void rtnl_rule_set_realms(struct rtnl_rule *rule, uint32_t realms) in rtnl_rule_set_realms() argument
742 rule->r_realms = realms; in rtnl_rule_set_realms()
743 rule->ce_mask |= RULE_ATTR_REALMS; in rtnl_rule_set_realms()
746 uint32_t rtnl_rule_get_realms(struct rtnl_rule *rule) in rtnl_rule_get_realms() argument
748 if (rule->ce_mask & RULE_ATTR_REALMS) in rtnl_rule_get_realms()
749 return rule->r_realms; in rtnl_rule_get_realms()