-get_carrier_via_sysfs(const char *name, bool *carrier)
-{
- char line[8];
- int retval;
-
- int error = 0;
- char *fn = NULL;
- int fd = -1;
-
- *carrier = false;
-
- fn = xasprintf("/sys/class/net/%s/carrier", name);
- fd = open(fn, O_RDONLY);
- if (fd < 0) {
- error = errno;
- VLOG_WARN_RL(&rl, "%s: open failed: %s", fn, strerror(error));
- goto exit;
- }
-
- retval = read(fd, line, sizeof line);
- if (retval < 0) {
- error = errno;
- if (error == EINVAL) {
- /* This is the normal return value when we try to check carrier if
- * the network device is not up. */
- } else {
- VLOG_WARN_RL(&rl, "%s: read failed: %s", fn, strerror(error));
- }
- goto exit;
- } else if (retval == 0) {
- error = EPROTO;
- VLOG_WARN_RL(&rl, "%s: unexpected end of file", fn);
- goto exit;
- }
-
- if (line[0] != '0' && line[0] != '1') {
- error = EPROTO;
- VLOG_WARN_RL(&rl, "%s: value is %c (expected 0 or 1)", fn, line[0]);
- goto exit;
- }
- *carrier = line[0] != '0';
- error = 0;
-
-exit:
- if (fd >= 0) {
- close(fd);
- }
- free(fn);
- return error;
-}
-
-static int
-get_flags(const struct netdev *netdev, int *flags)