summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorsowmini <none@none>2007-10-26 08:02:09 -0700
committersowmini <none@none>2007-10-26 08:02:09 -0700
commit219e6466a2aff1255072ab802dec9e47f3b5a609 (patch)
treec9f1ec20db4f44a5786bd3408fc5b3d9b74c3e9b /usr/src
parent9b03ea0f916d36e6ec001b90683afcaee8e29a40 (diff)
downloadillumos-joyent-219e6466a2aff1255072ab802dec9e47f3b5a609.tar.gz
6497440 The comments for IRE forwarding table is not updated with the new code
6606222 Parsing tunnel parameters should be more robust
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/uts/common/inet/ip/ip6_if.c6
-rw-r--r--usr/src/uts/common/inet/ip/ip_if.c82
-rw-r--r--usr/src/uts/common/inet/ip/ip_ire.c13
3 files changed, 41 insertions, 60 deletions
diff --git a/usr/src/uts/common/inet/ip/ip6_if.c b/usr/src/uts/common/inet/ip/ip6_if.c
index c5a18350a8..1a9b7876fa 100644
--- a/usr/src/uts/common/inet/ip/ip6_if.c
+++ b/usr/src/uts/common/inet/ip/ip6_if.c
@@ -186,7 +186,8 @@ ipif_lookup_interface_v6(const in6_addr_t *if_addr, const in6_addr_t *dst,
ill);
mutex_exit(&ipsq->ipsq_lock);
RELEASE_CONN_LOCK(q);
- *error = EINPROGRESS;
+ if (error != NULL)
+ *error = EINPROGRESS;
return (NULL);
}
}
@@ -264,7 +265,8 @@ repeat:
ill);
mutex_exit(&ipsq->ipsq_lock);
RELEASE_CONN_LOCK(q);
- *error = EINPROGRESS;
+ if (error != NULL)
+ *error = EINPROGRESS;
return (NULL);
}
}
diff --git a/usr/src/uts/common/inet/ip/ip_if.c b/usr/src/uts/common/inet/ip/ip_if.c
index 729b308e9d..31a67639ed 100644
--- a/usr/src/uts/common/inet/ip/ip_if.c
+++ b/usr/src/uts/common/inet/ip/ip_if.c
@@ -4254,7 +4254,8 @@ ill_find_by_name(char *name, boolean_t isv6, queue_t *q, mblk_t *mp,
ipsq_enq(ipsq, q, mp, func, NEW_OP, ill);
mutex_exit(&ipsq->ipsq_lock);
RELEASE_CONN_LOCK(q);
- *error = EINPROGRESS;
+ if (error != NULL)
+ *error = EINPROGRESS;
return (NULL);
}
mutex_exit(&ill->ill_lock);
@@ -5234,7 +5235,8 @@ ill_lookup_on_ifindex(uint_t index, boolean_t isv6, queue_t *q, mblk_t *mp,
ipsq_enq(ipsq, q, mp, func, NEW_OP, ill);
mutex_exit(&ipsq->ipsq_lock);
RELEASE_CONN_LOCK(q);
- *err = EINPROGRESS;
+ if (err != NULL)
+ *err = EINPROGRESS;
return (NULL);
}
RELEASE_CONN_LOCK(q);
@@ -6010,7 +6012,8 @@ ipif_lookup_interface(ipaddr_t if_addr, ipaddr_t dst, queue_t *q, mblk_t *mp,
ill);
mutex_exit(&ipsq->ipsq_lock);
RELEASE_CONN_LOCK(q);
- *error = EINPROGRESS;
+ if (error != NULL)
+ *error = EINPROGRESS;
return (NULL);
}
}
@@ -6090,7 +6093,8 @@ repeat:
ill);
mutex_exit(&ipsq->ipsq_lock);
RELEASE_CONN_LOCK(q);
- *error = EINPROGRESS;
+ if (error != NULL)
+ *error = EINPROGRESS;
return (NULL);
}
}
@@ -19172,8 +19176,11 @@ ipif_lookup_on_name(char *name, size_t namelen, boolean_t do_alloc,
* If alias has two or more digits and the first
* is zero, fail.
*/
- if (&cp[2] < endp && cp[1] == '0')
+ if (&cp[2] < endp && cp[1] == '0') {
+ if (error != NULL)
+ *error = EINVAL;
return (NULL);
+ }
}
if (cp <= name) {
@@ -19249,7 +19256,8 @@ ipif_lookup_on_name(char *name, size_t namelen, boolean_t do_alloc,
mutex_exit(&ipsq->ipsq_lock);
RELEASE_CONN_LOCK(q);
ill_refrele(ill);
- *error = EINPROGRESS;
+ if (error != NULL)
+ *error = EINPROGRESS;
return (NULL);
}
}
@@ -21649,9 +21657,7 @@ ipif_lookup_on_ifindex(uint_t index, boolean_t isv6, zoneid_t zoneid,
queue_t *q, mblk_t *mp, ipsq_func_t func, int *err, ip_stack_t *ipst)
{
ill_t *ill;
- ipsq_t *ipsq;
- phyint_t *phyi;
- ipif_t *ipif;
+ ipif_t *ipif = NULL;
ASSERT((q == NULL && mp == NULL && func == NULL && err == NULL) ||
(q != NULL && mp != NULL && func != NULL && err != NULL));
@@ -21659,56 +21665,24 @@ ipif_lookup_on_ifindex(uint_t index, boolean_t isv6, zoneid_t zoneid,
if (err != NULL)
*err = 0;
- /*
- * Indexes are stored in the phyint - a common structure
- * to both IPv4 and IPv6.
- */
-
- rw_enter(&ipst->ips_ill_g_lock, RW_READER);
- phyi = avl_find(&ipst->ips_phyint_g_list->phyint_list_avl_by_index,
- (void *) &index, NULL);
- if (phyi != NULL) {
- ill = isv6 ? phyi->phyint_illv6 : phyi->phyint_illv4;
- if (ill == NULL) {
- rw_exit(&ipst->ips_ill_g_lock);
- if (err != NULL)
- *err = ENXIO;
- return (NULL);
- }
- GRAB_CONN_LOCK(q);
+ ill = ill_lookup_on_ifindex(index, isv6, q, mp, func, err, ipst);
+ if (ill != NULL) {
mutex_enter(&ill->ill_lock);
- if (ILL_CAN_LOOKUP(ill)) {
- for (ipif = ill->ill_ipif; ipif != NULL;
- ipif = ipif->ipif_next) {
- if (IPIF_CAN_LOOKUP(ipif) &&
- (zoneid == ALL_ZONES ||
- zoneid == ipif->ipif_zoneid ||
- ipif->ipif_zoneid == ALL_ZONES)) {
- ipif_refhold_locked(ipif);
- mutex_exit(&ill->ill_lock);
- RELEASE_CONN_LOCK(q);
- rw_exit(&ipst->ips_ill_g_lock);
- return (ipif);
- }
+ for (ipif = ill->ill_ipif; ipif != NULL;
+ ipif = ipif->ipif_next) {
+ if (IPIF_CAN_LOOKUP(ipif) && (zoneid == ALL_ZONES ||
+ zoneid == ipif->ipif_zoneid ||
+ ipif->ipif_zoneid == ALL_ZONES)) {
+ ipif_refhold_locked(ipif);
+ break;
}
- } else if (ILL_CAN_WAIT(ill, q)) {
- ipsq = ill->ill_phyint->phyint_ipsq;
- mutex_enter(&ipsq->ipsq_lock);
- rw_exit(&ipst->ips_ill_g_lock);
- mutex_exit(&ill->ill_lock);
- ipsq_enq(ipsq, q, mp, func, NEW_OP, ill);
- mutex_exit(&ipsq->ipsq_lock);
- RELEASE_CONN_LOCK(q);
- *err = EINPROGRESS;
- return (NULL);
}
mutex_exit(&ill->ill_lock);
- RELEASE_CONN_LOCK(q);
+ ill_refrele(ill);
+ if (ipif == NULL && err != NULL)
+ *err = ENXIO;
}
- rw_exit(&ipst->ips_ill_g_lock);
- if (err != NULL)
- *err = ENXIO;
- return (NULL);
+ return (ipif);
}
typedef struct conn_change_s {
diff --git a/usr/src/uts/common/inet/ip/ip_ire.c b/usr/src/uts/common/inet/ip/ip_ire.c
index 375be461b7..0618e3f24e 100644
--- a/usr/src/uts/common/inet/ip/ip_ire.c
+++ b/usr/src/uts/common/inet/ip/ip_ire.c
@@ -144,14 +144,18 @@ struct kmem_cache *rt_entry_cache;
*
* We have a separate cache table and forwarding table for IPv4 and IPv6.
* Cache table (ip_cache_table/ip_cache_table_v6) is a pointer to an
- * array of irb_t structure and forwarding table (ip_forwarding_table/
- * ip_forwarding_table_v6) is an array of pointers to array of irb_t
- * structure. ip_forwarding_table_v6 is allocated dynamically in
+ * array of irb_t structures. The IPv6 forwarding table
+ * (ip_forwarding_table_v6) is an array of pointers to arrays of irb_t
+ * structure. ip_forwarding_table_v6 is allocated dynamically in
* ire_add_v6. ire_ft_init_lock is used to serialize multiple threads
* initializing the same bucket. Once a bucket is initialized, it is never
* de-alloacted. This assumption enables us to access
* ip_forwarding_table_v6[i] without any locks.
*
+ * The forwarding table for IPv4 is a radix tree whose leaves
+ * are rt_entry structures containing the irb_t for the rt_dst. The irb_t
+ * for IPv4 is dynamically allocated and freed.
+ *
* Each irb_t - ire bucket structure has a lock to protect
* a bucket and the ires residing in the bucket have a back pointer to
* the bucket structure. It also has a reference count for the number
@@ -161,7 +165,8 @@ struct kmem_cache *rt_entry_cache;
* in this bucket that are marked with IRE_MARK_CONDEMNED and the
* last thread to leave the bucket should delete the ires. Usually
* this is done by the IRB_REFRELE macro which is used to decrement
- * the reference count on a bucket.
+ * the reference count on a bucket. See comments above irb_t structure
+ * definition in ip.h for further details.
*
* IRE_REFHOLD/IRE_REFRELE macros operate on the ire which increments/
* decrements the reference count, ire_refcnt, atomically on the ire.