Re: RFC: New BGF 'LOOP' instruction

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Paul LeoNerd Evans
Date: Tuesday, August 3, 2010 - 7:34 am

On Tue, Aug 03, 2010 at 03:11:10PM +0100, Paul LeoNerd Evans wrote:

Of course, I completely forgot about finding also the offset of the
'next header' from the current header. That results in some code which,
in C, would look like:

  int hdrtype = b[IPv6_nexthdr];

  int x = size_of_IPv6_header;

  while(hdrtype != hdr_wanted) {
       int len;
       switch(hdrtype) {
         case 1:
           len = someconst;
           hdrtype = someotherconst;
           break;
         case 2:
           len = b[x+someoffs];
           hdrtype = b[x+someotheroffs];
           break;
         /* other IPv6 header types here */
       }

       x += len;
  }

You can't compile that idea into BPF without using a scratch memory
cell, because you can't have both 'len' and 'hdrtype' live in A at the
same time, nor can you atomically x += b[x+someoffs].

In short, much much easier if the C code did this part...

-- 
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk
ICQ# 4135350       |  Registered Linux# 179460
http://www.leonerd.org.uk/
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
RFC: New BGF 'LOOP' instruction, Paul LeoNerd Evans, (Mon Aug 2, 4:03 am)
Re: RFC: New BPF 'LOOP' instruction, Paul LeoNerd Evans, (Mon Aug 2, 4:13 am)
Re: RFC: New BGF 'LOOP' instruction, Hagen Paul Pfeifer, (Mon Aug 2, 1:16 pm)
Re: RFC: New BGF 'LOOP' instruction, David Miller, (Mon Aug 2, 10:13 pm)
Re: RFC: New BGF 'LOOP' instruction, David Miller, (Mon Aug 2, 10:18 pm)
Re: RFC: New BGF 'LOOP' instruction, Paul LeoNerd Evans, (Tue Aug 3, 12:04 am)
Re: RFC: New BGF 'LOOP' instruction, Paul LeoNerd Evans, (Tue Aug 3, 12:07 am)
Re: RFC: New BPF 'LOOP' instruction, Paul LeoNerd Evans, (Tue Aug 3, 12:18 am)
Re: RFC: New BGF 'LOOP' instruction, David Miller, (Tue Aug 3, 12:18 am)
Re: RFC: New BGF 'LOOP' instruction, David Miller, (Tue Aug 3, 12:19 am)
Re: RFC: New BGF 'LOOP' instruction, Hagen Paul Pfeifer, (Tue Aug 3, 2:03 am)
Re: RFC: New BGF 'LOOP' instruction, Hagen Paul Pfeifer, (Tue Aug 3, 2:10 am)
Re: RFC: New BGF 'LOOP' instruction, Andi Kleen, (Tue Aug 3, 5:58 am)
Re: RFC: New BGF 'LOOP' instruction, David Miller, (Tue Aug 3, 6:07 am)
Re: RFC: New BPF 'LOOP' instruction, Paul LeoNerd Evans, (Tue Aug 3, 6:34 am)
Re: RFC: New BGF 'LOOP' instruction, Paul LeoNerd Evans, (Tue Aug 3, 6:40 am)
Re: RFC: New BPF 'LOOP' instruction, Paul LeoNerd Evans, (Tue Aug 3, 6:42 am)
Re: RFC: New BGF 'LOOP' instruction, Andi Kleen, (Tue Aug 3, 7:05 am)
Re: RFC: New BPF 'LOOP' instruction, Rémi Denis-Courmont, (Tue Aug 3, 7:09 am)
Re: RFC: New BGF 'LOOP' instruction, Paul LeoNerd Evans, (Tue Aug 3, 7:11 am)
Re: RFC: New BPF 'LOOP' instruction, Paul LeoNerd Evans, (Tue Aug 3, 7:13 am)
Re: RFC: New BPF 'LOOP' instruction, Rémi Denis-Courmont, (Tue Aug 3, 7:16 am)
Re: RFC: New BPF 'LOOP' instruction, Paul LeoNerd Evans, (Tue Aug 3, 7:19 am)
Re: RFC: New BGF 'LOOP' instruction, Paul LeoNerd Evans, (Tue Aug 3, 7:34 am)
Re: RFC: New BPF 'LOOP' instruction, =?iso-8859-15?q?R=E9 ..., (Tue Aug 3, 8:17 am)
Re: RFC: New BPF 'LOOP' instruction, Paul LeoNerd Evans, (Tue Aug 3, 8:27 am)