Switch to parse_rtattr and use XFRMA_MAX directly instead of a easly
forgetable magic define (Logical change 1.129)
This commit is contained in:
parent
ebb4e4376a
commit
2534613eeb
|
|
@ -337,8 +337,7 @@ static int xfrm_policy_print(const struct sockaddr_nl *who,
|
||||||
FILE *fp = (FILE*)arg;
|
FILE *fp = (FILE*)arg;
|
||||||
struct xfrm_userpolicy_info *xpinfo = NLMSG_DATA(n);
|
struct xfrm_userpolicy_info *xpinfo = NLMSG_DATA(n);
|
||||||
int len = n->nlmsg_len;
|
int len = n->nlmsg_len;
|
||||||
struct rtattr * tb[XFRM_MAX_DEPTH];
|
struct rtattr * tb[XFRMA_MAX+1];
|
||||||
int ntb;
|
|
||||||
|
|
||||||
if (n->nlmsg_type != XFRM_MSG_NEWPOLICY &&
|
if (n->nlmsg_type != XFRM_MSG_NEWPOLICY &&
|
||||||
n->nlmsg_type != XFRM_MSG_DELPOLICY) {
|
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))
|
if (!xfrm_policy_filter_match(xpinfo))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
memset(tb, 0, sizeof(tb));
|
parse_rtattr(tb, XFRMA_MAX, XFRMP_RTA(xpinfo), len);
|
||||||
ntb = parse_rtattr_byindex(tb, XFRM_MAX_DEPTH, XFRMP_RTA(xpinfo), len);
|
|
||||||
|
|
||||||
if (n->nlmsg_type == XFRM_MSG_DELPOLICY)
|
if (n->nlmsg_type == XFRM_MSG_DELPOLICY)
|
||||||
fprintf(fp, "Deleted ");
|
fprintf(fp, "Deleted ");
|
||||||
|
|
@ -407,7 +405,7 @@ static int xfrm_policy_print(const struct sockaddr_nl *who,
|
||||||
if (show_stats > 0)
|
if (show_stats > 0)
|
||||||
xfrm_lifetime_print(&xpinfo->lft, &xpinfo->curlft, fp, "\t");
|
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)
|
if (oneline)
|
||||||
fprintf(fp, "\n");
|
fprintf(fp, "\n");
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@
|
||||||
* data = struct xfrm_usersa_info
|
* data = struct xfrm_usersa_info
|
||||||
* rtattr
|
* rtattr
|
||||||
* 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
|
* 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);
|
struct xfrm_usersa_info *xsinfo = NLMSG_DATA(n);
|
||||||
int len = n->nlmsg_len;
|
int len = n->nlmsg_len;
|
||||||
struct rtattr * tb[XFRMA_MAX+1];
|
struct rtattr * tb[XFRMA_MAX+1];
|
||||||
int ntb;
|
|
||||||
|
|
||||||
if (n->nlmsg_type != XFRM_MSG_NEWSA &&
|
if (n->nlmsg_type != XFRM_MSG_NEWSA &&
|
||||||
n->nlmsg_type != XFRM_MSG_DELSA) {
|
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))
|
if (!xfrm_state_filter_match(xsinfo))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
memset(tb, 0, sizeof(tb));
|
parse_rtattr(tb, XFRMA_MAX, XFRMS_RTA(xsinfo), len);
|
||||||
ntb = parse_rtattr_byindex(tb, XFRM_MAX_DEPTH, XFRMS_RTA(xsinfo), len);
|
|
||||||
|
|
||||||
if (n->nlmsg_type == XFRM_MSG_DELSA)
|
if (n->nlmsg_type == XFRM_MSG_DELSA)
|
||||||
fprintf(fp, "Deleted ");
|
fprintf(fp, "Deleted ");
|
||||||
|
|
@ -441,7 +439,7 @@ static int xfrm_state_print(const struct sockaddr_nl *who,
|
||||||
}
|
}
|
||||||
fprintf(fp, "%s", _SL_);
|
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))
|
if (!xfrm_selector_iszero(&xsinfo->sel))
|
||||||
xfrm_selector_print(&xsinfo->sel, xsinfo->family, fp, "\tsel ");
|
xfrm_selector_print(&xsinfo->sel, xsinfo->family, fp, "\tsel ");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue