/****************************************************************************** * Copyright (c) Huawei Technologies Co., Ltd. 2017-2019. All rights reserved. * isulad-tools is licensed under the Mulan PSL v1. * You can use this software according to the terms and conditions of the Mulan PSL v1. * You may obtain a copy of Mulan PSL v1 at: * http://license.coscl.org.cn/MulanPSL * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR * PURPOSE. * See the Mulan PSL v1 for more details. * Author: zhangwentao * Create: 2017-07-19 * Description: config net device tx/sg/tso on ******************************************************************************/ #include #include #include #include #include #include #include #include #include #include #include #include #include int setNetDeviceTSO(int fd, char* name, int on) { struct ifreq ifr = {0}; struct ethtool_value eval = {0}; int ret; eval.data = on; eval.cmd = ETHTOOL_STSO; strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name) - 1); ifr.ifr_data = (void*)&eval; ret = ioctl(fd, SIOCETHTOOL, &ifr); if (ret < 0) { return -1; } return 0; } int setNetDeviceSG(int fd, char* name, int on) { struct ifreq ifr = {0}; struct ethtool_value eval = {0}; int ret; eval.data = on; eval.cmd = ETHTOOL_SSG; strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name) - 1); ifr.ifr_data = (void*)&eval; ret = ioctl(fd, SIOCETHTOOL, &ifr); if (ret < 0) { return -1; } return 0; } int setNetDeviceTX(int fd, char* name, int on) { struct ifreq ifr = {0}; struct ethtool_value eval = {0}; int ret; eval.data = on; eval.cmd = ETHTOOL_STXCSUM; strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name) - 1); ifr.ifr_data = (void*)&eval; ret = ioctl(fd, SIOCETHTOOL, &ifr); if (ret < 0) { return -1; } return 0; }