nat64lsn.c (f76e5f2087e097d7eb612d831801082262533d2d) nat64lsn.c (c5e85276aca64be6b5b6d0a2388db5a47bb36637)
1/*-
2 * Copyright (c) 2015-2016 Yandex LLC
3 * Copyright (c) 2015-2016 Alexander V. Chernikov <melifaro@FreeBSD.org>
4 * Copyright (c) 2015-2016 Andrey V. Elsukov <ae@FreeBSD.org>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 23 unchanged lines hidden (view full) ---

32#include <sys/types.h>
33#include <sys/socket.h>
34
35#include "ipfw2.h"
36
37#include <ctype.h>
38#include <err.h>
39#include <errno.h>
1/*-
2 * Copyright (c) 2015-2016 Yandex LLC
3 * Copyright (c) 2015-2016 Alexander V. Chernikov <melifaro@FreeBSD.org>
4 * Copyright (c) 2015-2016 Andrey V. Elsukov <ae@FreeBSD.org>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 23 unchanged lines hidden (view full) ---

32#include <sys/types.h>
33#include <sys/socket.h>
34
35#include "ipfw2.h"
36
37#include <ctype.h>
38#include <err.h>
39#include <errno.h>
40#include <inttypes.h>
40#include <netdb.h>
41#include <stdio.h>
42#include <stdlib.h>
43#include <string.h>
44#include <sysexits.h>
45
46#include <net/if.h>
47#include <netinet/in.h>

--- 634 unchanged lines hidden (view full) ---

682 memcpy(stats, oc + 1, sizeof(*stats));
683 free(oh);
684 return (0);
685 }
686 free(oh);
687 return (-1);
688}
689
41#include <netdb.h>
42#include <stdio.h>
43#include <stdlib.h>
44#include <string.h>
45#include <sysexits.h>
46
47#include <net/if.h>
48#include <netinet/in.h>

--- 634 unchanged lines hidden (view full) ---

683 memcpy(stats, oc + 1, sizeof(*stats));
684 free(oh);
685 return (0);
686 }
687 free(oh);
688 return (-1);
689}
690
690#define _P_STAT(_s, _f) printf("%8s:\t%lu\n", #_f, _s._f)
691static void
692nat64lsn_stats(const char *name, uint8_t set)
693{
694 struct ipfw_nat64lsn_stats stats;
695
696 if (nat64lsn_get_stats(name, set, &stats) != 0)
697 err(EX_OSERR, "Error retrieving stats");
698
691static void
692nat64lsn_stats(const char *name, uint8_t set)
693{
694 struct ipfw_nat64lsn_stats stats;
695
696 if (nat64lsn_get_stats(name, set, &stats) != 0)
697 err(EX_OSERR, "Error retrieving stats");
698
699 _P_STAT(stats, opcnt64);
700 _P_STAT(stats, opcnt46);
701 _P_STAT(stats, ofrags);
702 _P_STAT(stats, ifrags);
703 _P_STAT(stats, oerrors);
704 _P_STAT(stats, noroute4);
705 _P_STAT(stats, noroute6);
706 _P_STAT(stats, noproto);
707 _P_STAT(stats, nomem);
708 _P_STAT(stats, dropped);
699 if (co.use_set != 0 || set != 0)
700 printf("set %u ", set);
701 printf("nat64lsn %s\n", name);
702 printf("\t%ju packets translated from IPv6 to IPv4\n",
703 (uintmax_t)stats.opcnt64);
704 printf("\t%ju packets translated from IPv4 to IPv6\n",
705 (uintmax_t)stats.opcnt46);
706 printf("\t%ju IPv6 fragments created\n",
707 (uintmax_t)stats.ofrags);
708 printf("\t%ju IPv4 fragments received\n",
709 (uintmax_t)stats.ifrags);
710 printf("\t%ju output packets dropped due to no bufs, etc.\n",
711 (uintmax_t)stats.oerrors);
712 printf("\t%ju output packets discarded due to no IPv4 route\n",
713 (uintmax_t)stats.noroute4);
714 printf("\t%ju output packets discarded due to no IPv6 route\n",
715 (uintmax_t)stats.noroute6);
716 printf("\t%ju packets discarded due to unsupported protocol\n",
717 (uintmax_t)stats.noproto);
718 printf("\t%ju packets discarded due to memory allocation problems\n",
719 (uintmax_t)stats.nomem);
720 printf("\t%ju packets discarded due to some errors\n",
721 (uintmax_t)stats.dropped);
722 printf("\t%ju packets not matched with IPv4 prefix\n",
723 (uintmax_t)stats.nomatch4);
709
724
710 _P_STAT(stats, hostcount);
711 _P_STAT(stats, tcpchunks);
712 _P_STAT(stats, udpchunks);
713 _P_STAT(stats, icmpchunks);
714 _P_STAT(stats, jcalls);
715 _P_STAT(stats, jrequests);
716 _P_STAT(stats, jhostsreq);
717 _P_STAT(stats, jportreq);
718 _P_STAT(stats, jhostfails);
719 _P_STAT(stats, jportfails);
720 _P_STAT(stats, jreinjected);
721 _P_STAT(stats, jmaxlen);
722 _P_STAT(stats, jnomem);
723 _P_STAT(stats, screated);
724 _P_STAT(stats, sdeleted);
725 _P_STAT(stats, spgcreated);
726 _P_STAT(stats, spgdeleted);
725 printf("\t%ju mbufs queued for post processing\n",
726 (uintmax_t)stats.jreinjected);
727 printf("\t%ju times the job queue was processed\n",
728 (uintmax_t)stats.jcalls);
729 printf("\t%ju job requests queued\n",
730 (uintmax_t)stats.jrequests);
731 printf("\t%ju job requests queue limit reached\n",
732 (uintmax_t)stats.jmaxlen);
733 printf("\t%ju job requests failed due to memory allocation problems\n",
734 (uintmax_t)stats.jnomem);
735
736 printf("\t%ju hosts allocated\n", (uintmax_t)stats.hostcount);
737 printf("\t%ju hosts requested\n", (uintmax_t)stats.jhostsreq);
738 printf("\t%ju host requests failed\n", (uintmax_t)stats.jhostfails);
739
740 printf("\t%ju portgroups requested\n", (uintmax_t)stats.jportreq);
741 printf("\t%ju portgroups allocated\n", (uintmax_t)stats.spgcreated);
742 printf("\t%ju portgroups deleted\n", (uintmax_t)stats.spgdeleted);
743 printf("\t%ju portgroup requests failed\n",
744 (uintmax_t)stats.jportfails);
745 printf("\t%ju portgroups allocated for TCP\n",
746 (uintmax_t)stats.tcpchunks);
747 printf("\t%ju portgroups allocated for UDP\n",
748 (uintmax_t)stats.udpchunks);
749 printf("\t%ju portgroups allocated for ICMP\n",
750 (uintmax_t)stats.icmpchunks);
751
752 printf("\t%ju states created\n", (uintmax_t)stats.screated);
753 printf("\t%ju states deleted\n", (uintmax_t)stats.sdeleted);
727}
728
729static int
730nat64lsn_show_cb(ipfw_nat64lsn_cfg *cfg, const char *name, uint8_t set)
731{
732 char abuf[INET6_ADDRSTRLEN];
733
734 if (name != NULL && strcmp(cfg->name, name) != 0)

--- 120 unchanged lines hidden ---
754}
755
756static int
757nat64lsn_show_cb(ipfw_nat64lsn_cfg *cfg, const char *name, uint8_t set)
758{
759 char abuf[INET6_ADDRSTRLEN];
760
761 if (name != NULL && strcmp(cfg->name, name) != 0)

--- 120 unchanged lines hidden ---