Skip to content

Commit 9f7b668

Browse files
committed
implement review comments
1 parent 61a65f9 commit 9f7b668

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

upf/flowtable.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ typedef struct flow_entry
186186
u8 tcp_state : 4; // TODO: needs only 3 bits?
187187
// should be updated in classify and based on PDR during flow creation
188188
u8 uplink_direction : 2;
189-
// do not need to perform ipfix operations for this flow anymore
189+
// do not perform ipfix operations for this flow anymore
190190
u8 ipfix_disabled : 1;
191191

192192
// use macro since unsigned will not expand to ~0

upf/upf_classify.c

+3-9
Original file line numberDiff line numberDiff line change
@@ -432,15 +432,13 @@ upf_acl_classify_return (vlib_main_t *vm, u32 teid, flow_entry_t *flow,
432432
// if impossible to detect
433433
always_inline flow_direction_t
434434
upf_classify_detect_flow_direction (vlib_buffer_t *b, struct rules *r,
435-
flow_direction_t direction, bool *found)
435+
flow_direction_t direction)
436436
{
437437
// Here we rely on the fact that interface of type ACCESS is one which
438438
// directed to UE
439439
// TODO: it should be possible to calculate and save this value per PDR
440440
// during session creation/modification
441441

442-
*found = false;
443-
444442
u32 pdr_idx = upf_buffer_opaque (b)->gtpu.pdr_idx;
445443
if (pdr_idx == ~0)
446444
{
@@ -460,7 +458,6 @@ upf_classify_detect_flow_direction (vlib_buffer_t *b, struct rules *r,
460458
upf_debug ("detected uplink direction from pdr: %d matched on %v",
461459
FTD_OP_SAME ^ direction,
462460
pool_elt_at_index (upf_main.nwis, pdr->pdi.nwi_index)->name);
463-
*found = true;
464461
return FTD_OP_SAME ^ direction;
465462
}
466463

@@ -483,7 +480,6 @@ upf_classify_detect_flow_direction (vlib_buffer_t *b, struct rules *r,
483480
"detected uplink direction from far: %d forwarded to %v",
484481
FTD_OP_FLIP ^ direction,
485482
pool_elt_at_index (upf_main.nwis, far->forward.nwi_index)->name);
486-
*found = true;
487483
return FTD_OP_FLIP ^ direction;
488484
}
489485

@@ -619,11 +615,9 @@ upf_classify_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
619615

620616
if (flow->uplink_direction == FLOW_ENTRY_UPLINK_DIRECTION_UNDEFINED)
621617
{
622-
bool found;
623618
flow_direction_t uplink_direction =
624-
upf_classify_detect_flow_direction (b, active, direction,
625-
&found);
626-
if (found)
619+
upf_classify_detect_flow_direction (b, active, direction);
620+
if (uplink_direction != FLOW_ENTRY_UPLINK_DIRECTION_UNDEFINED)
627621
flow->uplink_direction = uplink_direction;
628622
}
629623

upf/upf_ipfix.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,16 @@ upf_ipfix_template_rewrite (ipfix_exporter_t *exp, flow_report_t *fr,
117117
fib_protocol_t fproto =
118118
context->key.is_ip4 ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6;
119119
upf_ipfix_template_t *template = &upf_ipfix_templates[context->key.policy];
120-
upf_ipfix_template_proto_t *ptemplate = &template->per_ip[fproto];
120+
upf_ipfix_template_proto_t *template_proto = &template->per_ip[fproto];
121121

122-
ASSERT (ptemplate->field_count);
122+
ASSERT (template_proto->field_count);
123123

124124
/* allocate rewrite space */
125125

126126
vec_validate_aligned (
127127
rewrite,
128128
sizeof (ip4_ipfix_template_packet_t) +
129-
ptemplate->field_count * sizeof (ipfix_field_specifier_t) - 1,
129+
template_proto->field_count * sizeof (ipfix_field_specifier_t) - 1,
130130
CLIB_CACHE_LINE_BYTES);
131131

132132
tp = (ip4_ipfix_template_packet_t *) rewrite;
@@ -150,7 +150,7 @@ upf_ipfix_template_rewrite (ipfix_exporter_t *exp, flow_report_t *fr,
150150
h->domain_id = clib_host_to_net_u32 (stream->domain_id);
151151

152152
/* Add TLVs to the template */
153-
f = ptemplate->add_fields (f);
153+
f = template_proto->add_fields (f);
154154

155155
/* Back to the template packet... */
156156
ip = (ip4_header_t *) &tp->ip4;
@@ -173,7 +173,7 @@ upf_ipfix_template_rewrite (ipfix_exporter_t *exp, flow_report_t *fr,
173173
vec_len (rewrite));
174174
upf_debug ("n of fields: %u, hdr size %u, part hdr size %u, "
175175
"single field spec len %u",
176-
ptemplate->field_count, sizeof (ip4_ipfix_template_packet_t),
176+
template_proto->field_count, sizeof (ip4_ipfix_template_packet_t),
177177
sizeof (ipfix_template_packet_t),
178178
sizeof (ipfix_field_specifier_t));
179179
ASSERT ((u8 *) f - (u8 *) ip == vec_len (rewrite));

0 commit comments

Comments
 (0)