Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
91dd15a4
Unverified
Commit
91dd15a4
authored
Jun 19, 2020
by
Stéphane Graber
Committed by
GitHub
Jun 19, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3454 from brauner/master
tree-wide: variable naming update
parents
8ed01f3c
992a0a67
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
57 additions
and
56 deletions
+57
-56
CODING_STYLE.md
CODING_STYLE.md
+6
-7
lxc.container.conf.sgml.in
doc/ja/lxc.container.conf.sgml.in
+10
-10
lxc.container.conf.sgml.in
doc/lxc.container.conf.sgml.in
+9
-9
openpty.c
src/include/openpty.c
+14
-14
openpty.h
src/include/openpty.h
+6
-4
console.c
src/tests/console.c
+12
-12
No files found.
CODING_STYLE.md
View file @
91dd15a4
...
@@ -733,11 +733,11 @@ __do_closedir __attribute__((__cleanup__(__auto_closedir__)))
...
@@ -733,11 +733,11 @@ __do_closedir __attribute__((__cleanup__(__auto_closedir__)))
```
```
For example:
For example:
```
c
```
c
void
remount_all_slave
(void)
void
turn_into_dependent_mounts
(void)
{
{
__do_free char
*
line = NULL;
__do_free char
*
line = NULL;
__do_fclose FILE
*
f = NULL;
__do_fclose FILE
*
f = NULL;
__do_close
_prot_errno
int memfd = -EBADF, mntinfo_fd = -EBADF;
__do_close int memfd = -EBADF, mntinfo_fd = -EBADF;
int ret;
int ret;
ssize_t copied;
ssize_t copied;
size_t len = 0;
size_t len = 0;
...
@@ -780,7 +780,7 @@ again:
...
@@ -780,7 +780,7 @@ again:
return;
return;
}
}
f = fdopen(memfd, "r");
f = fdopen(memfd, "r
e
");
if (!f) {
if (!f) {
SYSERROR("Failed to open copy of \"/proc/self/mountinfo\" to mark all shared. Continuing");
SYSERROR("Failed to open copy of \"/proc/self/mountinfo\" to mark all shared. Continuing");
return;
return;
...
@@ -810,12 +810,11 @@ again:
...
@@ -810,12 +810,11 @@ again:
null_endofword(target);
null_endofword(target);
ret = mount(NULL, target, NULL, MS_SLAVE, NULL);
ret = mount(NULL, target, NULL, MS_SLAVE, NULL);
if (ret < 0) {
if (ret < 0) {
SYSERROR("Failed to make \"%s\" MS_SLAVE", target);
SYSERROR("Failed to recursively turn old root mount tree into dependent mount. Continuing...");
ERROR("Continuing...");
continue;
continue;
}
}
TRACE("Re
mounted \"%s\" as MS_SLAVE", target
);
TRACE("Re
cursively turned old root mount tree into dependent mount"
);
}
}
TRACE("
Remounted all mount table entries as MS_SLAVE
");
TRACE("
Turned all mount table entries into dependent mount
");
}
}
```
```
doc/ja/lxc.container.conf.sgml.in
View file @
91dd15a4
...
@@ -713,25 +713,25 @@ by KATOH Yasufumi <karma at jazz.email.ne.jp>
...
@@ -713,25 +713,25 @@ by KATOH Yasufumi <karma at jazz.email.ne.jp>
modes are <option>l3</option>, <option>l3s</option> and
modes are <option>l3</option>, <option>l3s</option> and
<option>l2</option>. It defaults to <option>l3</option> mode.
<option>l2</option>. It defaults to <option>l3</option> mode.
In <option>l3</option> mode TX processing up to L3 happens on the stack instance
In <option>l3</option> mode TX processing up to L3 happens on the stack instance
attached to the
slave
device and packets are switched to the stack instance of the
attached to the
dependent
device and packets are switched to the stack instance of the
master
device for the L2 processing and routing from that instance will be
parent
device for the L2 processing and routing from that instance will be
used before packets are queued on the outbound device. In this mode the
slav
es
used before packets are queued on the outbound device. In this mode the
dependent devic
es
will not receive nor can send multicast / broadcast traffic.
will not receive nor can send multicast / broadcast traffic.
In <option>l3s</option> mode TX processing is very similar to the L3 mode except that
In <option>l3s</option> mode TX processing is very similar to the L3 mode except that
iptables (conn-tracking) works in this mode and hence it is L3-symmetric (L3s).
iptables (conn-tracking) works in this mode and hence it is L3-symmetric (L3s).
This will have slightly less performance but that shouldn't matter since you are
This will have slightly less performance but that shouldn't matter since you are
choosing this mode over plain-L3 mode to make conn-tracking work.
choosing this mode over plain-L3 mode to make conn-tracking work.
In <option>l2</option> mode TX processing happens on the stack instance attached to
In <option>l2</option> mode TX processing happens on the stack instance attached to
the
slave device and packets are switched and queued to the master
device to send
the
dependent device and packets are switched and queued to the parent
device to send
out. In this mode the
slav
es will RX/TX multicast and broadcast (if applicable) as well.
out. In this mode the
dependent devic
es will RX/TX multicast and broadcast (if applicable) as well.
<option>lxc.net.[i].ipvlan.isolation</option> specifies the isolation mode.
<option>lxc.net.[i].ipvlan.isolation</option> specifies the isolation mode.
The accepted isolation values are <option>bridge</option>,
The accepted isolation values are <option>bridge</option>,
<option>private</option> and <option>vepa</option>.
<option>private</option> and <option>vepa</option>.
It defaults to <option>bridge</option>.
It defaults to <option>bridge</option>.
In <option>bridge</option> isolation mode
slav
es can cross-talk among themselves
In <option>bridge</option> isolation mode
dependent devic
es can cross-talk among themselves
apart from talking through the
master
device.
apart from talking through the
parent
device.
In <option>private</option> isolation mode the port is set in private mode.
In <option>private</option> isolation mode the port is set in private mode.
i.e. port won't allow cross communication between
slav
es.
i.e. port won't allow cross communication between
dependent devic
es.
In <option>vepa</option> isolation mode the port is set in VEPA mode.
In <option>vepa</option> isolation mode the port is set in VEPA mode.
i.e. port will offload switching functionality to the external entity as
i.e. port will offload switching functionality to the external entity as
described in 802.1Qbg.
described in 802.1Qbg.
...
@@ -1548,7 +1548,7 @@ by KATOH Yasufumi <karma at jazz.email.ne.jp>
...
@@ -1548,7 +1548,7 @@ by KATOH Yasufumi <karma at jazz.email.ne.jp>
fstab フォーマットの一行と同じフォーマットのマウントポイントの指定をします。
fstab フォーマットの一行と同じフォーマットのマウントポイントの指定をします。
<!--
<!--
Moreover lxc supports mount propagation, such as rs
lave
or
Moreover lxc supports mount propagation, such as rs
hared
or
rprivate, and adds three additional mount options.
rprivate, and adds three additional mount options.
<option>optional</option> don't fail if mount does not work.
<option>optional</option> don't fail if mount does not work.
<option>create=dir</option> or <option>create=file</option>
<option>create=dir</option> or <option>create=file</option>
...
@@ -1556,7 +1556,7 @@ by KATOH Yasufumi <karma at jazz.email.ne.jp>
...
@@ -1556,7 +1556,7 @@ by KATOH Yasufumi <karma at jazz.email.ne.jp>
<option>relative</option> source path is taken to be relative to
<option>relative</option> source path is taken to be relative to
the mounted container root. For instance,
the mounted container root. For instance,
-->
-->
加えて、LXC では rs
lave
や rprivate といったマウント・プロパゲーションオプションと、独自の 3 つのマウントオプションが使えます。
加えて、LXC では rs
hared
や rprivate といったマウント・プロパゲーションオプションと、独自の 3 つのマウントオプションが使えます。
<option>optional</option> は、マウントが失敗しても失敗を返さずに無視します。
<option>optional</option> は、マウントが失敗しても失敗を返さずに無視します。
<option>create=dir</option> と <option>create=file</option> は、マウントポイントをマウントする際にディレクトリもしくはファイルを作成します。
<option>create=dir</option> と <option>create=file</option> は、マウントポイントをマウントする際にディレクトリもしくはファイルを作成します。
<option>relative</option> を指定すると、マウントされたコンテナルートからの相対パスとして取得されます。
<option>relative</option> を指定すると、マウントされたコンテナルートからの相対パスとして取得されます。
...
...
doc/lxc.container.conf.sgml.in
View file @
91dd15a4
...
@@ -536,25 +536,25 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
...
@@ -536,25 +536,25 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
modes are <option>l3</option>, <option>l3s</option> and
modes are <option>l3</option>, <option>l3s</option> and
<option>l2</option>. It defaults to <option>l3</option> mode.
<option>l2</option>. It defaults to <option>l3</option> mode.
In <option>l3</option> mode TX processing up to L3 happens on the stack instance
In <option>l3</option> mode TX processing up to L3 happens on the stack instance
attached to the
slave
device and packets are switched to the stack instance of the
attached to the
dependent
device and packets are switched to the stack instance of the
master
device for the L2 processing and routing from that instance will be
parent
device for the L2 processing and routing from that instance will be
used before packets are queued on the outbound device. In this mode the
slav
es
used before packets are queued on the outbound device. In this mode the
dependent devic
es
will not receive nor can send multicast / broadcast traffic.
will not receive nor can send multicast / broadcast traffic.
In <option>l3s</option> mode TX processing is very similar to the L3 mode except that
In <option>l3s</option> mode TX processing is very similar to the L3 mode except that
iptables (conn-tracking) works in this mode and hence it is L3-symmetric (L3s).
iptables (conn-tracking) works in this mode and hence it is L3-symmetric (L3s).
This will have slightly less performance but that shouldn't matter since you are
This will have slightly less performance but that shouldn't matter since you are
choosing this mode over plain-L3 mode to make conn-tracking work.
choosing this mode over plain-L3 mode to make conn-tracking work.
In <option>l2</option> mode TX processing happens on the stack instance attached to
In <option>l2</option> mode TX processing happens on the stack instance attached to
the
slave device and packets are switched and queued to the master device to send
the
dependent device and packets are switched and queued to the parent device to send devices
out. In this mode the
slav
es will RX/TX multicast and broadcast (if applicable) as well.
out. In this mode the
dependent devic
es will RX/TX multicast and broadcast (if applicable) as well.
<option>lxc.net.[i].ipvlan.isolation</option> specifies the isolation mode.
<option>lxc.net.[i].ipvlan.isolation</option> specifies the isolation mode.
The accepted isolation values are <option>bridge</option>,
The accepted isolation values are <option>bridge</option>,
<option>private</option> and <option>vepa</option>.
<option>private</option> and <option>vepa</option>.
It defaults to <option>bridge</option>.
It defaults to <option>bridge</option>.
In <option>bridge</option> isolation mode
slav
es can cross-talk among themselves
In <option>bridge</option> isolation mode
dependent devic
es can cross-talk among themselves
apart from talking through the
master
device.
apart from talking through the
parent
device.
In <option>private</option> isolation mode the port is set in private mode.
In <option>private</option> isolation mode the port is set in private mode.
i.e. port won't allow cross communication between
slav
es.
i.e. port won't allow cross communication between
dependent devic
es.
In <option>vepa</option> isolation mode the port is set in VEPA mode.
In <option>vepa</option> isolation mode the port is set in VEPA mode.
i.e. port will offload switching functionality to the external entity as
i.e. port will offload switching functionality to the external entity as
described in 802.1Qbg.
described in 802.1Qbg.
...
@@ -1170,7 +1170,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
...
@@ -1170,7 +1170,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Specify a mount point corresponding to a line in the
Specify a mount point corresponding to a line in the
fstab format.
fstab format.
Moreover lxc supports mount propagation, such as rs
lave
or
Moreover lxc supports mount propagation, such as rs
hared
or
rprivate, and adds three additional mount options.
rprivate, and adds three additional mount options.
<option>optional</option> don't fail if mount does not work.
<option>optional</option> don't fail if mount does not work.
<option>create=dir</option> or <option>create=file</option>
<option>create=dir</option> or <option>create=file</option>
...
...
src/include/openpty.c
View file @
91dd15a4
...
@@ -34,43 +34,43 @@
...
@@ -34,43 +34,43 @@
#define _PATH_DEVPTMX "/dev/ptmx"
#define _PATH_DEVPTMX "/dev/ptmx"
int
openpty
(
int
*
a
master
,
int
*
aslave
,
char
*
name
,
struct
termios
*
termp
,
int
openpty
(
int
*
a
ptmx
,
int
*
apts
,
char
*
name
,
struct
termios
*
termp
,
struct
winsize
*
winp
)
struct
winsize
*
winp
)
{
{
char
buf
[
PATH_MAX
];
char
buf
[
PATH_MAX
];
int
master
,
slave
;
int
ptmx
,
pts
;
master
=
open
(
_PATH_DEVPTMX
,
O_RDWR
);
ptmx
=
open
(
_PATH_DEVPTMX
,
O_RDWR
);
if
(
master
==
-
1
)
if
(
ptmx
==
-
1
)
return
-
1
;
return
-
1
;
if
(
grantpt
(
master
))
if
(
grantpt
(
ptmx
))
goto
fail
;
goto
fail
;
if
(
unlockpt
(
master
))
if
(
unlockpt
(
ptmx
))
goto
fail
;
goto
fail
;
if
(
ptsname_r
(
master
,
buf
,
sizeof
buf
))
if
(
ptsname_r
(
ptmx
,
buf
,
sizeof
buf
))
goto
fail
;
goto
fail
;
slave
=
open
(
buf
,
O_RDWR
|
O_NOCTTY
);
pts
=
open
(
buf
,
O_RDWR
|
O_NOCTTY
);
if
(
slave
==
-
1
)
if
(
pts
==
-
1
)
goto
fail
;
goto
fail
;
/* XXX Should we ignore errors here? */
/* XXX Should we ignore errors here? */
if
(
termp
)
if
(
termp
)
tcsetattr
(
slave
,
TCSAFLUSH
,
termp
);
tcsetattr
(
pts
,
TCSAFLUSH
,
termp
);
if
(
winp
)
if
(
winp
)
ioctl
(
slave
,
TIOCSWINSZ
,
winp
);
ioctl
(
pts
,
TIOCSWINSZ
,
winp
);
*
a
master
=
master
;
*
a
ptmx
=
ptmx
;
*
a
slave
=
slave
;
*
a
pts
=
pts
;
if
(
name
!=
NULL
)
if
(
name
!=
NULL
)
strcpy
(
name
,
buf
);
strcpy
(
name
,
buf
);
return
0
;
return
0
;
fail:
fail:
close
(
master
);
close
(
ptmx
);
return
-
1
;
return
-
1
;
}
}
src/include/openpty.h
View file @
91dd15a4
...
@@ -27,10 +27,12 @@
...
@@ -27,10 +27,12 @@
#include <termios.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <sys/ioctl.h>
/* Create pseudo tty master slave pair with NAME and set terminal
/*
attributes according to TERMP and WINP and return handles for both
* Create pseudo tty ptmx pts pair with @__name and set terminal
ends in AMASTER and ASLAVE. */
* attributes according to @__termp and @__winp and return handles for both
extern
int
openpty
(
int
*
__amaster
,
int
*
__aslave
,
char
*
__name
,
* ends in @__aptmx and @__apts.
*/
extern
int
openpty
(
int
*
__aptmx
,
int
*
__apts
,
char
*
__name
,
const
struct
termios
*
__termp
,
const
struct
termios
*
__termp
,
const
struct
winsize
*
__winp
);
const
struct
winsize
*
__winp
);
...
...
src/tests/console.c
View file @
91dd15a4
...
@@ -37,14 +37,14 @@
...
@@ -37,14 +37,14 @@
} while (0)
} while (0)
static
void
test_console_close_all
(
int
ttyfd
[
MAXCONSOLES
],
static
void
test_console_close_all
(
int
ttyfd
[
MAXCONSOLES
],
int
master
fd
[
MAXCONSOLES
])
int
ptmx
fd
[
MAXCONSOLES
])
{
{
int
i
;
int
i
;
for
(
i
=
0
;
i
<
MAXCONSOLES
;
i
++
)
{
for
(
i
=
0
;
i
<
MAXCONSOLES
;
i
++
)
{
if
(
master
fd
[
i
]
!=
-
1
)
{
if
(
ptmx
fd
[
i
]
!=
-
1
)
{
close
(
master
fd
[
i
]);
close
(
ptmx
fd
[
i
]);
master
fd
[
i
]
=
-
1
;
ptmx
fd
[
i
]
=
-
1
;
}
}
if
(
ttyfd
[
i
]
!=
-
1
)
{
if
(
ttyfd
[
i
]
!=
-
1
)
{
...
@@ -59,14 +59,14 @@ static int test_console_running_container(struct lxc_container *c)
...
@@ -59,14 +59,14 @@ static int test_console_running_container(struct lxc_container *c)
int
nrconsoles
,
i
,
ret
=
-
1
;
int
nrconsoles
,
i
,
ret
=
-
1
;
int
ttynum
[
MAXCONSOLES
];
int
ttynum
[
MAXCONSOLES
];
int
ttyfd
[
MAXCONSOLES
];
int
ttyfd
[
MAXCONSOLES
];
int
master
fd
[
MAXCONSOLES
];
int
ptmx
fd
[
MAXCONSOLES
];
for
(
i
=
0
;
i
<
MAXCONSOLES
;
i
++
)
for
(
i
=
0
;
i
<
MAXCONSOLES
;
i
++
)
ttynum
[
i
]
=
ttyfd
[
i
]
=
master
fd
[
i
]
=
-
1
;
ttynum
[
i
]
=
ttyfd
[
i
]
=
ptmx
fd
[
i
]
=
-
1
;
ttynum
[
0
]
=
1
;
ttynum
[
0
]
=
1
;
ret
=
c
->
console_getfd
(
c
,
&
ttynum
[
0
],
&
master
fd
[
0
]);
ret
=
c
->
console_getfd
(
c
,
&
ttynum
[
0
],
&
ptmx
fd
[
0
]);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
TSTERR
(
"console allocate failed"
);
TSTERR
(
"console allocate failed"
);
goto
err1
;
goto
err1
;
...
@@ -79,12 +79,12 @@ static int test_console_running_container(struct lxc_container *c)
...
@@ -79,12 +79,12 @@ static int test_console_running_container(struct lxc_container *c)
}
}
/* attempt to alloc same ttynum */
/* attempt to alloc same ttynum */
ret
=
c
->
console_getfd
(
c
,
&
ttynum
[
0
],
&
master
fd
[
1
]);
ret
=
c
->
console_getfd
(
c
,
&
ttynum
[
0
],
&
ptmx
fd
[
1
]);
if
(
ret
!=
-
1
)
{
if
(
ret
!=
-
1
)
{
TSTERR
(
"console allocate should fail for allocated ttynum %d"
,
ttynum
[
0
]);
TSTERR
(
"console allocate should fail for allocated ttynum %d"
,
ttynum
[
0
]);
goto
err2
;
goto
err2
;
}
}
close
(
masterfd
[
0
]);
master
fd
[
0
]
=
-
1
;
close
(
ptmxfd
[
0
]);
ptmx
fd
[
0
]
=
-
1
;
close
(
ttyfd
[
0
]);
ttyfd
[
0
]
=
-
1
;
close
(
ttyfd
[
0
]);
ttyfd
[
0
]
=
-
1
;
/* ensure we can allocate all consoles, we do this a few times to
/* ensure we can allocate all consoles, we do this a few times to
...
@@ -92,7 +92,7 @@ static int test_console_running_container(struct lxc_container *c)
...
@@ -92,7 +92,7 @@ static int test_console_running_container(struct lxc_container *c)
*/
*/
for
(
i
=
0
;
i
<
10
;
i
++
)
{
for
(
i
=
0
;
i
<
10
;
i
++
)
{
for
(
nrconsoles
=
0
;
nrconsoles
<
MAXCONSOLES
;
nrconsoles
++
)
{
for
(
nrconsoles
=
0
;
nrconsoles
<
MAXCONSOLES
;
nrconsoles
++
)
{
ret
=
c
->
console_getfd
(
c
,
&
ttynum
[
nrconsoles
],
&
master
fd
[
nrconsoles
]);
ret
=
c
->
console_getfd
(
c
,
&
ttynum
[
nrconsoles
],
&
ptmx
fd
[
nrconsoles
]);
if
(
ret
<
0
)
if
(
ret
<
0
)
break
;
break
;
ttyfd
[
nrconsoles
]
=
ret
;
ttyfd
[
nrconsoles
]
=
ret
;
...
@@ -103,13 +103,13 @@ static int test_console_running_container(struct lxc_container *c)
...
@@ -103,13 +103,13 @@ static int test_console_running_container(struct lxc_container *c)
goto
err2
;
goto
err2
;
}
}
test_console_close_all
(
ttyfd
,
master
fd
);
test_console_close_all
(
ttyfd
,
ptmx
fd
);
}
}
ret
=
0
;
ret
=
0
;
err2:
err2:
test_console_close_all
(
ttyfd
,
master
fd
);
test_console_close_all
(
ttyfd
,
ptmx
fd
);
err1:
err1:
return
ret
;
return
ret
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment