Changeset View
Changeset View
Standalone View
Standalone View
sys/netpfil/ipfw/nat64/ip_fw_nat64.c
/*- | /*- | ||||
* Copyright (c) 2015-2018 Yandex LLC | * SPDX-License-Identifier: BSD-2-Clause-FreeBSD | ||||
* Copyright (c) 2015-2018 Andrey V. Elsukov <ae@FreeBSD.org> | |||||
* All rights reserved. | |||||
* | * | ||||
* Copyright (c) 2015-2019 Yandex LLC | |||||
* Copyright (c) 2015-2019 Andrey V. Elsukov <ae@FreeBSD.org> | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
* modification, are permitted provided that the following conditions | * modification, are permitted provided that the following conditions | ||||
* are met: | * are met: | ||||
* | * | ||||
* 1. Redistributions of source code must retain the above copyright | * 1. Redistributions of source code must retain the above copyright | ||||
* notice, this list of conditions and the following disclaimer. | * notice, this list of conditions and the following disclaimer. | ||||
* 2. Redistributions in binary form must reproduce the above copyright | * 2. Redistributions in binary form must reproduce the above copyright | ||||
* notice, this list of conditions and the following disclaimer in the | * notice, this list of conditions and the following disclaimer in the | ||||
Show All 32 Lines | |||||
#include <netinet/ip_fw.h> | #include <netinet/ip_fw.h> | ||||
#include <netpfil/ipfw/ip_fw_private.h> | #include <netpfil/ipfw/ip_fw_private.h> | ||||
#include "ip_fw_nat64.h" | #include "ip_fw_nat64.h" | ||||
#include "nat64_translate.h" | #include "nat64_translate.h" | ||||
VNET_DEFINE(int, nat64_debug) = 0; | VNET_DEFINE(int, nat64_debug) = 0; | ||||
VNET_DEFINE(int, nat64_allow_private) = 0; | |||||
SYSCTL_DECL(_net_inet_ip_fw); | SYSCTL_DECL(_net_inet_ip_fw); | ||||
SYSCTL_INT(_net_inet_ip_fw, OID_AUTO, nat64_debug, CTLFLAG_VNET | CTLFLAG_RW, | SYSCTL_INT(_net_inet_ip_fw, OID_AUTO, nat64_debug, CTLFLAG_VNET | CTLFLAG_RW, | ||||
&VNET_NAME(nat64_debug), 0, "Debug level for NAT64 module"); | &VNET_NAME(nat64_debug), 0, "Debug level for NAT64 module"); | ||||
SYSCTL_INT(_net_inet_ip_fw, OID_AUTO, nat64_allow_private, | |||||
CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nat64_allow_private), 0, | |||||
"Allow use of non-global IPv4 addresses with NAT64"); | |||||
static int | static int | ||||
sysctl_direct_output(SYSCTL_HANDLER_ARGS) | sysctl_direct_output(SYSCTL_HANDLER_ARGS) | ||||
{ | { | ||||
uint32_t value; | uint32_t value; | ||||
int error; | int error; | ||||
value = nat64_get_output_method(); | value = nat64_get_output_method(); | ||||
Show All 14 Lines | vnet_ipfw_nat64_init(const void *arg __unused) | ||||
struct ip_fw_chain *ch; | struct ip_fw_chain *ch; | ||||
int first, error; | int first, error; | ||||
ch = &V_layer3_chain; | ch = &V_layer3_chain; | ||||
first = IS_DEFAULT_VNET(curvnet) ? 1: 0; | first = IS_DEFAULT_VNET(curvnet) ? 1: 0; | ||||
error = nat64stl_init(ch, first); | error = nat64stl_init(ch, first); | ||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
error = nat64clat_init(ch, first); | |||||
if (error != 0) { | |||||
nat64stl_uninit(ch, first); | |||||
return (error); | |||||
} | |||||
error = nat64lsn_init(ch, first); | error = nat64lsn_init(ch, first); | ||||
if (error != 0) { | if (error != 0) { | ||||
nat64stl_uninit(ch, first); | nat64stl_uninit(ch, first); | ||||
nat64clat_uninit(ch, first); | |||||
return (error); | return (error); | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
vnet_ipfw_nat64_uninit(const void *arg __unused) | vnet_ipfw_nat64_uninit(const void *arg __unused) | ||||
{ | { | ||||
struct ip_fw_chain *ch; | struct ip_fw_chain *ch; | ||||
int last; | int last; | ||||
ch = &V_layer3_chain; | ch = &V_layer3_chain; | ||||
last = IS_DEFAULT_VNET(curvnet) ? 1: 0; | last = IS_DEFAULT_VNET(curvnet) ? 1: 0; | ||||
nat64stl_uninit(ch, last); | nat64stl_uninit(ch, last); | ||||
nat64clat_uninit(ch, last); | |||||
nat64lsn_uninit(ch, last); | nat64lsn_uninit(ch, last); | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
ipfw_nat64_modevent(module_t mod, int type, void *unused) | ipfw_nat64_modevent(module_t mod, int type, void *unused) | ||||
{ | { | ||||
Show All 31 Lines |