From: Gerrit Renker <gerrit@erg.abdn.ac.uk>
To: dccp@vger.kernel.org
Subject: [PATCH 11/14]: Auto-load (when supported) CCID plugins for negotiation
Date: Wed, 03 Oct 2007 14:02:51 +0000 [thread overview]
Message-ID: <200710031502.51979@strip-the-willow> (raw)
[DCCP]: Auto-load (when supported) CCID plugins for negotiation
This adds auto-loading of CCIDs (when module loading is enabled)
for the purpose of feature negotiation.
It is done in dccp_feat_init(), which is in process context.
The problem with loading the CCIDs at the end of feature negotiation is
that then this would be in software interrupt context. Besides, if the host
advertises CCIDs during negotiation, it should have them available in case
the peer agrees with one of the advertised CCIDs.
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
---
net/dccp/ccid.c | 39 +++++++++++++++++++++++++++++----------
net/dccp/ccid.h | 1 +
net/dccp/feat.c | 4 ++++
3 files changed, 34 insertions(+), 10 deletions(-)
--- a/net/dccp/feat.c
+++ b/net/dccp/feat.c
@@ -1067,6 +1067,10 @@ int dccp_feat_init(struct sock *sk)
ccid_get_default_ccids(&sp[1].val, &sp[1].len))
return -ENOBUFS;
+ /* Pre-load all CCID modules that are going to be advertised */
+ if (ccid_request_modules(sp[0].val, sp[0].len))
+ return -EUNATCH;
+
if (!dccp_feat_prefer(sysctl_dccp_feat_tx_ccid, sp[0].val, sp[0].len) ||
!dccp_feat_prefer(sysctl_dccp_feat_rx_ccid, sp[1].val, sp[1].len))
rc = -ENOPROTOOPT;
--- a/net/dccp/ccid.h
+++ b/net/dccp/ccid.h
@@ -85,6 +85,7 @@ extern bool ccid_support_check(u8 const
extern int ccid_getsockopt_available_ccids(struct sock *sk, int len,
char __user *, int __user *);
+extern int ccid_request_modules(u8 const *ccid_array, u8 array_len);
extern struct ccid *ccid_new(unsigned char id, struct sock *sk, int rx,
gfp_t gfp);
--- a/net/dccp/ccid.c
+++ b/net/dccp/ccid.c
@@ -196,22 +196,41 @@ int ccid_unregister(struct ccid_operatio
EXPORT_SYMBOL_GPL(ccid_unregister);
+/**
+ * ccid_request_module - Pre-load CCID module for later use
+ * This should be called only from process context (e.g. during connection
+ * setup) and is necessary for later calls to ccid_new (typically in software
+ * interrupt), so that it has the modules available when they are needed.
+ */
+static int ccid_request_module(u8 id)
+{
+ if (!in_atomic()) {
+ ccids_read_lock();
+ if (ccids[id] = NULL) {
+ ccids_read_unlock();
+ return request_module("net-dccp-ccid-%d", id);
+ }
+ ccids_read_unlock();
+ }
+ return 0;
+}
+
+int ccid_request_modules(u8 const *ccid_array, u8 array_len)
+{
+#ifdef CONFIG_KMOD
+ while (array_len--)
+ if (ccid_request_module(ccid_array[array_len]))
+ return -1;
+#endif
+ return 0;
+}
+
struct ccid *ccid_new(unsigned char id, struct sock *sk, int rx, gfp_t gfp)
{
struct ccid_operations *ccid_ops;
struct ccid *ccid = NULL;
ccids_read_lock();
-#ifdef CONFIG_KMOD
- if (ccids[id] = NULL) {
- /* We only try to load if in process context */
- ccids_read_unlock();
- if (gfp & GFP_ATOMIC)
- goto out;
- request_module("net-dccp-ccid-%d", id);
- ccids_read_lock();
- }
-#endif
ccid_ops = ccids[id];
if (ccid_ops = NULL)
goto out_unlock;
next reply other threads:[~2007-10-03 14:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-03 14:02 Gerrit Renker [this message]
2007-10-03 22:02 ` [PATCH 11/14]: Auto-load (when supported) CCID plugins for negotiation Ian McDonald
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200710031502.51979@strip-the-willow \
--to=gerrit@erg.abdn.ac.uk \
--cc=dccp@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox