Skip to content

Commit

Permalink
lb: Use more neutral terminology
Browse files Browse the repository at this point in the history
This commit replaces "svc master" by "svc frontend" and "slave" by
"backend slot".

Signed-off-by: Martynas Pumputis <m@lambda.lt>
  • Loading branch information
brb authored and qmonnet committed Jul 15, 2020
1 parent 5445f02 commit 308d67f
Show file tree
Hide file tree
Showing 12 changed files with 152 additions and 152 deletions.
24 changes: 12 additions & 12 deletions bpf/bpf_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ static __always_inline int __sock4_xlate_fwd(struct bpf_sock_addr *ctx,
.address = ctx->user_ip4,
.dport = ctx_dst_port(ctx),
}, orig_key = key;
struct lb4_service *slave_svc;
struct lb4_service *backend_slot;
bool backend_from_affinity = false;
__u32 backend_id = 0;

Expand Down Expand Up @@ -323,14 +323,14 @@ static __always_inline int __sock4_xlate_fwd(struct bpf_sock_addr *ctx,
if (backend_id == 0) {
backend_from_affinity = false;

key.slave = (sock_local_cookie(ctx_full) % svc->count) + 1;
slave_svc = __lb4_lookup_slave(&key);
if (!slave_svc) {
update_metrics(0, METRIC_EGRESS, REASON_LB_NO_SLAVE);
key.backend_slot = (sock_local_cookie(ctx_full) % svc->count) + 1;
backend_slot = __lb4_lookup_backend_slot(&key);
if (!backend_slot) {
update_metrics(0, METRIC_EGRESS, REASON_LB_NO_BACKEND_SLOT);
return -ENOENT;
}

backend_id = slave_svc->backend_id;
backend_id = backend_slot->backend_id;
backend = __lb4_lookup_backend(backend_id);
}

Expand Down Expand Up @@ -712,7 +712,7 @@ static __always_inline int __sock6_xlate_fwd(struct bpf_sock_addr *ctx,
struct lb6_key key = {
.dport = ctx_dst_port(ctx),
}, orig_key;
struct lb6_service *slave_svc;
struct lb6_service *backend_slot;
bool backend_from_affinity = false;
__u32 backend_id = 0;

Expand Down Expand Up @@ -745,14 +745,14 @@ static __always_inline int __sock6_xlate_fwd(struct bpf_sock_addr *ctx,
if (backend_id == 0) {
backend_from_affinity = false;

key.slave = (sock_local_cookie(ctx) % svc->count) + 1;
slave_svc = __lb6_lookup_slave(&key);
if (!slave_svc) {
update_metrics(0, METRIC_EGRESS, REASON_LB_NO_SLAVE);
key.backend_slot = (sock_local_cookie(ctx) % svc->count) + 1;
backend_slot = __lb6_lookup_backend_slot(&key);
if (!backend_slot) {
update_metrics(0, METRIC_EGRESS, REASON_LB_NO_BACKEND_SLOT);
return -ENOENT;
}

backend_id = slave_svc->backend_id;
backend_id = backend_slot->backend_id;
backend = __lb6_lookup_backend(backend_id);
}

Expand Down
28 changes: 14 additions & 14 deletions bpf/lib/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,13 @@ enum {
* If reason is larger than below then this is a drop reason and
* value corresponds to -(DROP_*), see above.
*/
#define REASON_FORWARDED 0
#define REASON_PLAINTEXT 3
#define REASON_DECRYPT 4
#define REASON_LB_NO_SLAVE 5
#define REASON_LB_NO_BACKEND 6
#define REASON_LB_REVNAT_UPDATE 7
#define REASON_LB_REVNAT_STALE 8
#define REASON_FORWARDED 0
#define REASON_PLAINTEXT 3
#define REASON_DECRYPT 4
#define REASON_LB_NO_BACKEND_SLOT 5
#define REASON_LB_NO_BACKEND 6
#define REASON_LB_REVNAT_UPDATE 7
#define REASON_LB_REVNAT_STALE 8

/* Lookup scope for externalTrafficPolicy=Local */
#define LB_LOOKUP_SCOPE_EXT 0
Expand Down Expand Up @@ -501,7 +501,7 @@ enum {
#define TUPLE_F_OUT 0 /* Outgoing flow */
#define TUPLE_F_IN 1 /* Incoming flow */
#define TUPLE_F_RELATED 2 /* Flow represents related packets */
#define TUPLE_F_SERVICE 4 /* Flow represents service/slave map */
#define TUPLE_F_SERVICE 4 /* Flow represents packets to service */

#define CT_EGRESS 0
#define CT_INGRESS 1
Expand Down Expand Up @@ -600,7 +600,7 @@ struct ct_entry {
struct lb6_key {
union v6addr address; /* Service virtual IPv6 address */
__be16 dport; /* L4 port filter, if unset, all ports apply */
__u16 slave; /* Backend iterator, 0 indicates the master service */
__u16 backend_slot; /* Backend iterator, 0 indicates the svc frontend */
__u8 proto; /* L4 protocol, currently not used (set to 0) */
__u8 scope; /* LB_LOOKUP_SCOPE_* for externalTrafficPolicy=Local */
__u8 pad[2];
Expand All @@ -610,7 +610,7 @@ struct lb6_key {
struct lb6_service {
union {
__u32 backend_id; /* Backend ID in lb6_backends */
__u32 affinity_timeout; /* In seconds, only for master svc */
__u32 affinity_timeout; /* In seconds, only for svc frontend */
};
__u16 count;
__u16 rev_nat_index;
Expand Down Expand Up @@ -647,7 +647,7 @@ struct ipv6_revnat_entry {
struct lb4_key {
__be32 address; /* Service virtual IPv4 address */
__be16 dport; /* L4 port filter, if unset, all ports apply */
__u16 slave; /* Backend iterator, 0 indicates the master service */
__u16 backend_slot; /* Backend iterator, 0 indicates the svc frontend */
__u8 proto; /* L4 protocol, currently not used (set to 0) */
__u8 scope; /* LB_LOOKUP_SCOPE_* for externalTrafficPolicy=Local */
__u8 pad[2];
Expand All @@ -656,10 +656,10 @@ struct lb4_key {
struct lb4_service {
union {
__u32 backend_id; /* Backend ID in lb4_backends */
__u32 affinity_timeout; /* In seconds, only for master svc */
__u32 affinity_timeout; /* In seconds, only for svc frontend */
};
/* For the master service, count denotes number of service endpoints.
* For service endpoints, zero. (Previously, legacy service ID)
/* For the service frontend, count denotes number of service backend
* slots (otherwise zero).
*/
__u16 count;
__u16 rev_nat_index; /* Reverse NAT ID in lb4_reverse_nat */
Expand Down
22 changes: 11 additions & 11 deletions bpf/lib/dbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,26 @@ enum {
DBG_TO_HOST,
DBG_TO_STACK,
DBG_PKT_HASH,
DBG_LB6_LOOKUP_MASTER,
DBG_LB6_LOOKUP_MASTER_FAIL,
DBG_LB6_LOOKUP_SLAVE,
DBG_LB6_LOOKUP_SLAVE_SUCCESS,
DBG_LB6_LOOKUP_SLAVE_V2_FAIL,
DBG_LB6_LOOKUP_FRONTEND,
DBG_LB6_LOOKUP_FRONTEND_FAIL,
DBG_LB6_LOOKUP_BACKEND_SLOT,
DBG_LB6_LOOKUP_BACKEND_SLOT_SUCCESS,
DBG_LB6_LOOKUP_BACKEND_SLOT_V2_FAIL,
DBG_LB6_LOOKUP_BACKEND_FAIL,
DBG_LB6_REVERSE_NAT_LOOKUP,
DBG_LB6_REVERSE_NAT,
DBG_LB4_LOOKUP_MASTER,
DBG_LB4_LOOKUP_MASTER_FAIL,
DBG_LB4_LOOKUP_SLAVE,
DBG_LB4_LOOKUP_SLAVE_SUCCESS,
DBG_LB4_LOOKUP_SLAVE_V2_FAIL,
DBG_LB4_LOOKUP_FRONTEND,
DBG_LB4_LOOKUP_FRONTEND_FAIL,
DBG_LB4_LOOKUP_BACKEND_SLOT,
DBG_LB4_LOOKUP_BACKEND_SLOT_SUCCESS,
DBG_LB4_LOOKUP_BACKEND_SLOT_V2_FAIL,
DBG_LB4_LOOKUP_BACKEND_FAIL,
DBG_LB4_REVERSE_NAT_LOOKUP,
DBG_LB4_REVERSE_NAT,
DBG_LB4_LOOPBACK_SNAT,
DBG_LB4_LOOPBACK_SNAT_REV,
DBG_CT_LOOKUP4,
DBG_RR_SLAVE_SEL,
DBG_RR_BACKEND_SLOT_SEL,
DBG_REV_PROXY_LOOKUP,
DBG_REV_PROXY_FOUND,
DBG_REV_PROXY_UPDATE,
Expand Down

0 comments on commit 308d67f

Please sign in to comment.