Commit bdf9e86d authored by Stephen Hemminger's avatar Stephen Hemminger

fix last change

Need to use correct XFRMA_ constants.
Get rid of bogus casts. Fix case where no attribute returned.
Signed-off-by: default avatarStephen Hemminger <shemminger@linux-foundation.org>
parent f90c4f4e
...@@ -780,8 +780,6 @@ int print_spdinfo( struct nlmsghdr *n, void *arg) ...@@ -780,8 +780,6 @@ int print_spdinfo( struct nlmsghdr *n, void *arg)
__u32 *f = NLMSG_DATA(n); __u32 *f = NLMSG_DATA(n);
struct rtattr * tb[XFRMA_SPD_MAX+1]; struct rtattr * tb[XFRMA_SPD_MAX+1];
struct rtattr * rta; struct rtattr * rta;
struct xfrmu_spdinfo *si;
struct xfrmu_spdhinfo *sh;
int len = n->nlmsg_len; int len = n->nlmsg_len;
...@@ -795,12 +793,14 @@ int print_spdinfo( struct nlmsghdr *n, void *arg) ...@@ -795,12 +793,14 @@ int print_spdinfo( struct nlmsghdr *n, void *arg)
parse_rtattr(tb, XFRMA_SPD_MAX, rta, len); parse_rtattr(tb, XFRMA_SPD_MAX, rta, len);
fprintf(fp,"\t SPD"); fprintf(fp,"\t SPD");
if (tb[XFRMA_SPDINFO]) { if (tb[XFRMA_SPD_INFO]) {
if (RTA_PAYLOAD(tb[XFRMA_SPDINFO]) < sizeof(*si)) { struct xfrmu_spdinfo *si;
if (RTA_PAYLOAD(tb[XFRMA_SPD_INFO]) < sizeof(*si)) {
fprintf(stderr, "SPDinfo: Wrong len %d\n", len); fprintf(stderr, "SPDinfo: Wrong len %d\n", len);
return -1; return -1;
} }
si = (struct xfrmu_spdinfo *)RTA_DATA(tb[XFRMA_SPDINFO]); si = RTA_DATA(tb[XFRMA_SPD_INFO]);
fprintf(fp," IN %d", si->incnt); fprintf(fp," IN %d", si->incnt);
fprintf(fp," OUT %d", si->outcnt); fprintf(fp," OUT %d", si->outcnt);
fprintf(fp," FWD %d", si->fwdcnt); fprintf(fp," FWD %d", si->fwdcnt);
...@@ -816,12 +816,14 @@ int print_spdinfo( struct nlmsghdr *n, void *arg) ...@@ -816,12 +816,14 @@ int print_spdinfo( struct nlmsghdr *n, void *arg)
fprintf(fp,"\n"); fprintf(fp,"\n");
} }
if (show_stats > 1) { if (show_stats > 1) {
if (tb[XFRMA_SPDHINFO]) { struct xfrmu_spdhinfo *sh;
if (RTA_PAYLOAD(tb[XFRMA_SPDHINFO]) < sizeof(*sh)) {
if (tb[XFRMA_SPD_HINFO]) {
if (RTA_PAYLOAD(tb[XFRMA_SPD_HINFO]) < sizeof(*sh)) {
fprintf(stderr, "SPDinfo: Wrong len %d\n", len); fprintf(stderr, "SPDinfo: Wrong len %d\n", len);
return -1; return -1;
} }
sh = (struct xfrmu_spdhinfo *)RTA_DATA(tb[XFRMA_SPDHINFO]); sh = RTA_DATA(tb[XFRMA_SPD_HINFO]);
fprintf(fp,"\t SPD buckets:"); fprintf(fp,"\t SPD buckets:");
fprintf(fp," count %d", sh->spdhcnt); fprintf(fp," count %d", sh->spdhcnt);
fprintf(fp," Max %d", sh->spdhmcnt); fprintf(fp," Max %d", sh->spdhmcnt);
......
...@@ -686,7 +686,7 @@ int xfrm_state_print(const struct sockaddr_nl *who, struct nlmsghdr *n, ...@@ -686,7 +686,7 @@ int xfrm_state_print(const struct sockaddr_nl *who, struct nlmsghdr *n,
fprintf(stderr, "Buggy XFRM_MSG_DELPOLICY: too short XFRMA_POLICY len\n"); fprintf(stderr, "Buggy XFRM_MSG_DELPOLICY: too short XFRMA_POLICY len\n");
return -1; return -1;
} }
xsinfo = (struct xfrm_usersa_info *)RTA_DATA(tb[XFRMA_SA]); xsinfo = RTA_DATA(tb[XFRMA_SA]);
} }
xfrm_state_info_print(xsinfo, tb, fp, NULL, NULL); xfrm_state_info_print(xsinfo, tb, fp, NULL, NULL);
...@@ -940,7 +940,6 @@ int print_sadinfo(struct nlmsghdr *n, void *arg) ...@@ -940,7 +940,6 @@ int print_sadinfo(struct nlmsghdr *n, void *arg)
__u32 *f = NLMSG_DATA(n); __u32 *f = NLMSG_DATA(n);
struct rtattr *tb[XFRMA_SAD_MAX+1]; struct rtattr *tb[XFRMA_SAD_MAX+1];
struct rtattr *rta; struct rtattr *rta;
struct xfrmu_sadhinfo *si;
__u32 *cnt; __u32 *cnt;
int len = n->nlmsg_len; int len = n->nlmsg_len;
...@@ -954,9 +953,9 @@ int print_sadinfo(struct nlmsghdr *n, void *arg) ...@@ -954,9 +953,9 @@ int print_sadinfo(struct nlmsghdr *n, void *arg)
rta = XFRMSAPD_RTA(f); rta = XFRMSAPD_RTA(f);
parse_rtattr(tb, XFRMA_SAD_MAX, rta, len); parse_rtattr(tb, XFRMA_SAD_MAX, rta, len);
if (tb[XFRMA_SADCNT]) { if (tb[XFRMA_SAD_CNT]) {
fprintf(fp,"\t SAD"); fprintf(fp,"\t SAD");
cnt = (__u32 *)RTA_DATA(tb[XFRMA_SADCNT]); cnt = (__u32 *)RTA_DATA(tb[XFRMA_SAD_CNT]);
fprintf(fp," count %d", *cnt); fprintf(fp," count %d", *cnt);
} else { } else {
fprintf(fp,"BAD SAD info returned\n"); fprintf(fp,"BAD SAD info returned\n");
...@@ -964,19 +963,21 @@ int print_sadinfo(struct nlmsghdr *n, void *arg) ...@@ -964,19 +963,21 @@ int print_sadinfo(struct nlmsghdr *n, void *arg)
} }
if (show_stats) { if (show_stats) {
if (!tb[XFRMA_SADHINFO]) { if (tb[XFRMA_SAD_HINFO]) {
} struct xfrmu_sadhinfo *si;
if (RTA_PAYLOAD(tb[XFRMA_SADHINFO]) < sizeof(*si)) {
if (RTA_PAYLOAD(tb[XFRMA_SAD_HINFO]) < sizeof(*si)) {
fprintf(fp,"BAD SAD length returned\n"); fprintf(fp,"BAD SAD length returned\n");
return -1; return -1;
} }
si = (struct xfrmu_sadhinfo *)RTA_DATA(tb[XFRMA_SADHINFO]); si = RTA_DATA(tb[XFRMA_SAD_HINFO]);
fprintf(fp," (buckets "); fprintf(fp," (buckets ");
fprintf(fp,"count %d", si->sadhcnt); fprintf(fp,"count %d", si->sadhcnt);
fprintf(fp," Max %d", si->sadhmcnt); fprintf(fp," Max %d", si->sadhmcnt);
fprintf(fp,")"); fprintf(fp,")");
} }
}
fprintf(fp,"\n"); fprintf(fp,"\n");
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment