On Thursday 2010-07-22 17:18, Eric Dumazet wrote: >Le jeudi 22 juillet 2010 à 16:19 +0200, Jan Engelhardt a écrit : >> On Thursday 2010-07-22 16:03, Eric Dumazet wrote: >> >> >This match is a bit strange, being packet content agnostic... >> >+/* >> >+ * Yes, packet content is not interesting for us, we only take care >> >+ * of cpu handling this packet >> >+ */ >> >> That is not so strange after all, we have many packet agnostic matches: >> xt_time, xt_condition, xt_IDLETIMER, xt_iface. >> So this little comment looks a bit redundant. >> >> Or it seems that academia can't come up with enough new protocols in time that >> we have to resort to do -m coffeemaker :) >> >> >@@ -0,0 +1,8 @@ >> >+#ifndef _XT_CPU_H >> >+#define _XT_CPU_H >> >+ >> >+struct xt_cpu_info { >> >+ unsigned int cpu; >> >+ int invert; >> >+}; >> >+#endif /*_XT_MAC_H*/ >> >> Please take a read in "Writing Netfilter Modules" e-book :-) >> It will tell you that types other than fixed ones are a no-no. > >Ok, let's do that, but I doubt sizeof(int) can be different than 4 on a >Linux 2.6 host right now. Never say never. "long" already bit people in the past, and now we have that CONFIG_COMPAT stuff. If invert is the only flag, perhaps it makes sense to use __u8 for it. >I prefer not doing the !!info->invert, and do the check only once. >+static int cpu_mt_check(const struct xt_mtchk_param *par) >+{ >+ const struct xt_cpu_info *info = par->matchinfo; >+ >+ if (info->invert & ~1) >+ return -EINVAL; >+ return 0; >+} >+ >+static bool cpu_mt(const struct sk_buff *skb, struct xt_action_param *par) >+{ >+ const struct xt_cpu_info *info = par->matchinfo; >+ >+ return (info->cpu == smp_processor_id()) ^ info->invert; >+} That works nicely indeed. Do you anticipate any future flags? -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html