Bug 132845 - [geom] [patch] ggated(8) does not close files opened after disconnect
Summary: [geom] [patch] ggated(8) does not close files opened after disconnect
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-geom mailing list
Depends on:
Reported: 2009-03-20 08:10 UTC by ota
Modified: 2018-05-28 19:46 UTC (History)
2 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description ota 2009-03-20 08:10:03 UTC
ggated doesn't close local file after closing client connections.

By the way, the patch at http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/132798 also includes this fix, too.  I decided to file this because it is a separate issue.


Add the following in connection_remove function in sbin/ggate/ggated/ggated.c

        if(conn->c_diskfd == -1)

static void
connection_remove(struct ggd_connection *conn)

        LIST_REMOVE(conn, c_next);
        g_gate_log(LOG_DEBUG, "Connection removed [%s %s].",
            ip2str((struct sockaddr*)&conn->c_srcaddr), conn->c_path);
        if (conn->c_sendfd != -1)
        if (conn->c_recvfd != -1)
How-To-Repeat: server# ggated
client# ggatec create -oro server /dev/da0
client# ggatec destroy -u 0
server# mount -orw /dev/da0 /mnt/backup

RW mount on server fails because ggated remain /dev/da0 opened.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2009-03-20 19:08:18 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-geom

Over to maintainer(s).
Comment 2 ota 2016-02-05 05:08:25 UTC
This has been quite a while and I happened to open this after seeing an update.

Looking at the report myself and ggated, ggated grabs all files in the export file at start time.  My report indicates that a file was still locked while ggated was alive although a client disconnected.

It doesn't sound like a bug but rather feature to keep files locked while the daemon is running.
Comment 3 Allan Jude freebsd_committer 2016-02-05 05:26:04 UTC
From my look at it, it looks like ggated opens the device twice when the client connects.

When I repeatedly cycled the client, it seemed to leak 1 GEOM reference each time.

I will write up some reproduction steps over the weekend
Comment 4 Fabian Keil 2016-02-05 07:50:57 UTC
Multiple ggated file descriptor leaks have been fixed in ElectroBSD and reported to the FreeBSD SO in 2014 and 2015 because of the DoS aspect.

For detail see:
and grep for ggate.
Comment 5 Eitan Adler freebsd_committer freebsd_triage 2018-05-28 19:46:10 UTC
batch change:

For bugs that match the following
-  Status Is In progress 
- Untouched since 2018-01-01.
- Affects Base System OR Documentation


Reset to open status.

I did a quick pass but if you are getting this email it might be worthwhile to double check to see if this bug ought to be closed.