Skip to contentSkip to conversation

Simple coding question...

DISCUSSION Torsten Luettgert 2 participants 2 messages Jan 15, 2006 – Jan 21, 2006 netfilter

lore
Share & tools
lore
#0 lore raw

Hello,

recently I studied the MARK and CLASSIFY targets and found these lines doing the actual changes:

   if((*pskb)->nfmark != markinfo->mark)
      (*pskb)->nfmark = markinfo->mark;

   if((*pskb)->priority != clinfo->priority)
      (*pskb)->priority = clinfo->priority;

Is there a reason the value is always checked first? Why not just write

   (*pskb)->something = my_value;

and save a few cycles? I'm just curious.

Greetings,
Torsten

#1 lore raw
Quoted 5 lines · Torsten Luettgert

Hello,

recently I studied the MARK and CLASSIFY targets and found these lines doing the actual changes:

Quoted 7 lines
   if((*pskb)->nfmark != markinfo->mark)
      (*pskb)->nfmark = markinfo->mark;

   if((*pskb)->priority != clinfo->priority)
      (*pskb)->priority = clinfo->priority;

Is there a reason the value is always checked first?

I cannot really comment, but I guess that it is done because reding data is cheaper than writing. When you write, you invalidate that cahce line on all other cpus.

However, since it's unlikely that processing of the same s kb moves from one cpu to the other, I think that reason is void, too.

Signature · 5 lines
- Harald Welte <[email protected]>                 http://netfilter.org/
============================================================================
  "Fragmentation is like classful addressing -- an interesting early
   architectural error that shows how much experimentation was going
   on while IP was being designed."                    -- Paul Vixie