Print this page
8927 sadb_x_kmc_t's KM cookie should be 64-bits
Reviewed by: Jason King <jason.king@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Yuri Pankov <yuripv@gmx.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libipsecutil/common/ipsec_util.c
          +++ new/usr/src/lib/libipsecutil/common/ipsec_util.c
↓ open down ↓ 15 lines elided ↑ open up ↑
  16   16   * If applicable, add the following below this CDDL HEADER, with the
  17   17   * fields enclosed by brackets "[]" replaced with your own identifying
  18   18   * information: Portions Copyright [yyyy] [name of copyright owner]
  19   19   *
  20   20   * CDDL HEADER END
  21   21   */
  22   22  /*
  23   23   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   * Copyright 2012 Milan Juri. All rights reserved.
       26 + * Copyright 2017 Joyent, Inc.
  26   27   */
  27   28  
  28   29  #include <unistd.h>
  29   30  #include <stdio.h>
  30   31  #include <stdlib.h>
  31   32  #include <stdarg.h>
  32   33  #include <sys/types.h>
  33   34  #include <sys/stat.h>
  34   35  #include <fcntl.h>
  35   36  #include <sys/sysconf.h>
↓ open down ↓ 1109 lines elided ↑ open up ↑
1145 1146          errno = rtnerr;
1146 1147          return (-1);
1147 1148  }
1148 1149  
1149 1150  /*
1150 1151   * Lookup the given cookie and return its corresponding label.  Return
1151 1152   * a pointer to the label on success, NULL on error (or if the label is
1152 1153   * not found).  Note that the returned label pointer points to a static
1153 1154   * string, so the label will be overwritten by a subsequent call to the
1154 1155   * function; the function is also not thread-safe as a result.
     1156 + *
     1157 + * Because this is possibly publically exported, do not change its name,
     1158 + * but this is for all intents and purposes an IKEv1/in.iked function.
1155 1159   */
1156 1160  char *
1157 1161  kmc_lookup_by_cookie(int cookie)
1158 1162  {
1159 1163          FILE            *map;
1160 1164          static char     linebuf[IBUF_SIZE];
1161 1165          char            *cur_label;
1162 1166          int             cur_cookie;
1163 1167  
1164 1168          if ((map = kmc_open_and_lock(KMCFILE)) == NULL) {
↓ open down ↓ 1419 lines elided ↑ open up ↑
2584 2588  
2585 2589  /*
2586 2590   * Print an SADB_X_EXT_KM_COOKIE extension.
2587 2591   */
2588 2592  
2589 2593  void
2590 2594  print_kmc(FILE *file, char *prefix, struct sadb_x_kmc *kmc)
2591 2595  {
2592 2596          char *cookie_label;
2593 2597  
2594      -        if ((cookie_label = kmc_lookup_by_cookie(kmc->sadb_x_kmc_cookie)) ==
2595      -            NULL)
2596      -                cookie_label = dgettext(TEXT_DOMAIN, "<Label not found.>");
     2598 +        switch (kmc->sadb_x_kmc_proto) {
     2599 +        case SADB_X_KMP_IKE:
     2600 +                cookie_label = kmc_lookup_by_cookie(kmc->sadb_x_kmc_cookie);
     2601 +                if (cookie_label == NULL)
     2602 +                        cookie_label =
     2603 +                            dgettext(TEXT_DOMAIN, "<Label not found.>");
     2604 +                (void) fprintf(file, dgettext(TEXT_DOMAIN,
     2605 +                    "%sProtocol %u, cookie=\"%s\" (%u)\n"), prefix,
     2606 +                    kmc->sadb_x_kmc_proto, cookie_label,
     2607 +                    kmc->sadb_x_kmc_cookie);
     2608 +                return;
     2609 +        case SADB_X_KMP_MANUAL:
     2610 +                cookie_label = dgettext(TEXT_DOMAIN, "Manual SA with cookie");
     2611 +                break;
     2612 +        /* case SADB_X_KMP_IKEV2: */
     2613 +        default:
     2614 +                cookie_label =
     2615 +                    dgettext(TEXT_DOMAIN, "<unknown KM protocol>");
     2616 +                break;
     2617 +        }
2597 2618  
     2619 +        /* XXX KEBE ASKS... htonll() on generic kmc_cookie? */
2598 2620          (void) fprintf(file, dgettext(TEXT_DOMAIN,
2599      -            "%sProtocol %u, cookie=\"%s\" (%u)\n"), prefix,
2600      -            kmc->sadb_x_kmc_proto, cookie_label, kmc->sadb_x_kmc_cookie);
     2621 +            "%sProtocol %u, cookie=\"%s\" (0x%"PRIx64"/%"PRIu64")\n"),
     2622 +            prefix, kmc->sadb_x_kmc_proto, cookie_label,
     2623 +            kmc->sadb_x_kmc_cookie64, kmc->sadb_x_kmc_cookie64);
2601 2624  }
2602 2625  
2603 2626  /*
2604 2627   * Print an SADB_X_EXT_REPLAY_CTR extension.
2605 2628   */
2606 2629  
2607 2630  void
2608 2631  print_replay(FILE *file, char *prefix, sadb_x_replay_ctr_t *repl)
2609 2632  {
2610 2633          (void) fprintf(file, dgettext(TEXT_DOMAIN,
↓ open down ↓ 835 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX