Re: [PATCH 5/5] [NETLINK]: Ignore control messages directly in netlink_run_queue()
* Thomas Graf [EMAIL PROTECTED] 2007-03-21 12:45 * Patrick McHardy [EMAIL PROTECTED] 2007-03-21 05:44 This looks like it would break nfnetlink, which appears to be using 0 as smallest message type. It shouldn't do that, the first 16 message types are reserved for control messages. Alright, even though nfnetlink is wrong and buggy we can't break it at this point. Dave, please ignore this last patch for now. - 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
Re: [PATCH 5/5] [NETLINK]: Ignore control messages directly in netlink_run_queue()
Thomas Graf wrote: * Patrick McHardy [EMAIL PROTECTED] 2007-03-21 05:44 This looks like it would break nfnetlink, which appears to be using 0 as smallest message type. It shouldn't do that, the first 16 message types are reserved for control messages. I'm afraid it does: enum cntl_msg_types { IPCTNL_MSG_CT_NEW, IPCTNL_MSG_CT_GET, IPCTNL_MSG_CT_DELETE, IPCTNL_MSG_CT_GET_CTRZERO, IPCTNL_MSG_MAX }; This is totally broken of course since it also uses netlink_ack(), netlink_dump() etc. :( Any smart ideas how to fix this without breaking compatibility? - 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
Re: [PATCH 5/5] [NETLINK]: Ignore control messages directly in netlink_run_queue()
Patrick McHardy wrote: Thomas Graf wrote: * Patrick McHardy [EMAIL PROTECTED] 2007-03-21 05:44 This looks like it would break nfnetlink, which appears to be using 0 as smallest message type. It shouldn't do that, the first 16 message types are reserved for control messages. I'm afraid it does: enum cntl_msg_types { IPCTNL_MSG_CT_NEW, IPCTNL_MSG_CT_GET, IPCTNL_MSG_CT_DELETE, IPCTNL_MSG_CT_GET_CTRZERO, IPCTNL_MSG_MAX }; This is totally broken of course since it also uses netlink_ack(), netlink_dump() etc. :( Any smart ideas how to fix this without breaking compatibility? Seems like we're lucky, nfnetlink encodes the subsystem ID in the upper 8 bits of the message type and uses 1 as the smallest ID: /* netfilter netlink message types are split in two pieces: * 8 bit subsystem, 8bit operation. */ #define NFNL_SUBSYS_ID(x) ((x 0xff00) 8) #define NFNL_MSG_TYPE(x)(x 0x00ff) #define NFNL_SUBSYS_NONE0 #define NFNL_SUBSYS_CTNETLINK 1 #define NFNL_SUBSYS_CTNETLINK_EXP 2 #define NFNL_SUBSYS_QUEUE 3 #define NFNL_SUBSYS_ULOG4 #define NFNL_SUBSYS_COUNT 5 So this should work fine. - 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
Re: [PATCH 5/5] [NETLINK]: Ignore control messages directly in netlink_run_queue()
* Patrick McHardy [EMAIL PROTECTED] 2007-03-21 13:06 Thomas Graf wrote: * Patrick McHardy [EMAIL PROTECTED] 2007-03-21 05:44 This looks like it would break nfnetlink, which appears to be using 0 as smallest message type. It shouldn't do that, the first 16 message types are reserved for control messages. I'm afraid it does: enum cntl_msg_types { IPCTNL_MSG_CT_NEW, IPCTNL_MSG_CT_GET, IPCTNL_MSG_CT_DELETE, IPCTNL_MSG_CT_GET_CTRZERO, IPCTNL_MSG_MAX }; This is totally broken of course since it also uses netlink_ack(), netlink_dump() etc. :( Any smart ideas how to fix this without breaking compatibility? Hmm... I think nfnetlink isn't even broken: /* netfilter netlink message types are split in two pieces: * 8 bit subsystem, 8bit operation. */ #define NFNL_SUBSYS_ID(x) ((x 0xff00) 8) #define NFNL_MSG_TYPE(x)(x 0x00ff) /* No enum here, otherwise __stringify() trick of * MODULE_ALIAS_NFNL_SUBSYS() * won't work anymore */ #define NFNL_SUBSYS_NONE0 #define NFNL_SUBSYS_CTNETLINK 1 #define NFNL_SUBSYS_CTNETLINK_EXP 2 #define NFNL_SUBSYS_QUEUE 3 #define NFNL_SUBSYS_ULOG4 #define NFNL_SUBSYS_COUNT 5 A msg_type 0x10 would just trigger a -EINVAL as no 0x0 subsystem can ever be registered. - 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
Re: [PATCH 5/5] [NETLINK]: Ignore control messages directly in netlink_run_queue()
* Patrick McHardy [EMAIL PROTECTED] 2007-03-21 13:21 Seems like we're lucky, nfnetlink encodes the subsystem ID in the upper 8 bits of the message type and uses 1 as the smallest ID: Alright, you've been quicker :-) - 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
[PATCH 5/5] [NETLINK]: Ignore control messages directly in netlink_run_queue()
Changes netlink_rcv_skb() to skip netlink controll messages and don't pass them on to the message handler. Signed-off-by: Thomas Graf [EMAIL PROTECTED] Index: net-2.6.22/net/netlink/af_netlink.c === --- net-2.6.22.orig/net/netlink/af_netlink.c2007-03-21 01:17:13.0 +0100 +++ net-2.6.22/net/netlink/af_netlink.c 2007-03-21 01:17:46.0 +0100 @@ -1479,6 +1479,10 @@ static int netlink_rcv_skb(struct sk_buf if (!(nlh-nlmsg_flags NLM_F_REQUEST)) goto skip; + /* Skip control messages */ + if (nlh-nlmsg_type NLMSG_MIN_TYPE) + goto skip; + if (cb(skb, nlh, err) 0) { /* Not an error, but we have to interrupt processing * here. Note: that in this case we do not pull Index: net-2.6.22/net/core/rtnetlink.c === --- net-2.6.22.orig/net/core/rtnetlink.c2007-03-21 01:17:13.0 +0100 +++ net-2.6.22/net/core/rtnetlink.c 2007-03-21 01:17:46.0 +0100 @@ -863,10 +863,6 @@ rtnetlink_rcv_msg(struct sk_buff *skb, s type = nlh-nlmsg_type; - /* A control message: ignore them */ - if (type RTM_BASE) - return 0; - /* Unknown message: reply with EINVAL */ if (type RTM_MAX) goto err_inval; Index: net-2.6.22/net/netlink/genetlink.c === --- net-2.6.22.orig/net/netlink/genetlink.c 2007-03-21 01:17:13.0 +0100 +++ net-2.6.22/net/netlink/genetlink.c 2007-03-21 01:17:46.0 +0100 @@ -304,9 +304,6 @@ static int genl_rcv_msg(struct sk_buff * struct genlmsghdr *hdr = nlmsg_data(nlh); int hdrlen, err = -EINVAL; - if (nlh-nlmsg_type NLMSG_MIN_TYPE) - goto ignore; - family = genl_family_find_byid(nlh-nlmsg_type); if (family == NULL) { err = -ENOENT; @@ -364,9 +361,6 @@ static int genl_rcv_msg(struct sk_buff * *errp = err = ops-doit(skb, info); return err; -ignore: - return 0; - errout: *errp = err; return -1; Index: net-2.6.22/net/xfrm/xfrm_user.c === --- net-2.6.22.orig/net/xfrm/xfrm_user.c2007-03-21 01:17:13.0 +0100 +++ net-2.6.22/net/xfrm/xfrm_user.c 2007-03-21 01:17:46.0 +0100 @@ -1861,10 +1861,6 @@ static int xfrm_user_rcv_msg(struct sk_b type = nlh-nlmsg_type; - /* A control message: ignore them */ - if (type XFRM_MSG_BASE) - return 0; - /* Unknown message: reply with EINVAL */ if (type XFRM_MSG_MAX) goto err_einval; -- - 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
Re: [PATCH 5/5] [NETLINK]: Ignore control messages directly in netlink_run_queue()
Thomas Graf wrote: Changes netlink_rcv_skb() to skip netlink controll messages and don't pass them on to the message handler. Signed-off-by: Thomas Graf [EMAIL PROTECTED] Index: net-2.6.22/net/netlink/af_netlink.c === --- net-2.6.22.orig/net/netlink/af_netlink.c 2007-03-21 01:17:13.0 +0100 +++ net-2.6.22/net/netlink/af_netlink.c 2007-03-21 01:17:46.0 +0100 @@ -1479,6 +1479,10 @@ static int netlink_rcv_skb(struct sk_buf if (!(nlh-nlmsg_flags NLM_F_REQUEST)) goto skip; + /* Skip control messages */ + if (nlh-nlmsg_type NLMSG_MIN_TYPE) + goto skip; + This looks like it would break nfnetlink, which appears to be using 0 as smallest message type. - 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