* Johannes Berg <[EMAIL PROTECTED]> 2006-09-14 11:21 > On Thu, 2006-09-14 at 10:14 +0200, Thomas Graf wrote: > > > Looks good, we have to watch the size of struct nla_policy though. > > This bumps the size from 4 bytes to 16 bytes on 64bit architectures > > which might become a problem since we always use ATTR_MAX sized > > arrays. > > Yes, I'm aware of that, but I couldn't think of a way to handle it well. > > I thought about using a second array containing just the check > functions, and then (ab)using `len' to index into it but that didn't > seem clean enough.
I agree, I talked about this with various people and some ideas came up. Always use function pointers to define the validation policy, i.e. there would be nla_validate_u32() etc. The problem with this approach is that for every string attribute with different length a separate validation function is required which simply adds to code what it saved from text. It also makes exporting the policy to userspace impossible. Following up on your idea, we could save a bit by using ERR_PTR() to store both the callback pointer and type/len tuple in the very same pointer but that gets very ugly. I think its best to use your patch for now and see where this leads to. - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html