Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F142375426
D28516.id83477.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D28516.id83477.diff
View Options
Index: sys/netgraph/ng_bridge.h
===================================================================
--- sys/netgraph/ng_bridge.h
+++ sys/netgraph/ng_bridge.h
@@ -190,6 +190,16 @@
};
#endif /* NGM_BRIDGE_TABLE_ABI */
+struct ng_bridge_move_host {
+ u_char addr[6]; /* ethernet address */
+ char hook[NG_HOOKSIZ]; /* link where addr can be found */
+};
+/* Keep this in sync with the above structure definition */
+#define NG_BRIDGE_MOVE_HOST_TYPE_INFO(entype) { \
+ { "addr", (entype) }, \
+ { "hook", &ng_parse_hookbuf_type }, \
+}
+
/* Netgraph control messages */
enum {
NGM_BRIDGE_SET_CONFIG = 1, /* set node configuration */
@@ -200,6 +210,7 @@
NGM_BRIDGE_GETCLR_STATS, /* atomically get & clear link stats */
NGM_BRIDGE_GET_TABLE, /* get link table */
NGM_BRIDGE_SET_PERSISTENT, /* set persistent mode */
+ NGM_BRIDGE_MOVE_HOST, /* move a host to a link */
};
#endif /* _NETGRAPH_NG_BRIDGE_H_ */
Index: sys/netgraph/ng_bridge.c
===================================================================
--- sys/netgraph/ng_bridge.c
+++ sys/netgraph/ng_bridge.c
@@ -229,6 +229,13 @@
&ng_parse_struct_type,
&ng_bridge_stats_type_fields
};
+/* Parse type for struct ng_bridge_move_host */
+static const struct ng_parse_struct_field ng_bridge_move_host_type_fields[]
+ = NG_BRIDGE_MOVE_HOST_TYPE_INFO(&ng_parse_enaddr_type);
+static const struct ng_parse_type ng_bridge_move_host_type = {
+ &ng_parse_struct_type,
+ &ng_bridge_move_host_type_fields
+};
/* List of commands and how to convert arguments to/from ASCII */
static const struct ng_cmdlist ng_bridge_cmdlist[] = {
@@ -288,6 +295,13 @@
NULL,
NULL
},
+ {
+ NGM_BRIDGE_COOKIE,
+ NGM_BRIDGE_MOVE_HOST,
+ "movehost",
+ &ng_bridge_move_host_type,
+ NULL
+ },
{ 0 }
};
@@ -665,6 +679,26 @@
priv->persistent = 1;
break;
}
+ case NGM_BRIDGE_MOVE_HOST:
+ {
+ struct ng_bridge_move_host *mh;
+ hook_p hook;
+
+ if (msg->header.arglen < sizeof(*mh)) {
+ error = EINVAL;
+ break;
+ }
+ mh = (struct ng_bridge_move_host *)msg->data;
+ hook = (mh->hook[0] == 0)
+ ? lasthook
+ : ng_findhook(node, mh->hook);
+ if (hook == NULL) {
+ error = EINVAL;
+ break;
+ }
+ ng_bridge_put(priv, mh->addr, NG_HOOK_PRIVATE(hook));
+ break;
+ }
default:
error = EINVAL;
break;
@@ -849,12 +883,26 @@
host->age = 0;
}
} else if (ctx.incoming->learnMac) {
- if (!ng_bridge_put(priv, eh->ether_shost, ctx.incoming)) {
+ struct ng_mesg *msg;
+ struct ng_bridge_move_host *mh;
+ int error = 0;
+
+ NG_MKMESSAGE(msg, NGM_BRIDGE_COOKIE, NGM_BRIDGE_MOVE_HOST,
+ sizeof(*mh), M_NOWAIT);
+ if (msg == NULL) {
counter_u64_add(ctx.incoming->stats.memoryFailures, 1);
NG_FREE_ITEM(item);
NG_FREE_M(ctx.m);
return (ENOMEM);
}
+ mh = (struct ng_bridge_move_host *)msg->data;
+ strncpy(mh->hook, NG_HOOK_NAME(ctx.incoming->hook),
+ sizeof(mh->hook));
+ memcpy(mh->addr, eh->ether_shost, sizeof(mh->addr));
+ NG_SEND_MSG_ID(error, node, msg, NG_NODE_ID(node),
+ NG_NODE_ID(node));
+ if (error)
+ counter_u64_add(ctx.incoming->stats.memoryFailures, 1);
}
/* Run packet through ipfw processing, if enabled */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Jan 20, 7:06 AM (13 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27760419
Default Alt Text
D28516.id83477.diff (3 KB)
Attached To
Mode
D28516: netgraph/ng_bridge: learn MACs via control message
Attached
Detach File
Event Timeline
Log In to Comment