UNSET_FLAG (as_external_lsa->bits_metric, OSPF6_ASBR_BIT_F);
/* external route tag */
- UNSET_FLAG (as_external_lsa->bits_metric, OSPF6_ASBR_BIT_T);
+ if (info->tag)
+ SET_FLAG (as_external_lsa->bits_metric, OSPF6_ASBR_BIT_T);
+ else
+ UNSET_FLAG (as_external_lsa->bits_metric, OSPF6_ASBR_BIT_T);
/* Set metric */
OSPF6_ASBR_METRIC_SET (as_external_lsa, route->path.cost);
/* External Route Tag */
if (CHECK_FLAG (as_external_lsa->bits_metric, OSPF6_ASBR_BIT_T))
{
- /* xxx */
+ route_tag_t network_order = htonl(info->tag);
+
+ memcpy (p, &network_order, sizeof(network_order));
+ p += sizeof(network_order);
}
/* Fill LSA Header */
ospf6_lsa_originate_process (lsa, ospf6);
}
+static route_tag_t
+ospf6_as_external_lsa_get_tag (struct ospf6_lsa *lsa)
+{
+ struct ospf6_as_external_lsa *external;
+ ptrdiff_t tag_offset;
+ route_tag_t network_order;
+
+ if (!lsa)
+ return 0;
+
+ external = (struct ospf6_as_external_lsa *)
+ OSPF6_LSA_HEADER_END (lsa->header);
+
+ if (!CHECK_FLAG (external->bits_metric, OSPF6_ASBR_BIT_T))
+ return 0;
+
+ tag_offset = sizeof(*external) + OSPF6_PREFIX_SPACE(external->prefix.prefix_length);
+ if (CHECK_FLAG (external->bits_metric, OSPF6_ASBR_BIT_F))
+ tag_offset += sizeof(struct in6_addr);
+
+ memcpy(&network_order, (caddr_t)external + tag_offset, sizeof(network_order));
+ return ntohl(network_order);
+}
void
ospf6_asbr_lsa_add (struct ospf6_lsa *lsa)
route->path.u.cost_e2 = 0;
}
+ route->path.tag = ospf6_as_external_lsa_get_tag (lsa);
+
ospf6_route_copy_nexthops (route, asbr_entry);
if (IS_OSPF6_DEBUG_EXAMIN (AS_EXTERNAL))
void
ospf6_asbr_redistribute_add (int type, ifindex_t ifindex, struct prefix *prefix,
- u_int nexthop_num, struct in6_addr *nexthop)
+ u_int nexthop_num, struct in6_addr *nexthop, route_tag_t tag)
{
int ret;
struct ospf6_route troute;
memset (&tinfo, 0, sizeof (tinfo));
troute.route_option = &tinfo;
tinfo.ifindex = ifindex;
+ tinfo.tag = tag;
ret = route_map_apply (ospf6->rmap[type].map, prefix,
RMAP_OSPF6, &troute);
if (! IN6_IS_ADDR_UNSPECIFIED (&tinfo.forwarding))
memcpy (&info->forwarding, &tinfo.forwarding,
sizeof (struct in6_addr));
+ info->tag = tinfo.tag;
+ }
+ else
+ {
+ /* If there is no route-map, simply update the tag */
+ info->tag = tag;
}
info->type = type;
if (! IN6_IS_ADDR_UNSPECIFIED (&tinfo.forwarding))
memcpy (&info->forwarding, &tinfo.forwarding,
sizeof (struct in6_addr));
+ info->tag = tinfo.tag;
+ }
+ else
+ {
+ /* If there is no route-map, simply set the tag */
+ info->tag = tag;
}
info->type = type;
ospf6_routemap_rule_match_interface_free
};
+/* Match function for matching route tags */
+static route_map_result_t
+ospf6_routemap_rule_match_tag (void *rule, struct prefix *prefix,
+ route_map_object_t type, void *object)
+{
+ route_tag_t *tag = rule;
+ struct ospf6_route *route = object;
+ struct ospf6_external_info *info = route->route_option;
+
+ if (type == RMAP_OSPF6 && info->tag == *tag)
+ return RMAP_MATCH;
+
+ return RMAP_NOMATCH;
+}
+
+static struct route_map_rule_cmd
+ospf6_routemap_rule_match_tag_cmd =
+{
+ "tag",
+ ospf6_routemap_rule_match_tag,
+ route_map_rule_tag_compile,
+ route_map_rule_tag_free,
+};
+
static route_map_result_t
ospf6_routemap_rule_set_metric_type (void *rule, struct prefix *prefix,
route_map_object_t type, void *object)
ospf6_routemap_rule_set_forwarding_free,
};
+static route_map_result_t
+ospf6_routemap_rule_set_tag (void *rule, struct prefix *prefix,
+ route_map_object_t type, void *object)
+{
+ route_tag_t *tag = rule;
+ struct ospf6_route *route = object;
+ struct ospf6_external_info *info = route->route_option;
+
+ if (type != RMAP_OSPF6)
+ return RMAP_OKAY;
+
+ info->tag = *tag;
+ return RMAP_OKAY;
+}
+
+static struct route_map_rule_cmd
+ospf6_routemap_rule_set_tag_cmd =
+{
+ "tag",
+ ospf6_routemap_rule_set_tag,
+ route_map_rule_tag_compile,
+ route_map_rule_tag_free,
+};
+
static int
route_map_command_status (struct vty *vty, int ret)
{
DEFUN (ospf6_routemap_no_match_interface,
ospf6_routemap_no_match_interface_cmd,
"no match interface",
- MATCH_STR
NO_STR
+ MATCH_STR
"Match first hop interface of route\n")
{
int ret = route_map_delete_match ((struct route_map_index *) vty->index,
ALIAS (ospf6_routemap_no_match_interface,
ospf6_routemap_no_match_interface_val_cmd,
"no match interface WORD",
- MATCH_STR
NO_STR
+ MATCH_STR
"Match first hop interface of route\n"
"Interface name\n")
+/* add "match tag" */
+DEFUN (ospf6_routemap_match_tag,
+ ospf6_routemap_match_tag_cmd,
+ "match tag <1-4294967295>",
+ MATCH_STR
+ "Tag value for routing protocol\n"
+ "Tag value\n")
+{
+ int ret = route_map_add_match ((struct route_map_index *) vty->index,
+ "tag", argv[0]);
+ return route_map_command_status (vty, ret);
+}
+
+/* delete "match tag" */
+DEFUN (ospf6_routemap_no_match_tag,
+ ospf6_routemap_no_match_tag_cmd,
+ "no match tag",
+ NO_STR
+ MATCH_STR
+ "Tag value for routing protocol\n")
+{
+ int ret = route_map_delete_match ((struct route_map_index *) vty->index,
+ "tag", argc ? argv[0] : NULL);
+ return route_map_command_status (vty, ret);
+}
+
+ALIAS (ospf6_routemap_no_match_tag,
+ ospf6_routemap_no_match_tag_val_cmd,
+ "no match tag <1-4294967295>",
+ NO_STR
+ MATCH_STR
+ "Tag value for routing protocol\n"
+ "Tag value\n")
+
/* add "set metric-type" */
DEFUN (ospf6_routemap_set_metric_type,
ospf6_routemap_set_metric_type_cmd,
return route_map_command_status (vty, ret);
}
+/* add "set tag" */
+DEFUN (ospf6_routemap_set_tag,
+ ospf6_routemap_set_tag_cmd,
+ "set tag <1-4294967295>",
+ "Set value\n"
+ "Tag value for routing protocol\n"
+ "Tag value\n")
+{
+ int ret = route_map_add_set ((struct route_map_index *) vty->index,
+ "tag", argv[0]);
+ return route_map_command_status (vty, ret);
+}
+
+/* delete "set tag" */
+DEFUN (ospf6_routemap_no_set_tag,
+ ospf6_routemap_no_set_tag_cmd,
+ "no set tag",
+ NO_STR
+ "Set value\n"
+ "Tag value for routing protocol\n")
+{
+ int ret = route_map_delete_set ((struct route_map_index *) vty->index,
+ "tag", argc ? argv[0] : NULL);
+ return route_map_command_status (vty, ret);
+}
+
+ALIAS (ospf6_routemap_no_set_tag,
+ ospf6_routemap_no_set_tag_val_cmd,
+ "no set tag <1-4294967295>",
+ NO_STR
+ "Set value\n"
+ "Tag value for routing protocol\n"
+ "Tag value\n")
+
static void
ospf6_routemap_init (void)
{
route_map_install_match (&ospf6_routemap_rule_match_address_prefixlist_cmd);
route_map_install_match (&ospf6_routemap_rule_match_interface_cmd);
+ route_map_install_match (&ospf6_routemap_rule_match_tag_cmd);
route_map_install_set (&ospf6_routemap_rule_set_metric_type_cmd);
route_map_install_set (&ospf6_routemap_rule_set_metric_cmd);
route_map_install_set (&ospf6_routemap_rule_set_forwarding_cmd);
+ route_map_install_set (&ospf6_routemap_rule_set_tag_cmd);
/* Match address prefix-list */
install_element (RMAP_NODE, &ospf6_routemap_match_address_prefixlist_cmd);
install_element (RMAP_NODE, &ospf6_routemap_no_match_interface_cmd);
install_element (RMAP_NODE, &ospf6_routemap_no_match_interface_val_cmd);
+ /* Match tag */
+ install_element (RMAP_NODE, &ospf6_routemap_match_tag_cmd);
+ install_element (RMAP_NODE, &ospf6_routemap_no_match_tag_cmd);
+ install_element (RMAP_NODE, &ospf6_routemap_no_match_tag_val_cmd);
+
/* ASE Metric Type (e.g. Type-1/Type-2) */
install_element (RMAP_NODE, &ospf6_routemap_set_metric_type_cmd);
install_element (RMAP_NODE, &ospf6_routemap_no_set_metric_type_cmd);
install_element (RMAP_NODE, &no_set_metric_cmd);
install_element (RMAP_NODE, &no_set_metric_val_cmd);
- /* ASE Metric */
+ /* Forwarding address */
install_element (RMAP_NODE, &ospf6_routemap_set_forwarding_cmd);
install_element (RMAP_NODE, &ospf6_routemap_no_set_forwarding_cmd);
+
+ /* Tag */
+ install_element (RMAP_NODE, &ospf6_routemap_set_tag_cmd);
+ install_element (RMAP_NODE, &ospf6_routemap_no_set_tag_cmd);
+ install_element (RMAP_NODE, &ospf6_routemap_no_set_tag_val_cmd);
}
VNL);
}
+ /* Tag */
+ if (CHECK_FLAG (external->bits_metric, OSPF6_ASBR_BIT_T))
+ {
+ vty_out (vty, " Tag: %"ROUTE_TAG_PRI"%s",
+ ospf6_as_external_lsa_get_tag (lsa), VNL);
+ }
+
return 0;
}