Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backport: 1.4 backports 18-12-19 #6479

Merged
merged 33 commits into from
Dec 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d1f1238
agent: Universal --enable-ipv4 and --enable-ipv6 option
tgraf Dec 16, 2018
caee067
ipam: Allow disabling IPv6 in node addressing API
tgraf Dec 16, 2018
9b6b4d3
docker: Only install routes if address family is enabled
tgraf Dec 16, 2018
b821837
docker: Remove the unneeded EndpointGet check
tgraf Dec 16, 2018
aaa2ce6
cni: Do not require IPv6 addressing information to be present
tgraf Dec 16, 2018
8ad6d91
agent: Make IPv6 optional
tgraf Dec 16, 2018
b4c959e
agent: Fail if both IPv4 and IPv6 are disabled
tgraf Dec 16, 2018
83456dc
agent: Remove BPF maps of disabled address families
tgraf Dec 16, 2018
50d0c51
kubernetes: Disable IPv6 by default for new deployments
tgraf Dec 16, 2018
288d583
policy: cache whether all L3 is allowed in L4 filter
Dec 10, 2018
2d9d690
examples/kubernetes: bump cilium-etcd-operator to v2.0.3
aanm Dec 11, 2018
23b5b4a
pkg/bpf: Use os.PathError errors in map functions
joestringer Dec 11, 2018
6c12b96
pkg/bpf: Add unit test for Map.Open
joestringer Dec 11, 2018
efa703a
endpoint: Quieten CT garbage collection warnings
joestringer Dec 11, 2018
907ddfc
pkg/fqdn: Extract lowest TTL from DNS messages
raybejjani Dec 12, 2018
32d427b
test: use `cilium identity list` for policy trace test
Dec 14, 2018
d53a1ac
Disable broken sphinx-version-warning
tgraf Dec 16, 2018
3021996
endpoint: Limit the number of local endpoints to 4K
tgraf Dec 17, 2018
43499db
idpool: Do not preallocate unnecessary leasing space
tgraf Dec 17, 2018
79018c6
monitor: Initialize gopacket parser on demand
tgraf Dec 17, 2018
ee117c9
agent: Change monitor queue size default
tgraf Dec 17, 2018
3ccbf16
identity: Reduce the size of the identity event queue
tgraf Dec 17, 2018
5b0b3b8
pkg/fqdn: Track emitted IPs in cache only
raybejjani Dec 17, 2018
dc0104e
etcd: Increase initial connection timeout to 15 minutes
tgraf Dec 18, 2018
e18213d
bpf: pin endpoint configuration map
Dec 19, 2018
fc21c7b
endpoint: add {desired,realized}Policy fields
Nov 30, 2018
4d28300
policy: remove L4Filter parameter from ToKeys function
Dec 7, 2018
8e689a1
endpoint: remove redundant non-nil check
Dec 7, 2018
07cd0f4
endpoint: remove unused functions
Dec 7, 2018
0710ac5
endpoint: remove unnecessary setting of pointers
Dec 10, 2018
639469e
policy: hide realization of desired state in function
Dec 10, 2018
8f3f7c2
policy: add sets of denied ingress / egress identities to Policy stru…
Nov 30, 2018
397318c
policy: add means of short-circuiting L4 requirements computation unt…
Dec 4, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion Documentation/cmdref/cilium-agent.md
Expand Up @@ -37,9 +37,10 @@ cilium-agent
-d, --device string Device facing cluster/external network for direct L3 (non-overlay mode) (default "undefined")
--disable-conntrack Disable connection tracking
--disable-endpoint-crd Disable use of CiliumEndpoint CRD
--disable-ipv4 Disable IPv4 mode
--disable-k8s-services Disable east-west K8s load balancing by cilium
-e, --docker string Path to docker runtime socket (DEPRECATED: use container-runtime-endpoint instead) (default "unix:///var/run/docker.sock")
--enable-ipv4 Enable IPv4 support (default true)
--enable-ipv6 Enable IPv6 support (default true)
--enable-policy string Enable policy enforcement (default "default")
--enable-tracing Enable tracing while determining policy (debugging)
--envoy-log string Path to a separate Envoy log file, if any
Expand Down Expand Up @@ -77,6 +78,7 @@ cilium-agent
--logstash-probe-timer uint32 Logstash probe timer (seconds) (default 10)
--masquerade Masquerade packets from endpoints leaving the host (default true)
--monitor-aggregation string Level of monitor aggregation for traces from the datapath (default "None")
--monitor-queue-size int Size of the event queue when reading monitor events (default 32768)
--mtu int Overwrite auto-detected MTU of underlying network (default 1500)
--nat46-range string IPv6 prefix to map IPv4 addresses to (default "0:0:0:0:0:FFFF::/96")
--pprof Enable serving the pprof debugging API
Expand Down
2 changes: 1 addition & 1 deletion Documentation/concepts.rst
Expand Up @@ -265,7 +265,7 @@ without causing any conflicts.

The default behavior of Cilium is to assign both an IPv6 and IPv4 address to
every endpoint. However, this behavior can be configured to only allocate an
IPv6 address with the ``--disable-ipv4`` option. If both an IPv6 and IPv4
IPv6 address with the ``--enable-ipv4=false`` option. If both an IPv6 and IPv4
address are assigned, either address can be used to reach the endpoint. The
same behavior will apply with regard to policy rules, load-balancing, etc. See
:ref:`address_management` for more details.
Expand Down
4 changes: 2 additions & 2 deletions Documentation/conf.py
Expand Up @@ -37,8 +37,8 @@
'sphinx.ext.extlinks',
'sphinxcontrib.openapi',
'sphinx_tabs.tabs',
'sphinxcontrib.spelling',
'versionwarning.extension' ]
'sphinxcontrib.spelling']
# 'versionwarning.extension' ] <--- build is currently broken, see GH-6460

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand Down
6 changes: 4 additions & 2 deletions Documentation/kubernetes/install/standard.rst
Expand Up @@ -234,7 +234,9 @@ accordingly with your changes.
* ``debug`` - Sets to run Cilium in full debug mode, it can be changed at
runtime;

* ``disable-ipv4`` - Disables IPv4 in Cilium and endpoints managed by Cilium;
* ``enable-ipv4`` - Enable IPv4 addressing support

* ``enable-ipv6`` - Enable IPv6 addressing support

* ``clean-cilium-state`` - Removes any Cilium state, e.g. BPF policy maps,
before starting the Cilium agent;
Expand Down Expand Up @@ -279,7 +281,7 @@ enabled.

# If you want to run cilium in debug mode change this value to true
debug: "false"
disable-ipv4: "false"
enable-ipv4: "true"
# If you want to clean cilium state; change this value to true
clean-cilium-state: "false"
legacy-host-allows-world: "false"
Expand Down
12 changes: 10 additions & 2 deletions bpf/Makefile
Expand Up @@ -23,7 +23,11 @@ LB_OPTIONS = \
-DSKIP_DEBUG \
-DLB_L3 \
-DLB_L4 \
-DLB_L3 -DLB_L4
"-DLB_L3 -DLB_L4" \
"-DENABLE_IPV4 -DLB_L3 -DLB_L4" \
"-DENABLE_IPV6 -DLB_L3 -DLB_L4" \
"-DENABLE_IPV4 -DENABLE_IPV6 -DLB_L3 -DLB_L4"


bpf_lb.ll: bpf_lb.c $(LIB)
$(QUIET) set -e; \
Expand All @@ -41,7 +45,11 @@ bpf_lb.o: bpf_lb.ll
LXC_OPTIONS = \
-DSKIP_DEBUG \
-DHAVE_LPM_MAP_TYPE \
-DHAVE_LRU_MAP_TYPE
-DHAVE_LRU_MAP_TYPE \
-DENABLE_IPV4 \
-DENABLE_IPV6 \
"-DENABLE_IPV6 -DENABLE_IPV4" \
"-DENABLE_IPV4 -DENABLE_NAT46"

bpf_lxc.ll: bpf_lxc.c $(LIB)
$(QUIET) set -e; \
Expand Down
14 changes: 6 additions & 8 deletions bpf/bpf_lb.c
Expand Up @@ -27,8 +27,6 @@
* then passed back to the stack.
*
* Configuration:
* - LB_DISABLE_IPV4 - Ignore IPv4 packets
* - LB_DISABLE_IPV6 - Ignore IPv6 packets
* - LB_REDIRECT - Redirect to an ifindex
* - LB_L4 - Enable L4 matching and mapping
*/
Expand All @@ -54,7 +52,7 @@
#include "lib/drop.h"
#include "lib/lb.h"

#ifndef LB_DISABLE_IPV6
#ifdef ENABLE_IPV6
static inline int handle_ipv6(struct __sk_buff *skb)
{
void *data, *data_end;
Expand Down Expand Up @@ -113,9 +111,9 @@ static inline int handle_ipv6(struct __sk_buff *skb)

return TC_ACT_REDIRECT;
}
#endif
#endif /* ENABLE_IPV6 */

#ifndef LB_DISABLE_IPV4
#ifdef ENABLE_IPV4
static inline int handle_ipv4(struct __sk_buff *skb)
{
void *data;
Expand Down Expand Up @@ -168,7 +166,7 @@ static inline int handle_ipv4(struct __sk_buff *skb)

return TC_ACT_REDIRECT;
}
#endif
#endif /* ENABLE_IPV4 */

__section("from-netdev")
int from_netdev(struct __sk_buff *skb)
Expand All @@ -178,13 +176,13 @@ int from_netdev(struct __sk_buff *skb)
bpf_clear_cb(skb);

switch (skb->protocol) {
#ifndef LB_DISABLE_IPV6
#ifdef ENABLE_IPV6
case bpf_htons(ETH_P_IPV6):
ret = handle_ipv6(skb);
break;
#endif

#ifndef LB_DISABLE_IPV4
#ifdef ENABLE_IPV4
case bpf_htons(ETH_P_IP):
ret = handle_ipv4(skb);
break;
Expand Down
58 changes: 35 additions & 23 deletions bpf/bpf_lxc.c
Expand Up @@ -56,6 +56,7 @@
#define CT_MAP_TYPE BPF_MAP_TYPE_HASH
#endif

#ifdef ENABLE_IPV6
struct bpf_elf_map __section_maps CT_MAP_TCP6 = {
.type = CT_MAP_TYPE,
.size_key = sizeof(struct ipv6_ct_tuple),
Expand All @@ -72,6 +73,17 @@ struct bpf_elf_map __section_maps CT_MAP_ANY6 = {
.max_elem = CT_MAP_SIZE_ANY,
};

static inline struct bpf_elf_map *
get_ct_map6(struct ipv6_ct_tuple *tuple)
{
if (tuple->nexthdr == IPPROTO_TCP) {
return &CT_MAP_TCP6;
}
return &CT_MAP_ANY6;
}
#endif

#ifdef ENABLE_IPV4
struct bpf_elf_map __section_maps CT_MAP_TCP4 = {
.type = CT_MAP_TYPE,
.size_key = sizeof(struct ipv4_ct_tuple),
Expand All @@ -88,15 +100,6 @@ struct bpf_elf_map __section_maps CT_MAP_ANY4 = {
.max_elem = CT_MAP_SIZE_ANY,
};

static inline struct bpf_elf_map *
get_ct_map6(struct ipv6_ct_tuple *tuple)
{
if (tuple->nexthdr == IPPROTO_TCP) {
return &CT_MAP_TCP6;
}
return &CT_MAP_ANY6;
}

static inline struct bpf_elf_map *
get_ct_map4(struct ipv4_ct_tuple *tuple)
{
Expand All @@ -105,12 +108,16 @@ get_ct_map4(struct ipv4_ct_tuple *tuple)
}
return &CT_MAP_ANY4;
}
#endif

#if defined ENABLE_IPV4 || defined ENABLE_IPV6
static inline bool redirect_to_proxy(int verdict, int dir)
{
return verdict > 0 && (dir == CT_NEW || dir == CT_ESTABLISHED);
}
#endif

#ifdef ENABLE_IPV6
static inline int ipv6_l3_from_lxc(struct __sk_buff *skb,
struct ipv6_ct_tuple *tuple, int l3_off,
struct ipv6hdr *ip6, __u32 *dstID)
Expand Down Expand Up @@ -339,7 +346,7 @@ static inline int ipv6_l3_from_lxc(struct __sk_buff *skb,
}
#endif

#ifdef LXC_NAT46
#ifdef ENABLE_NAT46
if (unlikely(ipv6_addr_is_mapped(daddr))) {
ep_tail_call(skb, CILIUM_CALL_NAT64);
return DROP_MISSED_TAIL_CALL;
Expand Down Expand Up @@ -423,9 +430,9 @@ __section_tail(CILIUM_MAP_CALLS, CILIUM_CALL_IPV6_FROM_LXC) int tail_handle_ipv6

return ret;
}
#endif /* ENABLE_IPV6 */

#ifdef LXC_IPV4

#ifdef ENABLE_IPV4
static inline int handle_ipv4_from_lxc(struct __sk_buff *skb, __u32 *dstID)
{
struct ipv4_ct_tuple tuple = {};
Expand Down Expand Up @@ -465,14 +472,13 @@ static inline int handle_ipv4_from_lxc(struct __sk_buff *skb, __u32 *dstID)
}

ct_state_new.orig_dport = key.dport;
#ifdef ENABLE_IPV4
if ((svc = lb4_lookup_service(skb, &key)) != NULL) {
ret = lb4_local(get_ct_map4(&tuple), skb, l3_off, l4_off, &csum_off,
&key, &tuple, svc, &ct_state_new, ip4->saddr);
if (IS_ERR(ret))
return ret;
}
#endif

skip_service_lookup:
/* The verifier wants to see this assignment here in case the above goto
* skip_service_lookup is hit. However, in the case the packet
Expand Down Expand Up @@ -684,8 +690,6 @@ __section_tail(CILIUM_MAP_CALLS, CILIUM_CALL_IPV4_FROM_LXC) int tail_handle_ipv4
return ret;
}

#endif

/*
* ARP responder for ARP requests from container
* Respond to IPV4_GATEWAY with NODE_MAC
Expand All @@ -695,6 +699,7 @@ __section_tail(CILIUM_MAP_CALLS, CILIUM_CALL_ARP) int tail_handle_arp(struct __s
union macaddr mac = NODE_MAC;
return arp_respond(skb, &mac);
}
#endif /* ENABLE_IPV4 */

__section("from-container")
int handle_ingress(struct __sk_buff *skb)
Expand All @@ -707,11 +712,14 @@ int handle_ingress(struct __sk_buff *skb)
TRACE_PAYLOAD_LEN);

switch (skb->protocol) {
#ifdef ENABLE_IPV6
case bpf_htons(ETH_P_IPV6):
ep_tail_call(skb, CILIUM_CALL_IPV6_FROM_LXC);
ret = DROP_MISSED_TAIL_CALL;
break;
#endif

#ifdef ENABLE_IPV4
case bpf_htons(ETH_P_IP):
ep_tail_call(skb, CILIUM_CALL_IPV4_FROM_LXC);
ret = DROP_MISSED_TAIL_CALL;
Expand All @@ -721,6 +729,7 @@ int handle_ingress(struct __sk_buff *skb)
ep_tail_call(skb, CILIUM_CALL_ARP);
ret = DROP_MISSED_TAIL_CALL;
break;
#endif

default:
ret = DROP_UNKNOWN_L3;
Expand All @@ -732,6 +741,7 @@ int handle_ingress(struct __sk_buff *skb)
return ret;
}

#ifdef ENABLE_IPV6
static inline int __inline__
ipv6_policy(struct __sk_buff *skb, int ifindex, __u32 src_label, int *forwarding_reason, struct ep_config *cfg)
{
Expand Down Expand Up @@ -884,8 +894,9 @@ __section_tail(CILIUM_MAP_CALLS, CILIUM_CALL_IPV6_TO_LXC) int tail_ipv6_policy(s

return ret;
}
#endif /* ENABLE_IPV6 */

#ifdef LXC_IPV4
#ifdef ENABLE_IPV4
static inline int __inline__
ipv4_policy(struct __sk_buff *skb, int ifindex, __u32 src_label, int *forwarding_reason, struct ep_config *cfg)
{
Expand Down Expand Up @@ -927,7 +938,7 @@ ipv4_policy(struct __sk_buff *skb, int ifindex, __u32 src_label, int *forwarding

*forwarding_reason = ret;

#ifdef LXC_NAT46
#ifdef ENABLE_NAT46
if (skb->cb[CB_NAT46_STATE] == NAT46) {
ep_tail_call(skb, CILIUM_CALL_NAT46);
return DROP_MISSED_TAIL_CALL;
Expand Down Expand Up @@ -1025,8 +1036,7 @@ __section_tail(CILIUM_MAP_CALLS, CILIUM_CALL_IPV4_TO_LXC) int tail_ipv4_policy(s

return ret;
}

#endif
#endif /* ENABLE_IPV4 */

/* Handle policy decisions as the packet makes its way towards the endpoint.
* Previously, the packet may have come from another local endpoint, another
Expand All @@ -1041,17 +1051,19 @@ __section_tail(CILIUM_MAP_POLICY, LXC_ID) int handle_policy(struct __sk_buff *sk
__u32 src_label = skb->cb[CB_SRC_LABEL];

switch (skb->protocol) {
#ifdef ENABLE_IPV6
case bpf_htons(ETH_P_IPV6):
ep_tail_call(skb, CILIUM_CALL_IPV6_TO_LXC);
ret = DROP_MISSED_TAIL_CALL;
break;
#endif /* ENABLE_IPV6 */

#ifdef LXC_IPV4
#ifdef ENABLE_IPV4
case bpf_htons(ETH_P_IP):
ep_tail_call(skb, CILIUM_CALL_IPV4_TO_LXC);
ret = DROP_MISSED_TAIL_CALL;
break;
#endif
#endif /* ENABLE_IPV4 */

default:
ret = DROP_UNKNOWN_L3;
Expand All @@ -1065,7 +1077,7 @@ __section_tail(CILIUM_MAP_POLICY, LXC_ID) int handle_policy(struct __sk_buff *sk
return ret;
}

#ifdef LXC_NAT46
#ifdef ENABLE_NAT46
__section_tail(CILIUM_MAP_CALLS, CILIUM_CALL_NAT64) int tail_ipv6_to_ipv4(struct __sk_buff *skb)
{
int ret = ipv6_to_ipv4(skb, 14, LXC_IPV4);
Expand Down