From daf0a4d29cdb24ca0125c6bd15a52be153fbbde3 Mon Sep 17 00:00:00 2001 From: Olivier Dugeon Date: Tue, 20 Dec 2016 15:02:34 +0100 Subject: [PATCH] Rationalize Link Parameters flags * lib/if.h: Remove LP_TE as Link Parameters is set if different from 0 See IS_LINK_PARAMS_SET macro and use LP_TE_METRIC to determine if TE metric is set or not * lib/if.c: replace LP_TE by LP_TE_METRIC in default LP status * zebra/interface.c: replace LP_TE by LP_TE_METRIC and check if TE metric is equal to standard metric or not * ospfd/ospf_te.c: replace LP_TE by LP_TE_METRIC * isisd/isis_te.c: replace LP_TE by LP_TE_METRIC Signed-off-by: Olivier Dugeon --- isisd/isis_te.c | 2 +- lib/if.c | 4 ++-- lib/if.h | 9 ++++++--- ospfd/ospf_te.c | 2 +- zebra/interface.c | 8 ++++---- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/isisd/isis_te.c b/isisd/isis_te.c index 109f5e4574..34cd8397f4 100644 --- a/isisd/isis_te.c +++ b/isisd/isis_te.c @@ -591,7 +591,7 @@ isis_link_params_update (struct isis_circuit *circuit, struct interface *ifp) else SUBTLV_TYPE(mtc->unrsv_bw) = 0; - if (IS_PARAM_SET(ifp->link_params, LP_TE)) + if (IS_PARAM_SET(ifp->link_params, LP_TE_METRIC)) set_circuitparams_te_metric(mtc, ifp->link_params->te_metric); else SUBTLV_TYPE(mtc->te_metric) = 0; diff --git a/lib/if.c b/lib/if.c index fb12f201b2..0a1a8f6a26 100644 --- a/lib/if.c +++ b/lib/if.c @@ -1302,7 +1302,7 @@ if_link_params_get (struct interface *ifp) sizeof (struct if_link_params)); if (iflp == NULL) return NULL; - /* Set TE metric == standard metric */ + /* Set TE metric equal to standard metric */ iflp->te_metric = ifp->metric; /* Compute default bandwidth based on interface */ @@ -1316,7 +1316,7 @@ if_link_params_get (struct interface *ifp) iflp->unrsv_bw[i] = iflp->default_bw; /* Update Link parameters status */ - iflp->lp_status = LP_TE | LP_MAX_BW | LP_MAX_RSV_BW | LP_UNRSV_BW; + iflp->lp_status = LP_TE_METRIC | LP_MAX_BW | LP_MAX_RSV_BW | LP_UNRSV_BW; /* Finally attach newly created Link Parameters */ ifp->link_params = iflp; diff --git a/lib/if.h b/lib/if.h index e8a3b9d7b5..cfa376d1ea 100644 --- a/lib/if.h +++ b/lib/if.h @@ -146,9 +146,13 @@ struct if_stats #define MAX_CLASS_TYPE 8 #define MAX_PKT_LOSS 50.331642 -/* Link Parameters Status: 0: unset, 1: set, */ +/* + * Link Parameters Status: + * equal to 0: unset + * different from 0: set + */ #define LP_UNSET 0x0000 -#define LP_TE 0x0001 +#define LP_TE_METRIC 0x0001 #define LP_MAX_BW 0x0002 #define LP_MAX_RSV_BW 0x0004 #define LP_UNRSV_BW 0x0008 @@ -161,7 +165,6 @@ struct if_stats #define LP_RES_BW 0x0400 #define LP_AVA_BW 0x0800 #define LP_USE_BW 0x1000 -#define LP_TE_METRIC 0x2000 #define IS_PARAM_UNSET(lp, st) !(lp->lp_status & st) #define IS_PARAM_SET(lp, st) (lp->lp_status & st) diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c index c691aac040..4c5862e84a 100644 --- a/ospfd/ospf_te.c +++ b/ospfd/ospf_te.c @@ -746,7 +746,7 @@ update_linkparams(struct mpls_te_link *lp) else TLV_TYPE(lp->unrsv_bw) = 0; - if (IS_PARAM_SET(ifp->link_params, LP_TE)) + if (IS_PARAM_SET(ifp->link_params, LP_TE_METRIC)) set_linkparams_te_metric(lp, ifp->link_params->te_metric); else TLV_TYPE(lp->te_metric) = 0; diff --git a/zebra/interface.c b/zebra/interface.c index 8eddd3062a..4a0409702f 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -1107,7 +1107,7 @@ if_dump_vty (struct vty *vty, struct interface *ifp) int i; struct if_link_params *iflp = ifp->link_params; vty_out(vty, " Traffic Engineering Link Parameters:%s", VTY_NEWLINE); - if (IS_PARAM_SET(iflp, LP_TE)) + if (IS_PARAM_SET(iflp, LP_TE_METRIC)) vty_out(vty, " TE metric %u%s",iflp->te_metric, VTY_NEWLINE); if (IS_PARAM_SET(iflp, LP_MAX_BW)) vty_out(vty, " Maximum Bandwidth %g (Byte/s)%s", iflp->max_bw, VTY_NEWLINE); @@ -1785,7 +1785,7 @@ DEFUN (link_params_metric, VTY_GET_ULONG("metric", metric, argv[idx_number]->arg); /* Update TE metric if needed */ - link_param_cmd_set_uint32 (ifp, &iflp->te_metric, LP_TE | LP_TE_METRIC, metric); + link_param_cmd_set_uint32 (ifp, &iflp->te_metric, LP_TE_METRIC, metric); return CMD_SUCCESS; } @@ -1799,7 +1799,7 @@ DEFUN (no_link_params_metric, VTY_DECLVAR_CONTEXT (interface, ifp); /* Unset TE Metric */ - link_param_cmd_unset(ifp, LP_TE | LP_TE_METRIC); + link_param_cmd_unset(ifp, LP_TE_METRIC); return CMD_SUCCESS; } @@ -2737,7 +2737,7 @@ link_params_config_write (struct vty *vty, struct interface *ifp) vty_out (vty, " link-params%s", VTY_NEWLINE); vty_out(vty, " enable%s", VTY_NEWLINE); - if (IS_PARAM_SET(iflp, LP_TE) && IS_PARAM_SET(iflp, LP_TE_METRIC)) + if (IS_PARAM_SET(iflp, LP_TE_METRIC) && iflp->te_metric != ifp->metric) vty_out(vty, " metric %u%s",iflp->te_metric, VTY_NEWLINE); if (IS_PARAM_SET(iflp, LP_MAX_BW) && iflp->max_bw != iflp->default_bw) vty_out(vty, " max-bw %g%s", iflp->max_bw, VTY_NEWLINE); -- 2.39.5