From: 12!tgraf <12!tgraf> Date: Tue, 18 Jan 2005 22:11:58 +0000 (+0000) Subject: Switch to parse_rtattr and use XFRMA_MAX directly instead of a easly X-Git-Tag: v2_6_10-050124~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2534613eeba36f2a59a7876dbe1b291c76fcb4da;p=thirdparty%2Fiproute2.git Switch to parse_rtattr and use XFRMA_MAX directly instead of a easly forgetable magic define (Logical change 1.129) --- diff --git a/ip/xfrm_policy.c b/ip/xfrm_policy.c index 093983e37..c1331a420 100644 --- a/ip/xfrm_policy.c +++ b/ip/xfrm_policy.c @@ -337,8 +337,7 @@ static int xfrm_policy_print(const struct sockaddr_nl *who, FILE *fp = (FILE*)arg; struct xfrm_userpolicy_info *xpinfo = NLMSG_DATA(n); int len = n->nlmsg_len; - struct rtattr * tb[XFRM_MAX_DEPTH]; - int ntb; + struct rtattr * tb[XFRMA_MAX+1]; if (n->nlmsg_type != XFRM_MSG_NEWPOLICY && n->nlmsg_type != XFRM_MSG_DELPOLICY) { @@ -356,8 +355,7 @@ static int xfrm_policy_print(const struct sockaddr_nl *who, if (!xfrm_policy_filter_match(xpinfo)) return 0; - memset(tb, 0, sizeof(tb)); - ntb = parse_rtattr_byindex(tb, XFRM_MAX_DEPTH, XFRMP_RTA(xpinfo), len); + parse_rtattr(tb, XFRMA_MAX, XFRMP_RTA(xpinfo), len); if (n->nlmsg_type == XFRM_MSG_DELPOLICY) fprintf(fp, "Deleted "); @@ -407,7 +405,7 @@ static int xfrm_policy_print(const struct sockaddr_nl *who, if (show_stats > 0) xfrm_lifetime_print(&xpinfo->lft, &xpinfo->curlft, fp, "\t"); - xfrm_xfrma_print(tb, ntb, xpinfo->sel.family, fp, "\t"); + xfrm_xfrma_print(tb, xpinfo->sel.family, fp, "\t"); if (oneline) fprintf(fp, "\n"); diff --git a/ip/xfrm_state.c b/ip/xfrm_state.c index 8cfdd927c..b6481975e 100644 --- a/ip/xfrm_state.c +++ b/ip/xfrm_state.c @@ -43,7 +43,7 @@ * data = struct xfrm_usersa_info * rtattr * rtattr - * ... (max count of rtattr is XFRM_MAX_DEPTH) + * ... (max count of rtattr is XFRM_MAX+1 * * each rtattr data = struct xfrm_algo(dynamic size) or xfrm_address_t */ @@ -397,7 +397,6 @@ static int xfrm_state_print(const struct sockaddr_nl *who, struct xfrm_usersa_info *xsinfo = NLMSG_DATA(n); int len = n->nlmsg_len; struct rtattr * tb[XFRMA_MAX+1]; - int ntb; if (n->nlmsg_type != XFRM_MSG_NEWSA && n->nlmsg_type != XFRM_MSG_DELSA) { @@ -415,8 +414,7 @@ static int xfrm_state_print(const struct sockaddr_nl *who, if (!xfrm_state_filter_match(xsinfo)) return 0; - memset(tb, 0, sizeof(tb)); - ntb = parse_rtattr_byindex(tb, XFRM_MAX_DEPTH, XFRMS_RTA(xsinfo), len); + parse_rtattr(tb, XFRMA_MAX, XFRMS_RTA(xsinfo), len); if (n->nlmsg_type == XFRM_MSG_DELSA) fprintf(fp, "Deleted "); @@ -441,7 +439,7 @@ static int xfrm_state_print(const struct sockaddr_nl *who, } fprintf(fp, "%s", _SL_); - xfrm_xfrma_print(tb, ntb, xsinfo->family, fp, "\t"); + xfrm_xfrma_print(tb, xsinfo->family, fp, "\t"); if (!xfrm_selector_iszero(&xsinfo->sel)) xfrm_selector_print(&xsinfo->sel, xsinfo->family, fp, "\tsel ");