On Wed, Mar 18, 2009 at 05:41:43AM +0100, Patrick McHardy wrote: > >This calculation results in no message trim if most of those attributes > >are present. However, assuming the worst case (no counters, no helper, > >no mark, no master tuple, etc.), netlink_trim() may be called. My patch > >calculates the exact size, so there's no trimming for any case. > > The numbers imply that its still a net win. But its a valid point, if > the common case will still result in reallocations, it might make sense > to include the space for a few of those members optionally to make > sure we don't cross the 50% waste threshold. That's a good point. For reference these are the attributes of TCP conntrack event, I have marked the optional NLAs. I don't know what the ratio is in bytes though. CTA_TUPLE_ORIG NLA_F_NESTED CTA_TUPLE_IP NLA_F_NESTED CTA_IP_V4_SRC CTA_IP_V4_DST CTA_TUPLE_PROTO NLA_F_NESTED CTA_PROTO_NUM CTA_PROTO_SRC_PORT CTA_PROTO_DST_PORT CTA_TUPLE_REPLY NLA_F_NESTED CTA_TUPLE_IP NLA_F_NESTED /* ipv6_tuple_to_nl_attr() */ CTA_IP_V4_SRC CTA_IP_V4_DST CTA_TUPLE_PROTO NLA_F_NESTED CTA_PROTO_NUM CTA_PROTO_SRC_PORT CTA_PROTO_DST_PORT CTA_ID CTA_STATUS CTA_COUNTERS_ORIG NLA_F_NESTED optional CTA_COUNTERS_PACKETS CTA_COUNTERS_BYTES CTA_COUNTERS_REPLY NLA_F_NESTED optional CTA_COUNTERS_PACKETS CTA_COUNTERS_BYTES CTA_TIMEOUT CTA_PROTOINFO NLA_F_NESTED CTA_PROTOINFO_TCP NLA_F_NESTED CTA_PROTOINFO_TCP_STATE CTA_PROTOINFO_TCP_WSCALE_ORIGINAL CTA_PROTOINFO_TCP_WSCALE_REPLY CTA_PROTOINFO_TCP_FLAGS_ORIGINAL CTA_PROTOINFO_TCP_FLAGS_REPLY CTA_HELP optional CTA_HELP_NAME CTA_SECMARK optional CTA_TUPLE_MASTER NLA_F_NESTED optional CTA_TUPLE_IP NLA_F_NESTED CTA_IP_V4_SRC CTA_IP_V4_DST CTA_TUPLE_PROTO NLA_F_NESTED CTA_PROTO_NUM CTA_PROTO_SRC_PORT CTA_PROTO_DST_PORT CTA_NAT_SEQ_ADJ_ORIG NLA_F_NESTED optional CTA_NAT_SEQ_CORRECTION_POS CTA_NAT_SEQ_OFFSET_BEFORE CTA_NAT_SEQ_OFFSET_AFTER CTA_NAT_SEQ_ADJ_REPLY NLA_F_NESTED optional CTA_NAT_SEQ_CORRECTION_POS CTA_NAT_SEQ_OFFSET_BEFORE CTA_NAT_SEQ_OFFSET_AFTER CTA_MARK optional -- 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