View | Details | Raw Unified | Return to bug 253912
Collapse All | Expand All

(-)b/sys/netinet/libalias/alias_db.c (-62 / +75 lines)
Lines 379-385 Lookup table starting points: Link Here
379
*/
379
*/
380
380
381
/* Local prototypes */
381
/* Local prototypes */
382
static u_int	StartPointIn(struct in_addr, u_short, int);
382
static		u_int
383
StartPointIn(struct in_addr, struct in_addr,
384
    u_short, u_short, int);
383
385
384
static		u_int
386
static		u_int
385
StartPointOut(struct in_addr, struct in_addr,
387
StartPointOut(struct in_addr, struct in_addr,
Lines 403-418 static void UninitPacketAliasLog(struct libalias *); Link Here
403
void SctpShowAliasStats(struct libalias *la);
405
void SctpShowAliasStats(struct libalias *la);
404
406
405
static		u_int
407
static		u_int
406
StartPointIn(struct in_addr alias_addr,
408
StartPointIn(struct in_addr alias_addr, struct in_addr dst_addr,
407
    u_short alias_port,
409
    u_short alias_port, u_short dst_port, int link_type)
408
    int link_type)
409
{
410
{
410
	u_int n;
411
	u_int n;
411
412
412
	n = alias_addr.s_addr;
413
	n = alias_addr.s_addr;
413
	if (link_type != LINK_PPTP)
414
	n += dst_addr.s_addr;
415
	if (link_type != LINK_PPTP) {
414
		n += alias_port;
416
		n += alias_port;
417
		n += dst_port;
418
	}
415
	n += link_type;
419
	n += link_type;
420
416
	return (n % LINK_TABLE_IN_SIZE);
421
	return (n % LINK_TABLE_IN_SIZE);
417
}
422
}
418
423
Lines 1043-1049 AddLink(struct libalias *la, struct in_addr src_addr, struct in_addr dst_addr, Link Here
1043
		LIST_INSERT_HEAD(&la->linkTableOut[start_point], lnk, list_out);
1048
		LIST_INSERT_HEAD(&la->linkTableOut[start_point], lnk, list_out);
1044
1049
1045
		/* Set up pointers for input lookup table */
1050
		/* Set up pointers for input lookup table */
1046
		start_point = StartPointIn(alias_addr, lnk->alias_port, link_type);
1051
		start_point = StartPointIn(alias_addr, dst_addr,
1052
		    lnk->alias_port, dst_port, link_type);
1047
		LIST_INSERT_HEAD(&la->linkTableIn[start_point], lnk, list_in);
1053
		LIST_INSERT_HEAD(&la->linkTableIn[start_point], lnk, list_in);
1048
	} else {
1054
	} else {
1049
#ifdef LIBALIAS_DEBUG
1055
#ifdef LIBALIAS_DEBUG
Lines 1175-1192 _FindLinkIn(struct libalias *la, struct in_addr dst_addr, Link Here
1175
{
1181
{
1176
	int flags_in;
1182
	int flags_in;
1177
	u_int start_point;
1183
	u_int start_point;
1178
	struct alias_link *lnk;
1184
	struct alias_link *lnk = NULL;
1179
	struct alias_link *lnk_fully_specified;
1180
	struct alias_link *lnk_unknown_all;
1181
	struct alias_link *lnk_unknown_dst_addr;
1182
	struct alias_link *lnk_unknown_dst_port;
1183
1185
1184
	LIBALIAS_LOCK_ASSERT(la);
1186
	LIBALIAS_LOCK_ASSERT(la);
1185
/* Initialize pointers */
1186
	lnk_fully_specified = NULL;
1187
	lnk_unknown_all = NULL;
1188
	lnk_unknown_dst_addr = NULL;
1189
	lnk_unknown_dst_port = NULL;
1190
1187
1191
/* If either the dest addr or port is unknown, the search
1188
/* If either the dest addr or port is unknown, the search
1192
   loop will have to know about this. */
1189
   loop will have to know about this. */
Lines 1197-1254 _FindLinkIn(struct libalias *la, struct in_addr dst_addr, Link Here
1197
	if (dst_port == 0)
1194
	if (dst_port == 0)
1198
		flags_in |= LINK_UNKNOWN_DEST_PORT;
1195
		flags_in |= LINK_UNKNOWN_DEST_PORT;
1199
1196
1200
/* Search loop */
1197
	/* Search for fully specified links */
1201
	start_point = StartPointIn(alias_addr, alias_port, link_type);
1198
	if (!(flags_in & LINK_PARTIALLY_SPECIFIED)) {
1202
	LIST_FOREACH(lnk, &la->linkTableIn[start_point], list_in) {
1199
		start_point = StartPointIn(alias_addr, dst_addr,
1203
		int flags;
1200
		                           alias_port, dst_port, link_type);
1204
1201
		LIST_FOREACH(lnk, &la->linkTableIn[start_point], list_in) {
1205
		flags = flags_in | lnk->flags;
1202
			int flags = flags_in | lnk->flags;
1206
		if (!(flags & LINK_PARTIALLY_SPECIFIED)) {
1203
			if (!(flags & LINK_PARTIALLY_SPECIFIED)) {
1207
			if (lnk->alias_addr.s_addr == alias_addr.s_addr
1204
				if (lnk->alias_addr.s_addr == alias_addr.s_addr
1208
			    && lnk->alias_port == alias_port
1205
				    && lnk->alias_port == alias_port
1209
			    && lnk->dst_addr.s_addr == dst_addr.s_addr
1206
				    && lnk->dst_addr.s_addr == dst_addr.s_addr
1210
			    && lnk->dst_port == dst_port
1207
				    && lnk->dst_port == dst_port
1211
			    && lnk->link_type == link_type) {
1208
				    && lnk->link_type == link_type) {
1212
				lnk_fully_specified = lnk;
1209
					lnk->timestamp = la->timeStamp;
1213
				break;
1210
					break;
1211
				}
1214
			}
1212
			}
1215
		} else if ((flags & LINK_UNKNOWN_DEST_ADDR)
1213
		}
1216
		    && (flags & LINK_UNKNOWN_DEST_PORT)) {
1214
	}
1217
			if (lnk->alias_addr.s_addr == alias_addr.s_addr
1215
1218
			    && lnk->alias_port == alias_port
1216
	/* Search for links without destination port */
1219
			    && lnk->link_type == link_type) {
1217
	if (lnk == NULL && !(flags_in & LINK_UNKNOWN_DEST_ADDR)) {
1220
				if (lnk_unknown_all == NULL)
1218
		start_point = StartPointIn(alias_addr, dst_addr,
1221
					lnk_unknown_all = lnk;
1219
		                           alias_port, 0, link_type);
1220
		LIST_FOREACH(lnk, &la->linkTableIn[start_point], list_in) {
1221
			int flags = flags_in | lnk->flags;
1222
			if (flags & LINK_UNKNOWN_DEST_PORT) {
1223
				if (lnk->alias_addr.s_addr == alias_addr.s_addr
1224
				    && lnk->alias_port == alias_port
1225
				    && lnk->link_type == link_type
1226
				    && lnk->dst_addr.s_addr == dst_addr.s_addr)
1227
					break;
1222
			}
1228
			}
1223
		} else if (flags & LINK_UNKNOWN_DEST_ADDR) {
1229
		}
1224
			if (lnk->alias_addr.s_addr == alias_addr.s_addr
1230
	}
1225
			    && lnk->alias_port == alias_port
1231
1226
			    && lnk->link_type == link_type
1232
	/* Search for links without destination address */
1227
			    && lnk->dst_port == dst_port) {
1233
	if (lnk == NULL && !(flags_in & LINK_UNKNOWN_DEST_PORT)) {
1228
				if (lnk_unknown_dst_addr == NULL)
1234
		start_point = StartPointIn(alias_addr, la->nullAddress,
1229
					lnk_unknown_dst_addr = lnk;
1235
		                           alias_port, dst_port, link_type);
1236
		LIST_FOREACH(lnk, &la->linkTableIn[start_point], list_in) {
1237
			int flags = flags_in | lnk->flags;
1238
			if (flags & LINK_UNKNOWN_DEST_ADDR) {
1239
				if (lnk->alias_addr.s_addr == alias_addr.s_addr
1240
				    && lnk->alias_port == alias_port
1241
				    && lnk->link_type == link_type
1242
				    && lnk->dst_port == dst_port)
1243
					break;
1230
			}
1244
			}
1231
		} else if (flags & LINK_UNKNOWN_DEST_PORT) {
1245
		}
1232
			if (lnk->alias_addr.s_addr == alias_addr.s_addr
1246
	}
1233
			    && lnk->alias_port == alias_port
1247
1234
			    && lnk->link_type == link_type
1248
	/* Search for links without destination address and port */
1235
			    && lnk->dst_addr.s_addr == dst_addr.s_addr) {
1249
	if (lnk == NULL) {
1236
				if (lnk_unknown_dst_port == NULL)
1250
		start_point = StartPointIn(alias_addr, la->nullAddress,
1237
					lnk_unknown_dst_port = lnk;
1251
		                           alias_port, 0, link_type);
1252
		LIST_FOREACH(lnk, &la->linkTableIn[start_point], list_in) {
1253
			int flags = flags_in | lnk->flags;
1254
			if ((flags & LINK_UNKNOWN_DEST_ADDR)
1255
			    && (flags & LINK_UNKNOWN_DEST_PORT)) {
1256
				if (lnk->alias_addr.s_addr == alias_addr.s_addr
1257
				    && lnk->alias_port == alias_port
1258
				    && lnk->link_type == link_type)
1259
					break;
1238
			}
1260
			}
1239
		}
1261
		}
1240
	}
1262
	}
1241
1263
1242
	if (lnk_fully_specified != NULL) {
1264
	if (lnk == NULL)
1243
		lnk_fully_specified->timestamp = la->timeStamp;
1244
		lnk = lnk_fully_specified;
1245
	} else if (lnk_unknown_dst_port != NULL)
1246
		lnk = lnk_unknown_dst_port;
1247
	else if (lnk_unknown_dst_addr != NULL)
1248
		lnk = lnk_unknown_dst_addr;
1249
	else if (lnk_unknown_all != NULL)
1250
		lnk = lnk_unknown_all;
1251
	else
1252
		return (NULL);
1265
		return (NULL);
1253
1266
1254
	if (replace_partial_links &&
1267
	if (replace_partial_links &&
Lines 1612-1618 FindPptpInByCallId(struct libalias *la, struct in_addr dst_addr, Link Here
1612
	struct alias_link *lnk;
1625
	struct alias_link *lnk;
1613
1626
1614
	LIBALIAS_LOCK_ASSERT(la);
1627
	LIBALIAS_LOCK_ASSERT(la);
1615
	i = StartPointIn(alias_addr, 0, LINK_PPTP);
1628
	i = StartPointIn(alias_addr, dst_addr, 0, 0, LINK_PPTP);
1616
	LIST_FOREACH(lnk, &la->linkTableIn[i], list_in)
1629
	LIST_FOREACH(lnk, &la->linkTableIn[i], list_in)
1617
	    if (lnk->link_type == LINK_PPTP &&
1630
	    if (lnk->link_type == LINK_PPTP &&
1618
	    lnk->dst_addr.s_addr == dst_addr.s_addr &&
1631
	    lnk->dst_addr.s_addr == dst_addr.s_addr &&

Return to bug 253912