diff options
Diffstat (limited to 'debian/patches/random-fixes0004-pfinet-convert-to-trivfs-dynamic-classes-and-buckets.patch')
-rw-r--r-- | debian/patches/random-fixes0004-pfinet-convert-to-trivfs-dynamic-classes-and-buckets.patch | 228 |
1 files changed, 228 insertions, 0 deletions
diff --git a/debian/patches/random-fixes0004-pfinet-convert-to-trivfs-dynamic-classes-and-buckets.patch b/debian/patches/random-fixes0004-pfinet-convert-to-trivfs-dynamic-classes-and-buckets.patch new file mode 100644 index 00000000..da99c745 --- /dev/null +++ b/debian/patches/random-fixes0004-pfinet-convert-to-trivfs-dynamic-classes-and-buckets.patch @@ -0,0 +1,228 @@ +From 004c432be995bf8c1fc74e2726a077a009792746 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Sun, 27 Sep 2015 18:50:11 +0200 +Subject: [PATCH hurd 04/10] pfinet: convert to trivfs dynamic classes and + buckets + +libtrivfs contains two ways of managing more than one port class and +bucket. There is the old way of using a statically allocated array +with explicit length, and the new way with dynamically allocated +vectors. + +Converting all users to the new way of handling multiple classes +and/or buckets, we can simplify the code in libtrivfs. In many cases, +the code will be simpler and more expressive for the user. + +This also fixes a mild bug. The classes and buckets given to +`trivfs_startup' end up in the dynamic vectors too, making the object +lookup code use the more complicated code path. + +* pfinet/main.c: Convert to dynamic classes and buckets. +* pfinet/options.c: Likewise. +* pfinet/pfinet.h: Likewise. +* pfinet/socket-ops.c: Likewise. +--- + pfinet/main.c | 61 +++++++++++++++++++++++++++++------------------------ + pfinet/options.c | 8 +++---- + pfinet/pfinet.h | 7 ++---- + pfinet/socket-ops.c | 2 +- + 4 files changed, 41 insertions(+), 37 deletions(-) + +diff --git a/pfinet/main.c b/pfinet/main.c +index 8716fdb..46457a9 100644 +--- a/pfinet/main.c ++++ b/pfinet/main.c +@@ -56,11 +56,9 @@ int trivfs_support_write = 1; + int trivfs_support_exec = 0; + int trivfs_allow_open = O_READ | O_WRITE; + +-struct port_class *trivfs_protid_portclasses[2]; +-int trivfs_protid_nportclasses = 2; +- +-struct port_class *trivfs_cntl_portclasses[2]; +-int trivfs_cntl_nportclasses = 2; ++/* We have a class each per portclass. */ ++struct port_class *pfinet_protid_portclasses[2]; ++struct port_class *pfinet_cntl_portclasses[2]; + + /* Which portclass to install on the bootstrap port, default to IPv4. */ + int pfinet_bootstrap_portclass = PORTCLASS_INET; +@@ -334,7 +332,7 @@ main (int argc, + + if (bootstrap != MACH_PORT_NULL) { + /* Create portclass to install on the bootstrap port. */ +- if(trivfs_protid_portclasses[pfinet_bootstrap_portclass] ++ if(pfinet_protid_portclasses[pfinet_bootstrap_portclass] + != MACH_PORT_NULL) + error(1, 0, "No portclass left to assign to bootstrap port"); + +@@ -342,17 +340,23 @@ main (int argc, + if (pfinet_bootstrap_portclass == PORTCLASS_INET6) + pfinet_activate_ipv6 (); + #endif +- +- trivfs_protid_portclasses[pfinet_bootstrap_portclass] = +- ports_create_class (trivfs_clean_protid, 0); +- trivfs_cntl_portclasses[pfinet_bootstrap_portclass] = +- ports_create_class (trivfs_clean_cntl, 0); ++ ++ err = trivfs_add_protid_port_class ( ++ &pfinet_protid_portclasses[pfinet_bootstrap_portclass]); ++ if (err) ++ error (1, 0, "error creating control port class"); ++ ++ err = trivfs_add_control_port_class ( ++ &pfinet_cntl_portclasses[pfinet_bootstrap_portclass]); ++ if (err) ++ error (1, 0, "error creating control port class"); + + /* Talk to parent and link us in. */ + err = trivfs_startup (bootstrap, 0, +- trivfs_cntl_portclasses[pfinet_bootstrap_portclass], +- pfinet_bucket, trivfs_protid_portclasses +- [pfinet_bootstrap_portclass], pfinet_bucket, ++ pfinet_cntl_portclasses[pfinet_bootstrap_portclass], ++ pfinet_bucket, ++ pfinet_protid_portclasses[pfinet_bootstrap_portclass], ++ pfinet_bucket, + &pfinetctl); + + if (err) +@@ -371,7 +375,7 @@ main (int argc, + /* Check that at least one portclass has been bound, + error out otherwise. */ + for (i = 0; i < trivfs_protid_nportclasses; i ++) +- if (trivfs_protid_portclasses[i] != MACH_PORT_NULL) ++ if (pfinet_protid_portclasses[i] != MACH_PORT_NULL) + break; + + if (i == trivfs_protid_nportclasses) +@@ -424,22 +428,25 @@ pfinet_bind (int portclass, const char *name) + err = errno; + + if (! err) { +- if (trivfs_protid_portclasses[portclass] != MACH_PORT_NULL) ++ if (pfinet_protid_portclasses[portclass] != MACH_PORT_NULL) + error (1, 0, "Cannot bind one protocol to multiple nodes.\n"); + + #ifdef CONFIG_IPV6 + if (portclass == PORTCLASS_INET6) + pfinet_activate_ipv6 (); + #endif ++ //mark ++ err = trivfs_add_protid_port_class (&pfinet_protid_portclasses[portclass]); ++ if (err) ++ error (1, 0, "error creating control port class"); + +- trivfs_protid_portclasses[portclass] = +- ports_create_class (trivfs_clean_protid, 0); +- trivfs_cntl_portclasses[portclass] = +- ports_create_class (trivfs_clean_cntl, 0); ++ err = trivfs_add_control_port_class (&pfinet_cntl_portclasses[portclass]); ++ if (err) ++ error (1, 0, "error creating control port class"); + +- err = trivfs_create_control (file, trivfs_cntl_portclasses[portclass], +- pfinet_bucket, +- trivfs_protid_portclasses[portclass], ++ err = trivfs_create_control (file, pfinet_cntl_portclasses[portclass], ++ pfinet_bucket, ++ pfinet_protid_portclasses[portclass], + pfinet_bucket, &cntl); + } + +@@ -473,16 +480,16 @@ trivfs_goaway (struct trivfs_control *cntl, int flags) + else + { + /* Stop new requests. */ +- ports_inhibit_class_rpcs (trivfs_cntl_portclasses[0]); +- ports_inhibit_class_rpcs (trivfs_protid_portclasses[0]); ++ ports_inhibit_class_rpcs (pfinet_cntl_portclasses[0]); ++ ports_inhibit_class_rpcs (pfinet_protid_portclasses[0]); + ports_inhibit_class_rpcs (socketport_class); + + if (ports_count_class (socketport_class) != 0) + { + /* We won't go away, so start things going again... */ + ports_enable_class (socketport_class); +- ports_resume_class_rpcs (trivfs_cntl_portclasses[0]); +- ports_resume_class_rpcs (trivfs_protid_portclasses[0]); ++ ports_resume_class_rpcs (pfinet_cntl_portclasses[0]); ++ ports_resume_class_rpcs (pfinet_protid_portclasses[0]); + + return EBUSY; + } +diff --git a/pfinet/options.c b/pfinet/options.c +index daffcd5..ae44759 100644 +--- a/pfinet/options.c ++++ b/pfinet/options.c +@@ -133,7 +133,7 @@ parse_interface_copy_device(struct device *src, + && FIB_RES_GW(res) != INADDR_ANY) + dst->gateway = FIB_RES_GW (res); + #ifdef CONFIG_IPV6 +- if (trivfs_protid_portclasses[PORTCLASS_INET6] != MACH_PORT_NULL) ++ if (pfinet_protid_portclasses[PORTCLASS_INET6] != MACH_PORT_NULL) + idev = ipv6_find_idev(src); + + if (idev) +@@ -452,7 +452,7 @@ parse_opt (int opt, char *arg, struct argp_state *state) + { + #ifdef CONFIG_IPV6 + struct inet6_dev *idev = NULL; +- if (trivfs_protid_portclasses[PORTCLASS_INET6] != MACH_PORT_NULL ++ if (pfinet_protid_portclasses[PORTCLASS_INET6] != MACH_PORT_NULL + && in->device) + idev = ipv6_find_idev(in->device); + #endif +@@ -570,7 +570,7 @@ parse_opt (int opt, char *arg, struct argp_state *state) + + /* Set IPv6 default router. */ + #ifdef CONFIG_IPV6 +- if (trivfs_protid_portclasses[PORTCLASS_INET6] != MACH_PORT_NULL) ++ if (pfinet_protid_portclasses[PORTCLASS_INET6] != MACH_PORT_NULL) + { + struct rt6_info *rt6i = ipv6_get_dflt_router (); + +@@ -710,7 +710,7 @@ trivfs_append_args (struct trivfs_control *fsys, char **argz, size_t *argz_len) + #ifdef CONFIG_IPV6 + struct inet6_dev *idev = NULL; + +- if (trivfs_protid_portclasses[PORTCLASS_INET6] != MACH_PORT_NULL) ++ if (pfinet_protid_portclasses[PORTCLASS_INET6] != MACH_PORT_NULL) + idev = ipv6_find_idev(dev); + + if (idev) +diff --git a/pfinet/pfinet.h b/pfinet/pfinet.h +index 46aa97b..6e59225 100644 +--- a/pfinet/pfinet.h ++++ b/pfinet/pfinet.h +@@ -92,11 +92,8 @@ enum { + PORTCLASS_INET6, + }; + +-extern struct port_class *trivfs_protid_portclasses[]; +-extern int trivfs_protid_nportclasses; +- +-extern struct port_class *trivfs_cntl_portclasses[2]; +-extern int trivfs_cntl_nportclasses; ++extern struct port_class *pfinet_protid_portclasses[2]; ++extern struct port_class *pfinet_cntl_portclasses[2]; + + /* Which portclass to install on the bootstrap port. */ + extern int pfinet_bootstrap_portclass; +diff --git a/pfinet/socket-ops.c b/pfinet/socket-ops.c +index 3f8b7fb..14b3120 100644 +--- a/pfinet/socket-ops.c ++++ b/pfinet/socket-ops.c +@@ -82,7 +82,7 @@ S_socket_create (struct trivfs_protid *master, + isroot = 1; + } + +- if (master->pi.class == trivfs_protid_portclasses[PORTCLASS_INET]) ++ if (master->pi.class == pfinet_protid_portclasses[PORTCLASS_INET]) + err = - (*net_families[PF_INET]->create) (sock, protocol); + else + err = - (*net_families[PF_INET6]->create) (sock, protocol); +-- +2.1.4 + |