Skip to content

Commit b13ef0e

Browse files
gentoo-rootpchaigno
authored andcommitted
bpf: Remove unneeded orig_sip from ipv6_host_policy_ingress
There is no need to copy the IPv6 address to a local variable, because the packet data is not going to change. Just use the address from the packet headers directly. Signed-off-by: Maxim Mikityanskiy <[email protected]>
1 parent e4889d7 commit b13ef0e

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

bpf/lib/host_firewall.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ ipv6_host_policy_ingress(struct __ctx_buff *ctx, __u32 *src_id,
100100
struct remote_endpoint_info *info;
101101
int ret, verdict = CTX_ACT_OK, l4_off, hdrlen;
102102
struct ipv6_ct_tuple tuple = {};
103-
union v6addr orig_sip;
104103
void *data, *data_end;
105104
struct ipv6hdr *ip6;
106105
__u16 proxy_port = 0;
@@ -123,7 +122,6 @@ ipv6_host_policy_ingress(struct __ctx_buff *ctx, __u32 *src_id,
123122
/* Lookup connection in conntrack map. */
124123
tuple.nexthdr = ip6->nexthdr;
125124
ipv6_addr_copy(&tuple.saddr, (union v6addr *)&ip6->saddr);
126-
ipv6_addr_copy(&orig_sip, (union v6addr *)&ip6->saddr);
127125
hdrlen = ipv6_hdrlen(ctx, &tuple.nexthdr);
128126
if (hdrlen < 0)
129127
return hdrlen;
@@ -136,11 +134,11 @@ ipv6_host_policy_ingress(struct __ctx_buff *ctx, __u32 *src_id,
136134
trace->reason = (enum trace_reason)ret;
137135

138136
/* Retrieve source identity. */
139-
info = lookup_ip6_remote_endpoint(&orig_sip, 0);
137+
info = lookup_ip6_remote_endpoint((union v6addr *)&ip6->saddr, 0);
140138
if (info && info->sec_label)
141139
*src_id = info->sec_label;
142140
cilium_dbg(ctx, info ? DBG_IP_ID_MAP_SUCCEED6 : DBG_IP_ID_MAP_FAILED6,
143-
orig_sip.p4, *src_id);
141+
ip6->saddr.s6_addr32[3], *src_id);
144142

145143
/* Reply traffic and related are allowed regardless of policy verdict. */
146144
if (ret == CT_REPLY || ret == CT_RELATED)

0 commit comments

Comments
 (0)