Dear Thomas,
definitely a good reason for not unrolling the loop.
Thanks,

        fulvio

On 08/12/2016 15:12, Thomas Graf via iovisor-dev wrote:
On 7 December 2016 at 22:06, Mauricio Vasquez via iovisor-dev
<[email protected]> wrote:
BPF_TABLE("array", u32, struct rt_entry, routing_table, ROUTING_TABLE_DIM);

static int handle_rx(void *skb, struct metadata *md) {
  u8 *cursor = 0;
  struct ip_t *ip = cursor_advance(cursor, sizeof(*ip));

  int i = 0;
  struct rt_entry *rt_entry_p = 0;
  u32 ip_dst_masked = 0;

  //#pragma unroll
  #pragma clang loop unroll(full)
  for (i = 0; i < ROUTING_TABLE_DIM; i++) {
    rt_entry_p = routing_table.lookup(&i);

Might be because you pass a pointer here?

    if (rt_entry_p) {
      ip_dst_masked = ip->dst & rt_entry_p->netmask;
      if (ip_dst_masked == rt_entry_p->network) {
        goto FORWARD;
      }
    }
  }

DROP:
  return RX_DROP;

FORWARD:
  pkt_redirect(skb,md, rt_entry_p->port);
  return RX_REDIRECT;
}

Do you have any idea why clang is not unrolling that loop?

It is working fine for us here and we're just using the standard unroll pragma:
https://github.com/cilium/cilium/blob/master/bpf/lib/l3.h#L131
_______________________________________________
iovisor-dev mailing list
[email protected]
https://lists.iovisor.org/mailman/listinfo/iovisor-dev

_______________________________________________
iovisor-dev mailing list
[email protected]
https://lists.iovisor.org/mailman/listinfo/iovisor-dev

Reply via email to