diff options
| author | Mark Johnston <markj@FreeBSD.org> | 2020-08-31 15:59:17 +0000 |
|---|---|---|
| committer | Mark Johnston <markj@FreeBSD.org> | 2020-08-31 15:59:17 +0000 |
| commit | 0a01415e6e75055d03d8b903e64c1264dd1d2849 (patch) | |
| tree | 7af07f898f5f32e1be1e24089206a73875280ff6 /sbin/ggate | |
| parent | 57b278f88622a90f99cf3ef36bc475460d2895f1 (diff) | |
Notes
Diffstat (limited to 'sbin/ggate')
| -rw-r--r-- | sbin/ggate/ggated/ggated.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/sbin/ggate/ggated/ggated.c b/sbin/ggate/ggated/ggated.c index f4279cbfaa13a..1382733492680 100644 --- a/sbin/ggate/ggated/ggated.c +++ b/sbin/ggate/ggated/ggated.c @@ -349,6 +349,16 @@ exports_check(struct ggd_export *ex, struct g_gate_cinit *cinit, flags = O_WRONLY; else flags = O_RDWR; + if (conn->c_diskfd != -1) { + if (strcmp(conn->c_path, ex->e_path) != 0) { + g_gate_log(LOG_ERR, "old %s and new %s: " + "Path mismatch during handshakes.", + conn->c_path, ex->e_path); + return (EPERM); + } + return (0); + } + conn->c_diskfd = open(ex->e_path, flags); if (conn->c_diskfd == -1) { error = errno; @@ -455,7 +465,7 @@ connection_new(struct g_gate_cinit *cinit, struct sockaddr *s, int sfd) conn->c_token = cinit->gc_token; ip = htonl(((struct sockaddr_in *)(void *)s)->sin_addr.s_addr); conn->c_srcip = ip; - conn->c_sendfd = conn->c_recvfd = -1; + conn->c_diskfd = conn->c_sendfd = conn->c_recvfd = -1; if ((cinit->gc_flags & GGATE_FLAG_SEND) != 0) conn->c_sendfd = sfd; else @@ -510,6 +520,8 @@ connection_remove(struct ggd_connection *conn) LIST_REMOVE(conn, c_next); g_gate_log(LOG_DEBUG, "Connection removed [%s %s].", ip2str(conn->c_srcip), conn->c_path); + if (conn->c_diskfd != -1) + close(conn->c_diskfd); if (conn->c_sendfd != -1) close(conn->c_sendfd); if (conn->c_recvfd != -1) |
