@@ -245,6 +245,26 @@ int pcn_pkt_controller_with_metadata(struct CTXTYPE *skb,
245245 skb->cb[4] = metadata[2];
246246 return pcn_pkt_controller(skb, md, reason);
247247}
248+
249+ static __always_inline
250+ void call_ingress_program_with_metadata(struct CTXTYPE *skb,
251+ struct pkt_metadata *md, int index) {
252+ // Save the traffic class for the next program in case it was changed
253+ // by the current one
254+ skb->mark = md->traffic_class;
255+
256+ call_ingress_program(skb, index);
257+ }
258+
259+ static __always_inline
260+ void call_egress_program_with_metadata(struct CTXTYPE *skb,
261+ struct pkt_metadata *md, int index) {
262+ // Save the traffic class for the next program in case it was changed
263+ // by the current one
264+ skb->mark = md->traffic_class;
265+
266+ call_egress_program(skb, index);
267+ }
248268)" ;
249269
250270const std::string CubeTC::CUBETC_HELPERS = R"(
@@ -327,6 +347,7 @@ int handle_rx_wrapper(struct CTXTYPE *skb) {
327347 md.in_port = x >> 16;
328348 md.cube_id = CUBE_ID;
329349 md.packet_len = skb->len;
350+ md.traffic_class = skb->mark;
330351 skb->cb[0] = md.in_port << 16 | CUBE_ID;
331352
332353 // Check if the cube is shadow and the in_port has odd index
@@ -343,6 +364,10 @@ int handle_rx_wrapper(struct CTXTYPE *skb) {
343364
344365 int rc = handle_rx(skb, &md);
345366
367+ // Save the traffic class for the next program in case it was changed
368+ // by the current one
369+ skb->mark = md.traffic_class;
370+
346371 switch (rc) {
347372 case RX_REDIRECT:
348373 // FIXME: reason is right, we are reusing the field
0 commit comments