| 1110 | } |
| 1111 | |
| 1112 | static void |
| 1113 | tcp_fastopen_ccache_bucket_trim(struct tcp_fastopen_ccache_bucket *ccb, |
| 1114 | unsigned int limit) |
| 1115 | { |
| 1116 | struct tcp_fastopen_ccache_entry *cce, *cce_tmp; |
| 1117 | unsigned int entries; |
| 1118 | |
| 1119 | CCB_LOCK(ccb); |
| 1120 | entries = 0; |
| 1121 | TAILQ_FOREACH_SAFE(cce, &ccb->ccb_entries, cce_link, cce_tmp) { |
| 1122 | entries++; |
| 1123 | if (entries > limit) |
| 1124 | tcp_fastopen_ccache_entry_drop(cce, ccb); |
| 1125 | } |
| 1126 | KASSERT(ccb->ccb_num_entries <= (int)limit, |
| 1127 | ("%s: ccb->ccb_num_entries %d exceeds limit %d", __func__, |
| 1128 | ccb->ccb_num_entries, limit)); |
| 1129 | if (limit == 0) { |
| 1130 | KASSERT(TAILQ_EMPTY(&ccb->ccb_entries), |
| 1131 | ("%s: ccb->ccb_entries not empty", __func__)); |
| 1132 | ccb->ccb_num_entries = -1; /* disable bucket */ |
| 1133 | } |
| 1134 | CCB_UNLOCK(ccb); |
| 1135 | } |
| 1136 | |
| 1137 | static void |
| 1138 | tcp_fastopen_ccache_entry_drop(struct tcp_fastopen_ccache_entry *cce, |
no test coverage detected